14 package cz.vutbr.fit.knot.annotations.web;
 
   26 import java.io.ByteArrayInputStream;
 
   27 import java.io.IOException;
 
   28 import java.io.InputStream;
 
   29 import java.io.Serializable;
 
   30 import java.io.StringWriter;
 
   31 import java.io.UnsupportedEncodingException;
 
   32 import java.util.ArrayList;
 
   33 import java.util.Collections;
 
   34 import java.util.HashMap;
 
   35 import java.util.HashSet;
 
   36 import java.util.Iterator;
 
   37 import java.util.LinkedList;
 
   38 import java.util.List;
 
   41 import javax.faces.bean.ManagedBean;
 
   42 import javax.faces.bean.ViewScoped;
 
   43 import javax.persistence.EntityManager;
 
   44 import javax.persistence.EntityTransaction;
 
   45 import javax.persistence.Query;
 
   46 import org.apache.commons.io.IOUtils;
 
   47 import org.apache.myfaces.custom.fileupload.UploadedFile;
 
   48 import org.semanticweb.owlapi.apibinding.OWLManager;
 
   49 import org.semanticweb.owlapi.model.ClassExpressionType;
 
   50 import org.semanticweb.owlapi.model.OWLAnnotation;
 
   51 import org.semanticweb.owlapi.model.OWLAnnotationProperty;
 
   52 import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom;
 
   53 import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom;
 
   54 import org.semanticweb.owlapi.model.OWLAnnotationValue;
 
   55 import org.semanticweb.owlapi.model.OWLAxiom;
 
   56 import org.semanticweb.owlapi.model.OWLClass;
 
   57 import org.semanticweb.owlapi.model.OWLClassExpression;
 
   58 import org.semanticweb.owlapi.model.OWLDataFactory;
 
   59 import org.semanticweb.owlapi.model.OWLDataProperty;
 
   60 import org.semanticweb.owlapi.model.OWLDataPropertyExpression;
 
   61 import org.semanticweb.owlapi.model.OWLDataRange;
 
   62 import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom;
 
   63 import org.semanticweb.owlapi.model.OWLIndividual;
 
   64 import org.semanticweb.owlapi.model.OWLLiteral;
 
   65 import org.semanticweb.owlapi.model.OWLNamedIndividual;
 
   66 import org.semanticweb.owlapi.model.OWLObjectIntersectionOf;
 
   67 import org.semanticweb.owlapi.model.OWLObjectOneOf;
 
   68 import org.semanticweb.owlapi.model.OWLObjectProperty;
 
   69 import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom;
 
   70 import org.semanticweb.owlapi.model.OWLObjectPropertyExpression;
 
   71 import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom;
 
   72 import org.semanticweb.owlapi.model.OWLObjectUnionOf;
 
   73 import org.semanticweb.owlapi.model.OWLOntology;
 
   74 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
 
   75 import org.semanticweb.owlapi.model.OWLOntologyManager;
 
   76 import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom;
 
   77 import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom;
 
   78 import org.semanticweb.owlapi.util.OWLOntologyWalker;
 
   79 import org.semanticweb.owlapi.util.OWLOntologyWalkerVisitor;
 
   80 import uk.ac.manchester.cs.owl.owlapi.OWLDatatypeImpl;
 
  205       this.disjointWithSet = 
new HashSet<String>();
 
  248       this.dataProperty = null;
 
  256       this.objectProperty = null;
 
  264       this.objectProperty = null;
 
  265       this.dataProperty = null;
 
  294     isAnonymous.value = 
false;
 
  296     if (originURI.startsWith(
"_:genid")) {
 
  299         endOfUrl = originURI.substring(7);
 
  300       } 
catch (Exception e) { 
 
  304         isAnonymous.value = 
true;
 
  305         return AppBean.getBaseUri() + 
"#";
 
  310     int anonymousStartName = originURI.lastIndexOf(
"#genid");
 
  312     if (anonymousStartName == -1) {
 
  318     isAnonymous.value = 
true;
 
  319     return originURI.substring(0, anonymousStartName + 1);
 
  329     int startName = originURI.lastIndexOf(
"#");
 
  331     if (startName == -1) {
 
  334     return originURI.substring(0, startName + 1);
 
  343     return str.substring(0, 1).toUpperCase() + str.substring(1);
 
  354     isAnnonymous.value = 
false;
 
  355     if (uri.startsWith(
"http://org.semanticweb.owlapi/error#Error")) { 
 
  356       isAnnonymous.value = 
true;
 
  357       return AppBean.getBaseOntoUploadUri() + 
"anonymous#classgenid" + uri.substring(41);
 
  379     int startIndex = uri.indexOf(
"#"); 
 
  380     if (startIndex == -1) { 
 
  381       startIndex = uri.lastIndexOf(
"/"); 
 
  383     return uri.substring(++startIndex);
 
  403   private int createAnnotTypeFromIndividual(OWLOntology oModel, OWLDataFactory oFactory, ArrayList<AnnotType> newTypes, Map<String, AnnotType> newTypesMap, Map<String, AnnotTypeInfo> newTypesMapInfo, 
UserGroup userGroup, OWLIndividual individual, String name, 
int anonymousIndividualCount) {
 
  404     String individualUri = individual.toStringID();
 
  405     String individualCorrectUri = individualUri;
 
  406     if (individual.isAnonymous()) {
 
  407       int indexSharp = individualCorrectUri.indexOf(
"#");
 
  408       if (indexSharp == -1) { 
 
  409         if (!individualCorrectUri.startsWith(
"_:genid")) {
 
  410           return anonymousIndividualCount;
 
  412         individualCorrectUri = AppBean.getBaseUri() + 
"#Specific" + name + ++anonymousIndividualCount;
 
  414         int indexHttp = individualCorrectUri.indexOf(
"http://");
 
  415         if (indexHttp == -1) { 
 
  416           return anonymousIndividualCount;
 
  418         individualCorrectUri = individualCorrectUri.substring(indexHttp, indexSharp+1) + 
"Specific" + name + ++anonymousIndividualCount;
 
  425     individualType.setUriInOntology(individualCorrectUri);
 
  427     if (newTypesMap.containsKey(individualCorrectUri)) {  
 
  429       return anonymousIndividualCount;
 
  433     if (!individual.isAnonymous()) {
 
  435         comment = 
getComments(oFactory, individual.asOWLNamedIndividual().getAnnotations(oModel));
 
  436       } 
catch (Exception e) {}
 
  438     if (!comment.isEmpty()) {
 
  439       individualType.setComment(comment);
 
  441     newTypes.add(individualType);
 
  442     newTypesMap.put(individualCorrectUri, individualType);
 
  443     newTypesMapInfo.put(individualUri, individualInfo);
 
  444     return anonymousIndividualCount;
 
  461   private boolean processModelPhase1(OWLOntology oModel, OWLDataFactory oFactory, ArrayList<AnnotType> newTypes, Map<String, AnnotType> newTypesMap, 
UserGroup userGroup, Map<String, AnnotTypeInfo> newTypesMapInfo) {
 
  463     for (OWLClass ontClass : oModel.getClassesInSignature()) { 
 
  464       String uri = ontClass.toStringID();  
 
  470               ontClass, 
false, (name.isEmpty() ? 
true : isAnnonymous.value));
 
  472       type.setUriInOntology(uri);
 
  473       if (newTypesMap.containsKey(uri)) {  
 
  478         type.setRestrictedAtt(
true);
 
  480       newTypesMapInfo.put(ontClass.toStringID(), info);
 
  482       newTypesMap.put(uri, type);
 
  483       Set<OWLIndividual> classIndividuals = ontClass.getIndividuals(oModel);
 
  484       int anonymousIndividualCount = 0;
 
  485       for (OWLIndividual individual : classIndividuals) {
 
  487                 newTypesMap, newTypesMapInfo, userGroup, individual, name, anonymousIndividualCount);
 
  506     Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
  507     boolean aFound = 
false;
 
  508     while (atrIt.hasNext()) {  
 
  510       if (aTA.
getName().equals(prName)) {
 
  516       attr.setUriInOntology(prUri);
 
  517       if (!comment.isEmpty()) {
 
  518         attr.setComment(comment);
 
  520       type.getAttributes().add(attr);
 
  535     isRequired.value = 
false;
 
  536     String stringType = 
"";
 
  537     if (stringURI.contains(
"XMLSchema#string")) {
 
  538       stringType = 
"String";
 
  539     } 
else if (stringURI.contains(
"XMLSchema#anyURI")) {
 
  541     } 
else if (stringURI.contains(
"XMLSchema#float") || stringURI.contains(
"XMLSchema#double")) {
 
  542       stringType = 
"Decimal";
 
  543     } 
else if (stringURI.contains(
"XMLSchema#dateTime")) {
 
  544       stringType = 
"DateTime";
 
  545     } 
else if (stringURI.contains(
"XMLSchema#decimal")) {
 
  546       stringType = 
"Decimal";
 
  547     } 
else if (stringURI.contains(
"XMLSchema#date")
 
  548             || stringURI.contains(
"XMLSchema#gYearMonth")
 
  549             || stringURI.contains(
"XMLSchema#gYear")
 
  550             || stringURI.contains(
"XMLSchema#gDay")
 
  551             || stringURI.contains(
"XMLSchema#gMonth")
 
  552             || stringURI.contains(
"XMLSchema#gMonthDay")) {
 
  554     } 
else if (stringURI.contains(
"XMLSchema#time")) {
 
  556     } 
else if (stringURI.contains(
"XMLSchema#boolean")) {
 
  557       stringType = 
"Boolean";
 
  558     } 
else if (stringURI.contains(
"XMLSchema#integer")
 
  559             || stringURI.contains(
"XMLSchema#long")
 
  560             || stringURI.contains(
"XMLSchema#int")
 
  561             || stringURI.contains(
"XMLSchema#short")
 
  562             || stringURI.contains(
"XMLSchema#byte")
 
  563             || stringURI.contains(
"XMLSchema#nonPositiveInteger")
 
  564             || stringURI.contains(
"XMLSchema#negativeInteger")
 
  565             || stringURI.contains(
"XMLSchema#nonNegativeInteger")
 
  566             || stringURI.contains(
"XMLSchema#positiveInteger")
 
  567             || stringURI.contains(
"XMLSchema#unsignedLong")
 
  568             || stringURI.contains(
"XMLSchema#unsignedInt")
 
  569             || stringURI.contains(
"XMLSchema#unsignedShort")
 
  570             || stringURI.contains(
"XMLSchema#unsignedByte")) {  
 
  571       stringType = 
"Integer";
 
  572     } 
else if (stringURI.contains(
"XMLSchema#normalizedString")
 
  573             || stringURI.contains(
"XMLSchema#token")
 
  574             || stringURI.contains(
"XMLSchema#language")
 
  575             || stringURI.contains(
"XMLSchema#QName")
 
  576             || stringURI.contains(
"XMLSchema#NOTATION")
 
  577             || stringURI.contains(
"XMLSchema#ID")
 
  578             || stringURI.contains(
"XMLSchema#ENTITY")
 
  579             || stringURI.contains(
"XMLSchema#ENTITIES")
 
  580             || stringURI.contains(
"XMLSchema#IDREF")
 
  581             || stringURI.contains(
"XMLSchema#IDREFS")
 
  582             || stringURI.contains(
"XMLSchema#Name")
 
  583             || stringURI.contains(
"XMLSchema#NCName")) {  
 
  584       stringType = 
"String";
 
  585     } 
else if (stringURI.contains(
"XMLSchema#NMTOKEN")
 
  586             || stringURI.contains(
"XMLSchema#NMTOKENS")) {
 
  587       stringType = 
"String";
 
  588       isRequired.value = 
true;
 
  589     } 
else if (stringURI.contains(
"XMLSchema#base64Binary")
 
  590             || stringURI.contains(
"XMLSchema#hexBinary")) {  
 
  591       stringType = 
"Binary";
 
  592     } 
else if (stringURI.contains(
"XMLSchema#duration")) {  
 
  593       stringType = 
"Duration";
 
  622           HashSet<String> subjectSetClassURI, HashSet<String> objectSetClassURI,
 
  623           Map<String, AnnotType> newTypesMap,
 
  624           Map<String, AnnotTypeInfo> newTypesMapInfo, ArrayList<TypeAttrOnto> ontoAttrs,
 
  625           UserGroup userGroup, Set<String> superPropertiesStringSet,
 
  626           Set<String> inversePropertiesID, OWLOntology oModel) { 
 
  635       if (anonymousProperty.
value) {
 
  636         if (!inversePropertiesID.isEmpty()) {
 
  637           anonymousProperty.value = 
false;
 
  638           Iterator<String> itr = inversePropertiesID.iterator();
 
  639           String firstInverseProperty = itr.next();
 
  642           if (superPropertiesStringSet.isEmpty()) {
 
  645             Iterator<String> itr = superPropertiesStringSet.iterator();
 
  646             String ancestor = itr.next();
 
  654       if (prName.isEmpty()) { 
 
  664       if (subjectSetClassURI.isEmpty()) { 
 
  665         processPropertyWS(prUri, prName, comment, objectSetClassURI, userGroup, ontoAttrs, newTypesMap, anonymousProperty.
value);
 
  669       for (String subjectUri : subjectSetClassURI) { 
 
  675         AnnotType type = newTypesMap.get(info.correctedUri);  
 
  683         if (objectSetClassURI.isEmpty()) { 
 
  684           if (!anonymousProperty.
value) { 
 
  690         for (String objUri : objectSetClassURI) { 
 
  692           String newPrUri = prUri;
 
  693           String newPrName = prName;
 
  694           if (!anonymousProperty.
value) {
 
  695             if (objectSetClassURI.size() != 1) {
 
  696               newPrUri += 
"." + objName;
 
  697               newPrName += 
"." + objName;
 
  701             newPrUri += objNameUpperFirstChar;
 
  702             newPrName += objNameUpperFirstChar;
 
  704           if (objUri.endsWith(
"rdf-schema#Literal")) { 
 
  705             if (!anonymousProperty.
value) { 
 
  713             pType = newTypesMap.get(pInfo.correctedUri);
 
  715           if (pType != null && pInfo != null) {  
 
  716             Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
  717             boolean aFound = 
false;
 
  718             while (atrIt.hasNext()) {  
 
  720               if (aTA.
getName().equals(newPrName)) {
 
  726               attr.setUriInOntology(newPrUri);
 
  727               if (comment != null) {
 
  728                 if (!comment.isEmpty()) {
 
  729                     attr.setComment(comment);
 
  732               type.getAttributes().add(attr);
 
  735             if (objUri.contains(
"XMLSchema#")) {
 
  738                 if (simpleType.isEmpty()) {
 
  742                 attr.setUriInOntology(newPrUri);
 
  743                 if (!comment.isEmpty()) {
 
  744                   attr.setComment(comment);
 
  747                 Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
  748                 boolean aFound = 
false;
 
  749                 while (atrIt.hasNext()) {  
 
  751                   if (aTA.
getName().equals(prName)) {
 
  756                   type.getAttributes().add(attr);
 
  777     for (String superClass : superClasses) {
 
  778       if (superClass.equals(propertyURI)) {
 
  783       if (isAnonymous.
value) { 
 
  805           Set<OWLObjectPropertyExpression> superProperties,
 
  806           Set<String> superClasses) {
 
  807     for (OWLObjectPropertyExpression superProperty : superProperties) {
 
  810         property = superProperty.asOWLObjectProperty().toStringID();
 
  811         if (propertyURI.equals(property)) {
 
  814         superClasses.add(property);
 
  815       } 
catch (Exception e) {
 
  832           Set<OWLDataPropertyExpression> superProperties,
 
  833           Set<String> superClasses) {
 
  834     for (OWLDataPropertyExpression superProperty : superProperties) {
 
  837         property = superProperty.asOWLDataProperty().toStringID();
 
  838         if (propertyURI.equals(property)) {
 
  841         superClasses.add(property);
 
  842       } 
catch (Exception e) {
 
  856     if (comment == null) {
 
  859     if (!comment.isEmpty()) {
 
  881                   String propertyName, String oneComment, 
 
  882                   String moreComment1, String moreComment2) {
 
  884       return originalComment;
 
  887     if (objectCount > 1) {
 
  888       originalComment += moreComment1 + propertyName + moreComment2;
 
  890       originalComment += oneComment;
 
  892     return originalComment;
 
  908       OWLDataProperty dataProperty = propertyReference.getDataProperty();
 
  909       OWLObjectProperty objectProperty = propertyReference.getObjectProperty();
 
  911       if (dataProperty != null) {
 
  916       } 
else if (objectProperty != null) {
 
  946     } 
catch (Exception e) {}
 
  961   private String 
getComments( OWLDataFactory oFactory, Set<OWLAnnotation> annotationSet) {
 
  963       for (OWLAnnotation propertyAnnotation : annotationSet) {    
 
  964         OWLAnnotationProperty propertyType = propertyAnnotation.getProperty();  
 
  965         OWLAnnotationValue value = propertyAnnotation.getValue();
 
  967         if (value instanceof OWLLiteral) {
 
  968           OWLLiteral literalValue = (OWLLiteral) value;  
 
  970           literalValue.getObjectPropertiesInSignature();
 
  971           if (propertyType.equals(oFactory.getRDFSComment())) {
 
  972             String commentValue = literalValue.getLiteral();
 
  973             if (!comment.isEmpty()) {
 
  974               comment = comment + 
" \n" + commentValue.trim();
 
  976               comment = commentValue.trim();
 
  996       HashSet<String> set = 
new HashSet<String>();
 
  998         if (exp.getClassExpressionType().equals(ClassExpressionType.OWL_CLASS)) {
 
  999             set.add(exp.asOWLClass().toStringID());
 
 1001         else if (exp.getClassExpressionType().equals(ClassExpressionType.OBJECT_UNION_OF)) {
 
 1002             Set<OWLClass> classSet = ((OWLObjectUnionOf) exp).getClassesInSignature();
 
 1003             for (OWLClass cls : classSet) {
 
 1004                 set.add(cls.toStringID());
 
 1007       } 
catch (Exception e) {}
 
 1025           OWLObjectProperty property, OWLObjectPropertyExpression expression, 
 
 1026           OWLOntology oModel, Set<OWLObjectPropertyExpression> inversePropertyURI,
 
 1027           Set<OWLObjectPropertyExpression> equivalentPropertyURI) {
 
 1034     Set<OWLObjectPropertyExpression> inverses;
 
 1035     Set<OWLObjectPropertyExpression> equivalents;
 
 1036     if (property != null) {
 
 1037       property.getInverseProperty().getRanges(oModel).toString();
 
 1038       inverses = property.getInverses(oModel);
 
 1039       equivalents = property.getEquivalentProperties(oModel);
 
 1041       if (expression == null) { 
 
 1044       inverses = expression.getInverses(oModel);
 
 1045       equivalents = expression.getEquivalentProperties(oModel);
 
 1048     for (OWLObjectPropertyExpression propertyExpression : inverses) {
 
 1049       if (processedProperty.contains(propertyExpression.toString())) {
 
 1052       processedProperty.add(propertyExpression.toString());
 
 1053       inversePropertyURI.add(propertyExpression);
 
 1055               equivalentPropertyURI, inversePropertyURI);
 
 1057     for (OWLObjectPropertyExpression propertyExpression : equivalents) {
 
 1058       if (processedProperty.contains(propertyExpression.toString())) {
 
 1062       processedProperty.add(propertyExpression.toString());
 
 1063       equivalentPropertyURI.add(propertyExpression);
 
 1065               inversePropertyURI, equivalentPropertyURI);
 
 1078                  Set<OWLClassExpression> objectSetExpression,
 
 1079                  Set<OWLClassExpression> subjectSetExpression,
 
 1080                  Set<String> inversePropertiesStringSet) {
 
 1083       Set<OWLObjectPropertyExpression> inverseSet = 
new HashSet<OWLObjectPropertyExpression>();
 
 1084       Set<OWLObjectPropertyExpression> equivalentSet = 
new HashSet<OWLObjectPropertyExpression>();
 
 1087       for (OWLObjectPropertyExpression propertyExpression : inverseSet) { 
 
 1088         if (!propertyExpression.isAnonymous()) { 
 
 1089           String inversePropertyNameID = propertyExpression.getNamedProperty().toStringID();
 
 1090           inversePropertiesStringSet.add(inversePropertyNameID);
 
 1094           if (!isAnonymousByName.
value) {
 
 1095             isAnonymousByName.value = 
true;
 
 1098         if (subjectSetExpression.isEmpty()) {
 
 1099           subjectSetExpression.addAll(propertyExpression.getRanges(oModel));
 
 1101         if (objectSetExpression.isEmpty()) {
 
 1102           objectSetExpression.addAll(propertyExpression.getDomains(oModel));
 
 1106       for (OWLObjectPropertyExpression propertyExpression : equivalentSet) { 
 
 1108         if (propertyExpression.toString().startsWith(
"InverseOf") || !propertyExpression.toString().startsWith(
"<")) {
 
 1112         if (!propertyExpression.isAnonymous()) {
 
 1113           if (propertyExpression.getNamedProperty().toStringID().equalsIgnoreCase(property.toStringID())) {
 
 1117         if (subjectSetExpression.isEmpty()) {
 
 1118           subjectSetExpression.addAll(propertyExpression.getDomains(oModel));
 
 1120         if (objectSetExpression.isEmpty()) {
 
 1121           objectSetExpression.addAll(propertyExpression.getRanges(oModel));
 
 1124     } 
catch (Exception e) {}
 
 1137     LinkedList<String> allAncestorList = 
new LinkedList<String>();
 
 1139       OWLClass actualClass = ontClass;
 
 1141         Set<OWLClassExpression> ancestorSet = actualClass.getSuperClasses(oModel);
 
 1142         Iterator<OWLClassExpression> ancestorIt = ancestorSet.iterator();
 
 1143         if (!ancestorIt.hasNext()) { 
 
 1146         OWLClassExpression ancestor = ancestorIt.next();
 
 1147         String ancestorString = ancestor.asOWLClass().toStringID();
 
 1148         actualClass = ancestor.asOWLClass();
 
 1149         if (allAncestorList.contains(ancestorString)) {
 
 1152         allAncestorList.addLast(ancestorString);
 
 1154     } 
catch (Exception e) {}
 
 1155     return allAncestorList;
 
 1168       Iterator<String> superClassesIt = superClasses.iterator();
 
 1169       while (superClassesIt.hasNext()) { 
 
 1171         AnnotType aType = newTypesMap.get(parentUri);
 
 1172         if (aType != null) {  
 
 1173           type.addAncestorType(aType);
 
 1175           if (!parentUri.equals(
"http://www.w3.org/2002/07/owl#Thing")) {
 
 1178             if (!newTypesMap.containsKey(parentUri)) {  
 
 1181               thing.setUri(thing.getGeneratedURI());
 
 1182               thing.setUriInOntology(parentUri);
 
 1183               newTypesMap.put(parentUri, thing);
 
 1184               newTypes.add(thing);
 
 1186               type.addAncestorType(aType);
 
 1205                 HashSet<String> subjectSetClassURI,
 
 1206                 HashSet<String> ancestorSetClassURI,
 
 1207                 Set<OWLAxiom> allAxioms) {
 
 1208     int anotherAxioms = 0;
 
 1209     for (OWLAxiom ax : allAxioms) {
 
 1210       if (ax.getAxiomType().getName().equals(
"AnnotationPropertyRangeOf") &&
 
 1211           ax instanceof OWLAnnotationPropertyRangeAxiom) {
 
 1212         OWLAnnotationPropertyRangeAxiom range = (OWLAnnotationPropertyRangeAxiom) ax;
 
 1213         objectSetClassURI.add(range.getRange().toString());
 
 1214       } 
else if (ax.getAxiomType().getName().equals(
"AnnotationPropertyDomain") &&
 
 1215                  ax instanceof OWLAnnotationPropertyDomainAxiom) {
 
 1216         OWLAnnotationPropertyDomainAxiom domain = (OWLAnnotationPropertyDomainAxiom) ax;
 
 1217         subjectSetClassURI.add(domain.getDomain().toString());
 
 1218       } 
else if (ax.getAxiomType().getName().equals(
"SubAnnotationPropertyOf") &&
 
 1219                  ax instanceof OWLSubAnnotationPropertyOfAxiom) {
 
 1221           OWLSubAnnotationPropertyOfAxiom ancestor = (OWLSubAnnotationPropertyOfAxiom) ax;
 
 1222           OWLAnnotationProperty ancestorProperty = ancestor.getSuperProperty();
 
 1223           if (ancestorProperty.isOWLObjectProperty()) {
 
 1224             ancestorSetClassURI.add(ancestorProperty.asOWLObjectProperty().toStringID());
 
 1226             ancestorSetClassURI.add(ancestorProperty.getIRI().toString());
 
 1228         } 
catch (Exception e) {}
 
 1230       else if (ax.getAxiomType().getName().equals(
"AnnotationAssertion")) {
 
 1237     return anotherAxioms;
 
 1255   private void processPropertyWS(String prUri, String prName, String comment, HashSet<String> objectSetClassURI, 
UserGroup userGroup, ArrayList<TypeAttrOnto> ontoAttrs, Map<String, AnnotType> newTypesMap, 
boolean isAnonymous) {
 
 1256     Iterator<String> it = objectSetClassURI.iterator();
 
 1257     while (it.hasNext()) {
 
 1258       String objectURI = it.next();
 
 1259       if (objectURI.endsWith(
"rdf-schema#Literal")) { 
 
 1263       if (objectSetClassURI.isEmpty()) {
 
 1267         Iterator<TypeAttrOnto> atrIt = ontoAttrs.iterator();
 
 1268         boolean aFound = 
false;
 
 1269         while (atrIt.hasNext()) {  
 
 1271           if (aTA.
getName().equals(prName)) {
 
 1277           attr.setUriInOntology(prUri);
 
 1278           if (!comment.isEmpty()) {
 
 1279             attr.setComment(comment);
 
 1281           ontoAttrs.add(attr);
 
 1286       if (prName.equals(
"subClassOf")) { 
 
 1292       for (String objUri : objectSetClassURI) {
 
 1293         String newPrName = prName;
 
 1294         String newPrUri = prUri;
 
 1297           if (objectSetClassURI.size() > 1) {
 
 1299             newPrName += 
"." + objName;
 
 1300             newPrUri += 
"." + objName;
 
 1304           newPrName += objName;
 
 1305           newPrUri += objName;
 
 1307         AnnotType pType = newTypesMap.get(objUri);
 
 1308         if (pType != null) {  
 
 1309           Iterator<TypeAttrOnto> atrIt = ontoAttrs.iterator();
 
 1310           boolean aFound = 
false;
 
 1311           while (atrIt.hasNext()) {  
 
 1313             if (aTA.
getName().equals(newPrName)) {
 
 1319             attr.setUriInOntology(newPrUri);
 
 1320             if (!comment.isEmpty()) {
 
 1321               attr.setComment(comment);
 
 1323             ontoAttrs.add(attr);
 
 1327             if (objUri.contains(
"XMLSchema#")) {
 
 1330                 if (simpleType.isEmpty()) {
 
 1333                 Iterator<TypeAttrOnto> atrIt = ontoAttrs.iterator();
 
 1334                 boolean aFound = 
false;
 
 1335                 while (atrIt.hasNext()) {  
 
 1337                   if (aTA.
getName().equals(newPrName)) {
 
 1343                   attr.setUriInOntology(newPrUri);
 
 1344                   if (!comment.isEmpty()) {
 
 1345                     attr.setComment(comment);
 
 1347                   ontoAttrs.add(attr);
 
 1369                           ArrayList<TypeAttrOnto> ontoAttrsDeleted) {
 
 1370     Iterator<TypeAttrOnto> it = ontoAttrs.iterator();
 
 1371     ArrayList<TypeAttrOnto> ontoList = 
new ArrayList<TypeAttrOnto>();
 
 1372     boolean ontoAtrFound = 
false;
 
 1374     while (it.hasNext()) {
 
 1375       ontoAtr = it.next();
 
 1376       String uri = ontoAtr.getUriInOntology();
 
 1377       if (uri.startsWith(propertyURI + 
".") || uri.equalsIgnoreCase(propertyURI)) {
 
 1378         ontoAtrFound = 
true;
 
 1380         ontoAttrsDeleted.add(ontoAtr);
 
 1381         ontoList.add(ontoAtr);
 
 1388     it = ontoAttrsDeleted.iterator();
 
 1389     while (it.hasNext()) {
 
 1390       ontoAtr = it.next();
 
 1393         ontoAtrFound = 
true;
 
 1394         ontoList.add(ontoAtr);
 
 1421                   String typeURI, Map<String, AnnotType> newTypesMap, 
 
 1422                   Map<String, AnnotTypeInfo> newTypesMapInfo, OWLOntology oModel, 
UserGroup userGroup) {
 
 1425       ArrayList<TypeAttrOnto> ontoAtrList = 
getOntoPropertyMayMove(data.propertyURI, ontoAttrs, ontoAttrsDeleted);
 
 1426       HashSet<String> subjectSetClassURI = 
new HashSet<String>();
 
 1427       subjectSetClassURI.add(typeURI);
 
 1428       if (ontoAtrList != null) {
 
 1430           HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 1431           if (oAtr.getAttributeType() != null) {
 
 1432             objectSetClassURI.add(oAtr.getAttributeType().getUriInOntology());
 
 1434           String comment = oAtr.getComment();
 
 1436             (comment == null ? 
"" : comment), subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs,
 
 1437             userGroup, 
new HashSet<String>(), 
new HashSet<String>(), oModel);
 
 1441         HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 1443           "", subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs,
 
 1444           userGroup, 
new HashSet<String>(), 
new HashSet<String>(), oModel);
 
 1461     String newName = 
"";
 
 1464     boolean isSuitableLabel = 
false; 
 
 1465     boolean onlyLabel = 
false;
 
 1466     if (isSuitableLabel && info.
disjointWithSet.isEmpty() && type.getAttributes().isEmpty() && isSuitableLabel) {
 
 1471     boolean firstPart = 
true;
 
 1473     boolean ancestorInName = 
false;
 
 1474     AnnotType ancestorType = type.getAncestorType();
 
 1475     if (ancestorType != null && !onlyLabel) {
 
 1476       if (info.
disjointWithSet.isEmpty() && type.getAttributes().isEmpty()) {
 
 1479         newName += ancestorType.getName();
 
 1481       ancestorInName = 
true;
 
 1485     int disjointClassesCount = 0;
 
 1494       disjointClassesCount++;
 
 1495       if (disjointClassesCount >= 5) {
 
 1501       int attributesCount = type.getAttributes().size();
 
 1506         AnnotTypeAttr atr = (AnnotTypeAttr) atrObj;
 
 1507         if (ancestorInName) {
 
 1508           if (attributesCount == 1) {
 
 1513           ancestorInName = 
false;
 
 1514         } 
else if (firstPart) {
 
 1515           if (attributesCount == 1) {
 
 1528     if (!newName.isEmpty()) {
 
 1529       return URIWithoutName + newName;
 
 1531     return info.correctedUri; 
 
 1546           HashSet<String> intersectionOfSet, HashSet<String> oneOfSet) {
 
 1548       if (exp.getClassExpressionType().equals(ClassExpressionType.OBJECT_ONE_OF)) {
 
 1549         Set<OWLNamedIndividual> classSet = ((OWLObjectOneOf) exp).getIndividualsInSignature();
 
 1550         for (OWLNamedIndividual individual : classSet) {
 
 1551             oneOfSet.add(individual.toStringID());
 
 1554       else if (exp.getClassExpressionType().equals(ClassExpressionType.OBJECT_INTERSECTION_OF)) {
 
 1555         Set<OWLClass> classSet = ((OWLObjectIntersectionOf) exp).getClassesInSignature();
 
 1556         for (OWLClass cls : classSet) {
 
 1557             intersectionOfSet.add(cls.toStringID());
 
 1560     } 
catch (Exception e) {}
 
 1575           String commentStr1, String commentStr2, String commentStr3) {
 
 1576     if (setOfURI.size() > 1) {
 
 1578       comment += commentStr1;
 
 1579       boolean first = 
true;
 
 1580       for (String cls : setOfURI) {
 
 1584           comment += commentStr2;
 
 1588       comment += commentStr3;
 
 1589       type.setComment(comment);
 
 1603     HashSet<String> unionOfClasses = 
new HashSet<String>(); 
 
 1604     for (OWLAxiom axiom : ontClass.getReferencingAxioms(oModel)) {
 
 1605       if (axiom instanceof OWLEquivalentClassesAxiom) {
 
 1607           OWLEquivalentClassesAxiom equivalentAxiom = (OWLEquivalentClassesAxiom) axiom;
 
 1608           Set<OWLClassExpression> equivalentClasses = equivalentAxiom.getClassExpressions();
 
 1610           boolean classFound = 
false;
 
 1611           for (OWLClassExpression exp : equivalentClasses) {
 
 1612             if (exp.getClassExpressionType().equals(ClassExpressionType.OWL_CLASS)) {
 
 1613               if (exp.asOWLClass().toStringID().equals(ontClass.toStringID())) {
 
 1622           for (OWLClassExpression exp : equivalentClasses) {
 
 1625             if (classes.contains(ontClass.toStringID())) { 
 
 1626               classes.remove(ontClass.toStringID());
 
 1628             unionOfClasses.addAll(classes);
 
 1630             HashSet<String> intersectionOfSet = 
new HashSet<String>();
 
 1631             HashSet<String> oneOfSet = 
new HashSet<String>();
 
 1645         } 
catch (Exception e) {}
 
 1674           ArrayList<AnnotType> newTypes, Map<String, AnnotType> newTypesMap,
 
 1675           Map<String, AnnotTypeInfo> newTypesMapInfo, ArrayList<TypeAttrOnto> ontoAttrs,
 
 1678     HashMap<String, HashSet<String>> objectMap  = 
new HashMap<String, HashSet<String>>();
 
 1679     HashMap<String, HashSet<String>> subjectMap = 
new HashMap<String, HashSet<String>>();
 
 1680     HashMap<String, HashSet<String>> ancestorMap = 
new HashMap<String, HashSet<String>>();
 
 1683     for (OWLAnnotationProperty property : oModel.getAnnotationPropertiesInSignature()) {
 
 1684       String prUri = property.toStringID();  
 
 1685       if (prUri.contains(
"rdf-schema#")) { 
 
 1690       HashSet<String> objectSetClassURI = 
new HashSet<String>(); 
 
 1691       HashSet<String> subjectSetClassURI = 
new HashSet<String>(); 
 
 1692       HashSet<String> ancestorSetClassURI = 
new HashSet<String>();
 
 1693       Set<OWLAxiom> allAxioms = property.getReferencingAxioms(oModel);
 
 1694       int anotherAxioms = 
processRdfPropertyAxioms(objectSetClassURI, subjectSetClassURI, ancestorSetClassURI, allAxioms);
 
 1696       if (subjectSetClassURI.isEmpty() && objectSetClassURI.isEmpty() && anotherAxioms != 0) {
 
 1700       objectMap.put(prUri, objectSetClassURI);
 
 1701       subjectMap.put(prUri, subjectSetClassURI);
 
 1702       ancestorMap.put(prUri, ancestorSetClassURI);
 
 1709     HashSet<String> ObjectAndDataPropertiesMap = 
new HashSet<String>();
 
 1710     for (OWLObjectProperty property : oModel.getObjectPropertiesInSignature()) {
 
 1711         ObjectAndDataPropertiesMap.add(property.toStringID());
 
 1714     for (OWLObjectProperty property : oModel.getObjectPropertiesInSignature()) {
 
 1715       String prUri = property.toStringID();  
 
 1718       Set<OWLObjectPropertyExpression> superProperties = property.getSuperProperties(oModel);
 
 1721       Set<OWLClassExpression> objectSetExpression = property.getRanges(oModel);
 
 1722       Set<OWLClassExpression> subjectSetExpression = property.getDomains(oModel);
 
 1725       if (objectSetExpression.isEmpty() && subjectSetExpression.isEmpty() && prUri.indexOf(
"genid") != -1) { 
 
 1726         Set<OWLAxiom> axioms = property.getReferencingAxioms(oModel);
 
 1727         for (OWLAxiom axiom : axioms) {
 
 1728           String axiomName = axiom.getAxiomType().getName();
 
 1729           if (axiomName.equals(
"ObjectPropertyRange") &&
 
 1730               axiom instanceof OWLObjectPropertyRangeAxiom) {
 
 1731             OWLObjectPropertyRangeAxiom range = (OWLObjectPropertyRangeAxiom) axiom;
 
 1732             objectSetExpression.add(range.getRange());
 
 1734           if (axiomName.equals(
"ObjectPropertyDomain") &&
 
 1735               axiom instanceof OWLObjectPropertyDomainAxiom) {
 
 1736             OWLObjectPropertyDomainAxiom domain = (OWLObjectPropertyDomainAxiom) axiom;
 
 1737             subjectSetExpression.add(domain.getDomain());
 
 1739           if (axiomName.equals(
"SubObjectPropertyOf") &&
 
 1740               axiom instanceof OWLSubObjectPropertyOfAxiom) {
 
 1742               OWLSubObjectPropertyOfAxiom subProperty = (OWLSubObjectPropertyOfAxiom) axiom;
 
 1743               if (!subProperty.getSuperProperty().asOWLObjectProperty().toStringID().equals(prUri)) {
 
 1744                 superProperties.add(subProperty.getSuperProperty());
 
 1746             } 
catch (Exception e) {
 
 1753       Set<String> superPropertiesStringSet = 
new HashSet<String>();
 
 1756       Set<String> inversePropertiesID = 
new HashSet<String>();
 
 1758       processInverseProperty(oModel, property, objectSetExpression, subjectSetExpression, inversePropertiesID);
 
 1761       HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 1762       for (OWLClassExpression exp : objectSetExpression) {
 
 1765       HashSet<String> subjectSetClassURI = 
new HashSet<String>();
 
 1766       for (OWLClassExpression exp : subjectSetExpression) {
 
 1771       boolean addObjectFromAnnotationProperty = objectSetClassURI.isEmpty();
 
 1772       if (objectSetClassURI.size() == 1) {
 
 1773         Iterator<String> it = objectSetClassURI.iterator();
 
 1774         if (it.next().endsWith(
"rdf-schema#Literal")) {
 
 1775           addObjectFromAnnotationProperty = 
true;
 
 1778       boolean addSubjectFromAnnotationProperty = subjectSetClassURI.isEmpty();
 
 1779       if (subjectSetClassURI.size() == 1) {
 
 1780         Iterator<String> it = subjectSetClassURI.iterator();
 
 1781         if (it.next().endsWith(
"rdf-schema#Literal")) {
 
 1782           addSubjectFromAnnotationProperty = 
true;
 
 1785       if (addObjectFromAnnotationProperty) {
 
 1786         if (objectMap.containsKey(prUri)) {
 
 1787           objectSetClassURI.addAll(objectMap.get(prUri));
 
 1790       if (addSubjectFromAnnotationProperty) {
 
 1791         if (subjectMap.containsKey(prUri)) {
 
 1792           subjectSetClassURI.addAll(subjectMap.get(prUri));
 
 1795       if (superPropertiesStringSet.isEmpty()) {
 
 1796         if (ancestorMap.containsKey(prUri)) {
 
 1797           superPropertiesStringSet.addAll(ancestorMap.get(prUri));
 
 1801       String comment = 
getComments(oFactory, property.getAnnotations(oModel));
 
 1805       processProperties(prUri, propertyReference, comment, subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs, userGroup, superPropertiesStringSet, inversePropertiesID, oModel);
 
 1811     for (OWLDataProperty dataProperty : oModel.getDataPropertiesInSignature()) {
 
 1812         ObjectAndDataPropertiesMap.add(dataProperty.toStringID());
 
 1814     for (OWLDataProperty dataProperty : oModel.getDataPropertiesInSignature()) {
 
 1815       String prUri = dataProperty.toStringID();
 
 1816       Set<OWLDataRange> rangeSet = dataProperty.getRanges(oModel);
 
 1817       Set<OWLClassExpression> subjectSet = dataProperty.getDomains(oModel);
 
 1820       HashSet<String> subjectSetClassURI = 
new HashSet<String>();
 
 1821       for (OWLClassExpression exp : subjectSet) {
 
 1824       HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 1825       for (OWLDataRange range : rangeSet) {
 
 1826         if (range instanceof OWLDatatypeImpl) {
 
 1827           OWLDatatypeImpl concreteRange = (OWLDatatypeImpl) range;
 
 1828           objectSetClassURI.add(concreteRange.getIRI().toString());
 
 1832       Set<OWLDataPropertyExpression> superProperties = dataProperty.getSuperProperties(oModel);
 
 1835       Set<String> superPropertiesStringSet = 
new HashSet<String>();
 
 1839       boolean addObjectFromAnnotationProperty = objectSetClassURI.isEmpty();
 
 1840       if (objectSetClassURI.size() == 1) {
 
 1841         Iterator<String> it = objectSetClassURI.iterator();
 
 1842         if (it.next().endsWith(
"rdf-schema#Literal")) {
 
 1843           addObjectFromAnnotationProperty = 
true;
 
 1846       boolean addSubjectFromAnnotationProperty = subjectSetClassURI.isEmpty();
 
 1847       if (subjectSetClassURI.size() == 1) {
 
 1848         Iterator<String> it = subjectSetClassURI.iterator();
 
 1849         if (it.next().endsWith(
"rdf-schema#Literal")) {
 
 1850           addSubjectFromAnnotationProperty = 
true;
 
 1853       if (addObjectFromAnnotationProperty) {
 
 1854         if (objectMap.containsKey(prUri)) {
 
 1855           objectSetClassURI.addAll(objectMap.get(prUri));
 
 1858       if (addSubjectFromAnnotationProperty) {
 
 1859         if (subjectMap.containsKey(prUri)) {
 
 1860           subjectSetClassURI.addAll(subjectMap.get(prUri));
 
 1863       if (superPropertiesStringSet.isEmpty()) {
 
 1864         if (ancestorMap.containsKey(prUri)) {
 
 1865           superPropertiesStringSet.addAll(ancestorMap.get(prUri));
 
 1869       String comment = 
getComments(oFactory, dataProperty.getAnnotations(oModel));
 
 1873       processProperties(prUri, 
new PropertyReference(dataProperty), comment, subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs, userGroup, superPropertiesStringSet, 
new HashSet<String>(), oModel);
 
 1880     for (OWLAnnotationProperty property : oModel.getAnnotationPropertiesInSignature()) {
 
 1881       String prUri = property.toStringID();  
 
 1882       if (prUri.contains(
"rdf-schema#")) { 
 
 1888       HashSet<String> objectSetClassURI = 
new HashSet<String>(); 
 
 1889       HashSet<String> subjectSetClassURI = 
new HashSet<String>(); 
 
 1890       HashSet<String> ancestorSetClassURI = 
new HashSet<String>();
 
 1891       Set<OWLAxiom> allAxioms = property.getReferencingAxioms(oModel);
 
 1892       int anotherAxioms = 
processRdfPropertyAxioms(objectSetClassURI, subjectSetClassURI, ancestorSetClassURI, allAxioms);
 
 1895       if (ObjectAndDataPropertiesMap.contains(prUri)) { 
 
 1898       if (subjectSetClassURI.isEmpty() && objectSetClassURI.isEmpty() && anotherAxioms != 0) {
 
 1902       String comment = 
getComments(oFactory, property.getAnnotations(oModel));
 
 1906       processProperties(prUri, 
new PropertyReference(), comment, subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs, userGroup, ancestorSetClassURI, 
new HashSet<String>(), oModel);
 
 1912     Set<String> annotationPropertyURIs = 
new HashSet<String>();
 
 1913     Set<OWLAnnotationProperty> annotationProperty = oModel.getAnnotationPropertiesInSignature();
 
 1914     for (OWLAnnotationProperty anotProp : annotationProperty) {
 
 1915       String anotPropURI = anotProp.toStringID();
 
 1916       annotationPropertyURIs.add(anotPropURI);
 
 1950     for (OWLClass ontClass : oModel.getClassesInSignature()) { 
 
 1951       String uri = ontClass.toStringID();  
 
 1956       uri = info.correctedUri; 
 
 1960         errorMessage = MessageProvider.getMessage(
"unknownOntologyError");
 
 1965       for (OWLClassExpression clsExp : ontClass.getEquivalentClasses(oModel)) {
 
 1966         if (clsExp.toString().startsWith(
"ObjectComplementOf")) {
 
 1968             if (!clsExp.getComplementNNF().asOWLClass().isAnonymous()) {
 
 1970                       getNameFromURI(clsExp.getComplementNNF().asOWLClass().toStringID()) + 
 
 1973               type.setComment(comment + newComment);
 
 1975           } 
catch (Exception e) {
 
 1989         AnnotType anc = type.getAncestorTypes().
get(0);
 
 1990         type.setAncestorType(anc);
 
 1995       superClasses.addFirst(uri);
 
 1996       Set<OWLIndividual> classIndividuals = ontClass.getIndividuals(oModel);
 
 1997       for (OWLIndividual individual : classIndividuals) {
 
 1998         AnnotTypeInfo individualInfo = newTypesMapInfo.get(individual.toStringID());
 
 1999         if (individualInfo == null) { 
 
 2002         AnnotType individualType = newTypesMap.get(individualInfo.correctedUri); 
 
 2003         if (individualType == null) {
 
 2004           errorMessage = MessageProvider.getMessage(
"unknownOntologyError");
 
 2010           AnnotType anc = individualType.getAncestorTypes().
get(0);
 
 2011           individualType.setAncestorType(anc);
 
 2018       Set<OWLClassExpression> disjointClasses = ontClass.getDisjointClasses(oModel);
 
 2019       HashSet<String> disjointClassesURI = 
new HashSet<String>();
 
 2020       for (OWLClassExpression exp : disjointClasses) {
 
 2023       for (String disjointClass : disjointClassesURI) {
 
 2026         if (isAnonymous.
value) { 
 
 2032         type.setComment(comment + newComment);
 
 2033         if (info.wasAnonymous) {
 
 2034           info.disjointWithSet.add(disjointClass);
 
 2042       for (OWLAnnotation statement : ontClass.getAnnotations(oModel)) {
 
 2044         OWLAnnotationValue 
object = statement.getValue();
 
 2047         OWLAnnotationProperty 
property = statement.getProperty();
 
 2050         if (property.equals(oFactory.getRDFSIsDefinedBy())) {
 
 2057         if (
object instanceof OWLLiteral) {
 
 2058           OWLLiteral objLiteral = (OWLLiteral) 
object;
 
 2061           if (property.equals(oFactory.getRDFSComment())) {
 
 2062             objString = objLiteral.getLiteral();
 
 2064             type.setComment(comment + objString.trim());
 
 2069           if (property.equals(oFactory.getRDFSLabel())) {
 
 2070             objString = objLiteral.getLiteral();
 
 2072             type.setComment(comment + 
 
 2079           if (annotationPropertyURIs.contains(property.toStringID())) {
 
 2080               String objLitS = objLiteral.toString();
 
 2081               int index = objLitS.lastIndexOf(
":");
 
 2085                 if (!simpleType.isEmpty()) {
 
 2086                     String newPrUri = property.toStringID();
 
 2089                     attr.setUriInOntology(newPrUri);
 
 2091                     Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2092                     boolean aFound = 
false;
 
 2093                     while (atrIt.hasNext()) {  
 
 2095                       if (aTA.
getName().equals(prName)) {
 
 2100                       type.getAttributes().add(attr);
 
 2110         objUri = object.toString();
 
 2111         String prUri = property.toStringID();
 
 2113         if (prName.isEmpty()) {
 
 2118         if (prUri.indexOf(
"http://www.w3.org/2000/01/rdf-schema") == -1) {
 
 2119           AnnotType pType = newTypesMap.get(objUri);
 
 2120           if (pType == null && objUri.startsWith(
"\"") && objUri.endsWith(
"\"") && objUri.length() > 2) {
 
 2121               String nUri = objUri.substring(1, objUri.length() - 1);
 
 2122               pType = newTypesMap.get(nUri);
 
 2124           if (pType != null) {  
 
 2126             attr.setUriInOntology(prUri);
 
 2127             Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2128             boolean aFound = 
false;
 
 2129             while (atrIt.hasNext()) {  
 
 2131               if (aTA.
getName().equals(attr.getName())) {
 
 2137               type.getAttributes().add(attr);
 
 2144           if (prName.equalsIgnoreCase(
"seeAlso")) {
 
 2145             if (!objUri.isEmpty()) {
 
 2147               type.setComment(comment + 
 
 2160       OWLOntologyWalker walker = 
new OWLOntologyWalker(Collections.singleton(oModel));
 
 2163       OWLOntologyWalkerVisitor baseVisitor = (OWLOntologyWalkerVisitor) visitor;
 
 2164       walker.walkStructure(baseVisitor);
 
 2166       ArrayList<TypeAttrOnto> ontoAttrsDeleted = 
new ArrayList<TypeAttrOnto>();
 
 2170       Set<OWLVisitorForRestrictionData.CardinalityData> minCardinalityData = visitor.getMinCardinalityData();
 
 2172         if (data.cardinality == 0) { 
 
 2176         AnnotTypeInfo typeInfo = newTypesMapInfo.get(data.classURI);
 
 2177         if (typeInfo == null) {
 
 2180         AnnotType type = newTypesMap.get(typeInfo.correctedUri);
 
 2184           Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2185           while (atrIt.hasNext()) {  
 
 2194                   ontoAttrsDeleted, data,
 
 2195                   typeInfo.
originUri, newTypesMap, newTypesMapInfo, oModel, userGroup);
 
 2198           atrIt = type.getAttributes().iterator();
 
 2199           while (atrIt.hasNext()) {  
 
 2203               String comment = atr.getComment();
 
 2204               if (comment == null) {
 
 2207               if (!comment.isEmpty()) {
 
 2214                 atr.setRequired(
true);
 
 2220               atr.setComment(comment);
 
 2229       Set<OWLVisitorForRestrictionData.CardinalityData> maxCardinalityData = visitor.getMaxCardinalityData();
 
 2231         AnnotTypeInfo typeInfo = newTypesMapInfo.get(data.classURI);
 
 2232         if (typeInfo == null) {
 
 2235         AnnotType type = newTypesMap.get(typeInfo.correctedUri);
 
 2239           Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2240           while (atrIt.hasNext()) {  
 
 2249                   ontoAttrsDeleted, data,
 
 2250                   typeInfo.
originUri, newTypesMap, newTypesMapInfo, oModel, userGroup);
 
 2253           atrIt = type.getAttributes().iterator();
 
 2254           while (atrIt.hasNext()) {  
 
 2258               if (data.cardinality == 0) { 
 
 2262               String comment = atr.getComment();
 
 2273               atr.setComment(comment);
 
 2282       Set<OWLVisitorForRestrictionData.CardinalityData> exactCardinalityData = visitor.getCardinalityData();
 
 2284         AnnotTypeInfo typeInfo = newTypesMapInfo.get(data.classURI);
 
 2285         if (typeInfo == null) {
 
 2288         AnnotType type = newTypesMap.get(typeInfo.correctedUri);
 
 2292           Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2293           while (atrIt.hasNext()) {  
 
 2302                   ontoAttrsDeleted, data,
 
 2303                   typeInfo.
originUri, newTypesMap, newTypesMapInfo, oModel, userGroup);
 
 2306           atrIt = type.getAttributes().iterator();
 
 2307           while (atrIt.hasNext()) {  
 
 2311               if (data.cardinality == 0) { 
 
 2315               String comment = atr.getComment();
 
 2319                 atr.setRequired(
true);
 
 2327               atr.setComment(comment);
 
 2336       Set<OWLVisitorForRestrictionData.ValueData> someValuesFromData = visitor.getSomeValuesFromData();
 
 2338         AnnotTypeInfo typeInfo = newTypesMapInfo.get(data.classURI);
 
 2339         if (typeInfo == null) {
 
 2342         AnnotType type = newTypesMap.get(typeInfo.correctedUri);
 
 2346           boolean onePropertyFromManyFound = 
false; 
 
 2348           Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2349           while (atrIt.hasNext()) {  
 
 2354               String propertyObjectUri = atr.getAttributeType().getUriInOntology(); 
 
 2355               if (data.valueURI.equals(propertyObjectUri)) {
 
 2356                 onePropertyFromManyFound = 
true;
 
 2357                 foundedProperty = atr;
 
 2366               ArrayList<TypeAttrOnto> ontoAtrList = 
getOntoPropertyMayMove(data.propertyURI, ontoAttrs, ontoAttrsDeleted);
 
 2367               HashSet<String> subjectSetClassURI = 
new HashSet<String>();
 
 2368               subjectSetClassURI.add(typeInfo.originUri);
 
 2369               if (ontoAtrList != null) {
 
 2371                   HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 2372                   if (oAtr.getAttributeType() != null) {
 
 2373                     objectSetClassURI.add(oAtr.getAttributeType().getUriInOntology());
 
 2375                     objectSetClassURI.add(data.valueURI);
 
 2377                   String comment = oAtr.getComment();
 
 2379                     (comment == null ? 
"" : comment), subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs,
 
 2380                     userGroup, 
new HashSet<String>(), 
new HashSet<String>(), oModel);
 
 2383                 HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 2384                 objectSetClassURI.add(data.valueURI);
 
 2386                   "", subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs,
 
 2387                   userGroup, 
new HashSet<String>(), 
new HashSet<String>(), oModel);
 
 2393           atrIt = type.getAttributes().iterator();
 
 2394           while (atrIt.hasNext()) {  
 
 2398               String comment = atr.getComment();
 
 2404                 atr.setRequired(
true);
 
 2406                 if (!onePropertyFromManyFound) {
 
 2411                   if (atr == foundedProperty) {
 
 2415                     atr.setRequired(
true);
 
 2419               atr.setComment(comment);
 
 2428       Set<OWLVisitorForRestrictionData.ValueData> allValuesFromData = visitor.getAllValuesFromData();
 
 2430         AnnotTypeInfo typeInfo = newTypesMapInfo.get(data.classURI);
 
 2431         if (typeInfo == null) {
 
 2434         AnnotType type = newTypesMap.get(typeInfo.correctedUri);
 
 2437           boolean propertyFound = 
false;
 
 2439           Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2440           while (atrIt.hasNext()) {  
 
 2445               if (propertyFound) {
 
 2448                 propertyFound = 
true;
 
 2449                 annotTypeAttr = atr;
 
 2453           if (propertyFound) {
 
 2455             AnnotType attributeType = newTypesMap.get(data.valueURI);
 
 2456             if (attributeType == null) { 
 
 2460             annotTypeAttr.setUriInOntology(data.propertyURI);
 
 2462             annotTypeAttr.setAttributeType(attributeType);
 
 2463             annotTypeAttr.setSimpleType(null);
 
 2465               ArrayList<TypeAttrOnto> ontoAtrList = 
getOntoPropertyMayMove(data.propertyURI, ontoAttrs, ontoAttrsDeleted);
 
 2466               HashSet<String> subjectSetClassURI = 
new HashSet<String>();
 
 2467               subjectSetClassURI.add(typeInfo.originUri);
 
 2468               HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 2469               objectSetClassURI.add(data.valueURI);
 
 2470               String comment = (ontoAtrList.isEmpty() ? 
"" : ontoAtrList.iterator().next().getComment());
 
 2472                   comment, subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs,
 
 2473                   userGroup, 
new HashSet<String>(), 
new HashSet<String>(), oModel);
 
 2480       Set<OWLVisitorForRestrictionData.HasValueData> hasValueData = visitor.getHasValueData();
 
 2482         if (data.individual.isAnonymous()) { 
 
 2485         AnnotTypeInfo infoType = newTypesMapInfo.get(data.classURI);
 
 2486         if (infoType == null) {
 
 2492         AnnotTypeInfo typeInfo = newTypesMapInfo.get(data.classURI);
 
 2493         if (typeInfo == null) {
 
 2496         AnnotType type = newTypesMap.get(typeInfo.correctedUri);
 
 2499           boolean propertyFound = 
false;
 
 2501           Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2502           while (atrIt.hasNext()) {  
 
 2507               if (propertyFound) {
 
 2510                 propertyFound = 
true;
 
 2511                 annotTypeAttr = atr;
 
 2516           AnnotType objectType = newTypesMap.get(data.valueURI);
 
 2518           boolean selectedObjectFound = 
false;
 
 2519           if (objectType != null) {
 
 2520             AnnotTypeInfo objectInfo = newTypesMapInfo.get(data.valueURI);
 
 2521             if (objectInfo == null) { 
 
 2522               errorMessage += MessageProvider.getMessage(
"unknownOntologyError") + 
"<br/>";
 
 2525             selectedObjectFound = 
true;
 
 2527           if (!selectedObjectFound) { 
 
 2530                   newTypesMap, newTypesMapInfo, userGroup, data.individual, type.
getName(), 0);
 
 2532             AnnotType individualType = newTypesMap.get(data.valueURI); 
 
 2533             if (individualType == null) {
 
 2534               errorMessage = MessageProvider.getMessage(
"unknownOntologyError");
 
 2538             superClasses.addFirst(infoType.correctedUri);
 
 2542               AnnotType anc = individualType.getAncestorTypes().
get(0);
 
 2543               individualType.setAncestorType(anc);
 
 2545             objectType = individualType;
 
 2548           if (propertyFound) {
 
 2550             annotTypeAttr.setUriInOntology(data.propertyURI);
 
 2552             annotTypeAttr.setAttributeType(objectType);
 
 2553             annotTypeAttr.setSimpleType(null);
 
 2555               ArrayList<TypeAttrOnto> ontoAtrList = 
getOntoPropertyMayMove(data.propertyURI, ontoAttrs, ontoAttrsDeleted);
 
 2556               HashSet<String> subjectSetClassURI = 
new HashSet<String>();
 
 2557               subjectSetClassURI.add(typeInfo.originUri);
 
 2558               HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 2559               objectSetClassURI.add(data.valueURI);
 
 2560               String comment = (ontoAtrList.isEmpty() ? 
"" : ontoAtrList.iterator().next().getComment());
 
 2562                   comment, subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs,
 
 2563                   userGroup, 
new HashSet<String>(), 
new HashSet<String>(), oModel);
 
 2570       Set<OWLVisitorForRestrictionData.ValueData> hasSelfData = visitor.getHasSelfData();
 
 2572         AnnotTypeInfo infoType = newTypesMapInfo.get(data.classURI);
 
 2573         if (infoType == null) {
 
 2579         AnnotTypeInfo typeInfo = newTypesMapInfo.get(data.classURI);
 
 2580         if (typeInfo == null) {
 
 2583         AnnotType type = newTypesMap.get(typeInfo.correctedUri);
 
 2586           boolean propertyFound = 
false;
 
 2588           Iterator<AnnotTypeAttr> atrIt = type.getAttributes().iterator();
 
 2589           while (atrIt.hasNext()) {  
 
 2595               if (propertyFound) {
 
 2598                 propertyFound = 
true;
 
 2599                 annotTypeAttr = atr;
 
 2603           if (propertyFound) {
 
 2606             annotTypeAttr.setAttributeType(type);
 
 2607             annotTypeAttr.setSimpleType(null);
 
 2608             String comment = annotTypeAttr.getComment();
 
 2611             annotTypeAttr.setComment(comment);
 
 2613               ArrayList<TypeAttrOnto> ontoAtrList = 
getOntoPropertyMayMove(data.propertyURI, ontoAttrs, ontoAttrsDeleted);
 
 2614               HashSet<String> subjectSetClassURI = 
new HashSet<String>();
 
 2615               subjectSetClassURI.add(typeInfo.originUri);
 
 2616               HashSet<String> objectSetClassURI = 
new HashSet<String>();
 
 2617               objectSetClassURI.add(typeInfo.originUri);
 
 2618               String comment = (ontoAtrList.isEmpty() ? 
"" : ontoAtrList.iterator().next().getComment());
 
 2622                   comment, subjectSetClassURI, objectSetClassURI, newTypesMap, newTypesMapInfo, ontoAttrs,
 
 2623                   userGroup, 
new HashSet<String>(), 
new HashSet<String>(), oModel);
 
 2628     } 
catch (Exception e) {  }
 
 2634     for (OWLClass ontClass : oModel.getClassesInSignature()) { 
 
 2635       String uri = ontClass.toStringID();  
 
 2640       if (!info.wasAnonymous) {
 
 2643       uri = info.correctedUri; 
 
 2647         errorMessage = MessageProvider.getMessage(
"unknownOntologyError");
 
 2652       type.setUriInOntology(newURI);
 
 2653       type.setName(newName);
 
 2654       newTypesMap.remove(uri);
 
 2655       newTypesMap.put(newURI, type);
 
 2682       errorMessage = MessageProvider.getMessage(
"groupMustBeSet");
 
 2686     Object[] params = 
new Object[2];  
 
 2689     List gList = AppBean.getPersistenceManager().queryDB(
"UserGroup.findByName", params);
 
 2691     if (gList != null && !gList.isEmpty()) {  
 
 2694       errorMessage = MessageProvider.getMessage(
"unknownGroup");
 
 2704       errorMessage = MessageProvider.getMessage(
"uploadingError");
 
 2709     StringWriter fWriter = 
new StringWriter();
 
 2711       IOUtils.copy(uploadedFile.getInputStream(), fWriter);
 
 2712     } 
catch (IOException ex) {
 
 2713       errorMessage = MessageProvider.getMessage(
"uploadingError");
 
 2718     InputStream is = null;
 
 2720       is = 
new ByteArrayInputStream(fWriter.toString().getBytes(
"UTF-8")); 
 
 2721     } 
catch (UnsupportedEncodingException ex) {
 
 2722       errorMessage = MessageProvider.getMessage(
"uploadingError");
 
 2727     OWLOntologyManager oManager = OWLManager.createOWLOntologyManager();
 
 2728     OWLDataFactory oFactory = OWLManager.getOWLDataFactory();
 
 2731         oModel = oManager.loadOntologyFromOntologyDocument(is);
 
 2732     } 
catch (OWLOntologyCreationException ex) {
 
 2747     ArrayList<AnnotType> newTypes = 
new ArrayList<AnnotType>();
 
 2750     Map<String, AnnotType> newTypesMap = 
new HashMap<String, AnnotType>();
 
 2753     ArrayList<TypeAttrOnto> ontoAttrs = 
new ArrayList<TypeAttrOnto>();
 
 2756     Map<String, AnnotTypeInfo> newTypesMapInfo = 
new HashMap<String, AnnotTypeInfo>();
 
 2759     if (
processModelPhase1(oModel, oFactory, newTypes, newTypesMap, userGroup, newTypesMapInfo)) {
 
 2765     if (
processModelPhase2(oModel, oFactory, newTypes, newTypesMap, newTypesMapInfo, ontoAttrs, userGroup)) {
 
 2770     for (Iterator<AnnotType> ntIt = newTypes.iterator(); ntIt.hasNext();) {
 
 2772       String uri = type.getGeneratedURI();
 
 2777     List<AnnotType> tToUpdate = 
new ArrayList<AnnotType>();  
 
 2780     boolean duplicitTypeFound = 
false;
 
 2781     for (Iterator<AnnotType> ntIt = newTypes.iterator(); ntIt.hasNext();) {
 
 2784       params[1] = type.getUri();
 
 2785       List tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByUri", params);
 
 2786       if (tList != null && !tList.isEmpty()) {  
 
 2790                        + type.
getUri() + MessageProvider.getMessage(
"typeAlreadyExists2") + 
"<br/>";
 
 2792           for (Iterator<AnnotType> ntIt2 = newTypes.iterator(); ntIt2.hasNext();) {  
 
 2794             if (t2.
getAncestorType() != null && t2.getAncestorType().getUri().equals(type.getUri())) {
 
 2795               t2.setAncestorType(typeInDB);  
 
 2797             List<AnnotType> nAnc = 
new ArrayList<AnnotType>();  
 
 2798             for (Iterator t2AIt = t2.
getAncestorTypes().iterator(); t2AIt.hasNext();) {
 
 2800               if (t2A.
getUri() != null && t2A.getUri().equals(type.
getUri())) {
 
 2806             t2.setAncestorTypes(nAnc);  
 
 2807             for (Iterator t2AtIt = t2.
getAttributes().iterator(); t2AtIt.hasNext();) {
 
 2809               if (t2At.
getAttributeType() != null && t2At.getAttributeType().getUri().equals(type.getUri())) {
 
 2810                 t2At.setAttributeType(typeInDB);
 
 2817           typeInDB.setAncestorType(type.getAncestorType());
 
 2818           typeInDB.setAncestorTypes(type.getAncestorTypes());
 
 2819           typeInDB.setAttributes(
new ArrayList<AnnotTypeAttr>(type.getAttributes()));
 
 2820           typeInDB.setComment(type.getComment());
 
 2821           typeInDB.setRestrictedAtt(type.getRestrictedAtt());
 
 2822           typeInDB.setUriInOntology(type.getUriInOntology());
 
 2824           for (Iterator<AnnotType> ntIt2 = newTypes.iterator(); ntIt2.hasNext();) {  
 
 2826             if (t2.
getAncestorType() != null && t2.getAncestorType().getUri().equals(type.getUri())) {
 
 2827               t2.setAncestorType(typeInDB);  
 
 2829             List<AnnotType> nAnc = 
new ArrayList<AnnotType>();  
 
 2830             for (Iterator t2AIt = t2.
getAncestorTypes().iterator(); t2AIt.hasNext();) {
 
 2832               if (t2A.
getUri() != null && t2A.getUri().equals(type.
getUri())) {
 
 2838             t2.setAncestorTypes(nAnc);  
 
 2839             for (Iterator t2AtIt = t2.
getAttributes().iterator(); t2AtIt.hasNext();) {
 
 2841               if (t2At.
getAttributeType() != null && t2At.getAttributeType().getUri().equals(type.getUri())) {
 
 2842                 t2At.setAttributeType(typeInDB);
 
 2847           tToUpdate.add(typeInDB);
 
 2851                        + type.
getUri() + MessageProvider.getMessage(
"typeAlreadyExists2") + 
"<br/>";
 
 2854         duplicitTypeFound = 
true;
 
 2858     if (duplicitTypeFound) {  
 
 2865     List<TypeAttrOnto> aToUpdate = 
new ArrayList<TypeAttrOnto>();
 
 2868     boolean duplicitAttributeFound = 
false;
 
 2869     for (Iterator<TypeAttrOnto> aFOIt = ontoAttrs.iterator(); aFOIt.hasNext();) {
 
 2871       Object[] params2 = 
new Object[4];  
 
 2872       params2[0] = 
"name";
 
 2873       params2[1] = aFO.getName();
 
 2874       params2[2] = 
"groupId";
 
 2875       params2[3] = aFO.getGroup().getId();
 
 2876       List aList = AppBean.getPersistenceManager().queryDB(
"TypeAttrOnto.findByNameAndGroup", params2);
 
 2877       if (aList != null && !aList.isEmpty()) {  
 
 2881                        + aFO.
getName() + MessageProvider.getMessage(
"attributeAlreadyExists2") + 
"<br/>";
 
 2886           attrInDB.setSimpleType(aFO.getSimpleType());
 
 2887           attrInDB.setAttributeType(aFO.getAttributeType());
 
 2888           attrInDB.setComment(aFO.getComment());
 
 2889           attrInDB.setUriInOntology(aFO.getUriInOntology());
 
 2891           aToUpdate.add(attrInDB);  
 
 2894         duplicitTypeFound = 
true;
 
 2898     if (duplicitAttributeFound) {  
 
 2906     EntityManager em = AppBean.getPersistenceManager().getEM();
 
 2907     EntityTransaction transaction = em.getTransaction();
 
 2908     boolean errorOccurred = 
false;
 
 2910       transaction.begin();
 
 2913       ArrayList<AnnotType> nTWA = 
new ArrayList<AnnotType>();
 
 2914       Map<String, AnnotType> nTMap = 
new HashMap<String, AnnotType>();
 
 2915       for (Iterator<AnnotType> ntIt = newTypes.iterator(); ntIt.hasNext();) {
 
 2918         nT.setAncestorTypes(type.getAncestorTypes());
 
 2919         nT.setAttributes(
new ArrayList<AnnotTypeAttr>(type.getAttributes()));
 
 2920         nT.setRestrictedAtt(type.getRestrictedAtt());
 
 2921         nT.setUriInOntology(type.getUriInOntology());
 
 2922         nT.setComment(type.getComment());
 
 2923         type.setAncestorType(null);
 
 2924         type.setAncestorTypes(
new ArrayList<AnnotType>());
 
 2925         type.setAttributes(
new ArrayList<AnnotTypeAttr>());
 
 2927         nTMap.put(type.getUri(), nT);
 
 2931       ArrayList<AnnotType> mergedTypes = 
new ArrayList<AnnotType>();
 
 2932       Map<String, AnnotType> mTypesMap = 
new HashMap<String, AnnotType>();
 
 2933       for (Iterator<AnnotType> nTWAIt = nTWA.iterator(); nTWAIt.hasNext();) {
 
 2935         type = em.merge(type);
 
 2936         mergedTypes.add(type);
 
 2937         mTypesMap.put(type.getUri(), type);
 
 2941       for (Iterator<AnnotType> mIt = mergedTypes.iterator(); mIt.hasNext();) {
 
 2943         AnnotType oType = nTMap.get(mType.getUri());  
 
 2946         List<AnnotTypeAttr> aList = oType.getAttributes();
 
 2947         for (Iterator<AnnotTypeAttr> aIt = aList.iterator(); aIt.hasNext();) {
 
 2949           AnnotType aTAAT = aTA.getAttributeType();
 
 2950           if (aTAAT != null) {  
 
 2952             AnnotType rType = mTypesMap.get(aTAAT.getUri());
 
 2953             if (rType == null) {  
 
 2956             aTA.setAttributeType(rType);
 
 2959           aTA.setAnnotationType(mTypesMap.get(aTA.getAnnotationType().getUri()));
 
 2961         mType.setAttributes(
new ArrayList<AnnotTypeAttr>(aList));
 
 2964         if (oType.getAncestorType() != null) {
 
 2966           AnnotType rType = mTypesMap.get(oType.getAncestorType().getUri());
 
 2967           if (rType == null) {  
 
 2968             rType = 
queryType(oType.getAncestorType().getUri(), em);
 
 2970           mType.setAncestorType(rType);
 
 2974         ArrayList<AnnotType> newAncestors = 
new ArrayList<AnnotType>();
 
 2975         for (Iterator<AnnotType> ancIt = oType.getAncestorTypes().iterator(); ancIt.hasNext();) {
 
 2977           AnnotType mAnc = mTypesMap.get(ancType.getUri());
 
 2981           if(!newAncestors.contains(mAnc)){
 
 2982             newAncestors.add(mAnc);
 
 2985         mType.setAncestorTypes(newAncestors);
 
 2987         mType = em.merge(mType);
 
 2991       for (Iterator<AnnotType> tTUIt = tToUpdate.iterator(); tTUIt.hasNext();) {
 
 2995         pType.setComment(type.getComment());
 
 2996         pType.setRestrictedAtt(type.getRestrictedAtt());
 
 2997         pType.setUriInOntology(type.getUriInOntology());
 
 2999         Iterator<AnnotTypeAttr> attrIter = pType.getAttributes().iterator();
 
 3000         Iterator<AnnotTypeAttr> newAttrIter = type.getAttributes().iterator();
 
 3001         while (attrIter.hasNext()) {  
 
 3003           if (!newAttrIter.hasNext()) {
 
 3007             attr.setSimpleType(newAttr.getSimpleType());
 
 3011               attr.setAttributeType(null);
 
 3013             attr.setName(newAttr.getName());
 
 3014             attr.setComment(newAttr.getComment());
 
 3015             attr.setRequired(newAttr.getRequired());
 
 3016             attr.setUriInOntology(newAttr.getUriInOntology());
 
 3020         while (newAttrIter.hasNext()) {
 
 3025           nA.setAnnotationType(pType);
 
 3026           pType.getAttributes().add(nA);
 
 3030         List<AnnotType> newAnc = 
new ArrayList<AnnotType>();
 
 3031         for (Iterator<AnnotType> aIt = type.
getAncestorTypes().iterator(); aIt.hasNext();) {
 
 3035         pType.setAncestorTypes(newAnc);
 
 3041           pType.setAncestorType(null);
 
 3046       for (Iterator<TypeAttrOnto> oAIt = ontoAttrs.iterator(); oAIt.hasNext();) {
 
 3050           AnnotType aT = mTypesMap.get(attr.getAttributeType().getUri());
 
 3051           attr.setAttributeType(aT);
 
 3058       for (Iterator<TypeAttrOnto> aFOIt = aToUpdate.iterator(); aFOIt.hasNext();) {
 
 3067       transaction.commit();
 
 3068     } 
catch (Exception e) {
 
 3069       transaction.rollback();
 
 3070       errorMessage = errorMessage + MessageProvider.getMessage(
"typePersistingError") + 
"<br/>";
 
 3078     synchronized(AppBean.getSessions()){
 
 3079       Iterator<EditorSession> sesIt = AppBean.getSessions().iterator();
 
 3080       while (sesIt.hasNext()) {  
 
 3084         for (Iterator<AnnotType> atIt = newTypes.iterator(); atIt.hasNext();) {
 
 3086           flier.AddAddedType(at);
 
 3089         for (Iterator<AnnotType> atIt = tToUpdate.iterator(); atIt.hasNext();) {
 
 3091           flier.AddEditedType(at);
 
 3093         es.addMessageTS(rc.createCometResponse(flier, es));  
 
 3098     successMessage = MessageProvider.getMessage(
"uploadSuccessfull");
 
 3116     Object[] params = 
new Object[2];
 
 3119     Query q = em.createNamedQuery(
"AnnotType.findByUri");
 
 3120     for (
int p = 0; p < params.length; p = p + 2) {
 
 3121       q.setParameter((String) params[p], params[p + 1]);
 
 3123     List aList = q.getResultList();
 
 3124     if (aList != null && !aList.isEmpty()) {  
 
 3127       throw new RuntimeException(
"New type not found!");
 
 3277     this.importLang = iLanguage;
 
List< AnnotTypeAttr > getAttributes()
static final int ASSYMETRIC_PROPERTY_MORE_OBJECT_COMMENT_2
static final int SYMETRIC_PROPERTY_MORE_OBJECT_COMMENT_1
PropertyReference(OWLObjectProperty objectProperty)
AnnotTypeInfo(String originUri, String correctedUri, OWLClass owlClass, boolean wasObject, boolean wasAnonymous)
static final int INVERSE_FUNCTIONAL_PROPERTY_MORE_OBJECT_COMMENT_1
Class representing attribute of unknown type of annotation. 
static final ArrayList< String > LANGUAGE_CODES
OWLObjectProperty objectProperty
Class with constants for ontology import. 
static final int TRANSITIVE_PROPERTY_MORE_OBJECT_COMMENT_1
void addInfoAboutCollectionToComment(AnnotType type, HashSet< String > setOfURI, String commentStr1, String commentStr2, String commentStr3)
static final int MAX_CARDINALITY_MORE_OBJECT_COMMENT_2
void setImportLang(String iLanguage)
String addSuperPropertiesToComment(String propertyURI, String comment, Set< String > superClasses)
static final boolean RESTRICT_TYPES_IMPORTED_FROM_ONTO
static final int INTERSECTION_OF_COMMENT_3
static final int FUNCTIONAL_PROPERTY_ONE_OBJECT_COMMENT
static final int ATTRIBUTE_WITH_ANONYMOUS_NAME_FIRST_AFTER
void getInverseEquivalentPropertyUri(Set< String > processedProperty, OWLObjectProperty property, OWLObjectPropertyExpression expression, OWLOntology oModel, Set< OWLObjectPropertyExpression > inversePropertyURI, Set< OWLObjectPropertyExpression > equivalentPropertyURI)
AnnotTypeInfo(String originUri, OWLClass owlClass)
int addPropertyInAnonymousClassFromCardinalityRestriction(ArrayList< TypeAttrOnto > ontoAttrs, ArrayList< TypeAttrOnto > ontoAttrsDeleted, OWLVisitorForRestrictionData.CardinalityData data, String typeURI, Map< String, AnnotType > newTypesMap, Map< String, AnnotTypeInfo > newTypesMapInfo, OWLOntology oModel, UserGroup userGroup)
static final int SOME_VALUES_FROM_MORE_OBJECT_COMMENT_1
Class representing attribute of type of annotation. 
void processUnionOfOneOfIntersectionOf(OWLClass ontClass, AnnotType type, OWLOntology oModel)
static final int MIN_CARDINALITY_MORE_OBJECT_COMMENT_1
String deleteNameInURIIfAnonymousProperty(String originURI, BooleanHolder isAnonymous)
void setuGroup(String uGroup)
static final int INTERSECTION_OF_COMMENT_2
static final int DISJOINT_WITH_COMMENT_2
static final int TRANSITIVE_PROPERTY_MORE_OBJECT_COMMENT_2
static final int DISJOINT_WITH_ANONYMOUS_NAME
static final int ATTRIBUTES_WITH_ANONYMOUS_NAME
static final int COMPLEMENT_OF_COMMENT_1
PropertyReference(OWLDataProperty dataProperty)
static final int UNION_OF_COMMENT_2
AnnotType getAncestorType()
static final int DISJOINT_WITH_ANONYMOUS_NAME_FIRST
void setUploadedFile(UploadedFile uploadedFile)
Singleton for storing global variables. 
static final int REFLEXIVE_PROPERTY_MORE_OBJECT_COMMENT_2
static final int MAX_CARDINALITY_ONE_OBJECT_COMMENT_2
Class for getting localized messages from message bundle. 
static final int IRREFLEXIVE_PROPERTY_MORE_OBJECT_COMMENT_2
boolean processModelPhase1(OWLOntology oModel, OWLDataFactory oFactory, ArrayList< AnnotType > newTypes, Map< String, AnnotType > newTypesMap, UserGroup userGroup, Map< String, AnnotTypeInfo > newTypesMapInfo)
void addSuperObjectPropertiesToSet(String propertyURI, Set< OWLObjectPropertyExpression > superProperties, Set< String > superClasses)
static final int EXACT_CARDINALITY_MORE_OBJECT_COMMENT_1
static final int SEE_ALSO_COMMENT
UploadedFile uploadedFile
AnnotType getAttributeType()
static final int ATTRIBUTE_WITH_ANONYMOUS_NAME_FIRST
String getNewNameForAnonymousClass(AnnotTypeInfo info, AnnotType type)
static final int METHOD_0_ERROR
static final int METHOD_2_UPDATE
String renameIfAnonymous(String uri)
static final int MAX_CARDINALITY_MORE_OBJECT_COMMENT_3
static final int MAX_CARDINALITY_ONE_OBJECT_COMMENT_1
String getStringTypeFromOntologyURI(String stringURI, boolean generateError, BooleanHolder isRequired)
static AnnotType queryType(String uri, EntityManager em)
void setOntologyUploaded(Boolean ontologyUploaded)
static final int SOME_VALUES_FROM_MORE_OBJECT_COMMENT_3
Class with reference to OWLObjectProperty or OWLDataProperty. 
void setErrorMessage(String errorMessage)
static final int INVERSE_FUNCTIONAL_PROPERTY_MORE_OBJECT_COMMENT_2
static final int UNION_OF_COMMENT_3
static final int LABEL_COMMENT_2
static final int INTERSECTION_OF_COMMENT_1
static final int FUNCTIONAL_PROPERTY_MORE_OBJECT_COMMENT_1
Set< String > disjointWithSet
Class representing user group. 
static final int METHOD_1_USE
boolean processModelPhase2(OWLOntology oModel, OWLDataFactory oFactory, ArrayList< AnnotType > newTypes, Map< String, AnnotType > newTypesMap, Map< String, AnnotTypeInfo > newTypesMapInfo, ArrayList< TypeAttrOnto > ontoAttrs, UserGroup userGroup)
static String getOWLString(int langNum, int stringNum)
static final int ASSYMETRIC_PROPERTY_ONE_OBJECT_COMMENT
static final int FUNCTIONAL_PROPERTY_MORE_OBJECT_COMMENT_2
static final int IRREFLEXIVE_PROPERTY_MORE_OBJECT_COMMENT_1
static final int COMPLEMENT_OF_COMMENT_2
static final int EXACT_CARDINALITY_ONE_OBJECT_COMMENT_2
static final int ASSYMETRIC_PROPERTY_MORE_OBJECT_COMMENT_1
void processInverseProperty(OWLOntology oModel, OWLObjectProperty property, Set< OWLClassExpression > objectSetExpression, Set< OWLClassExpression > subjectSetExpression, Set< String > inversePropertiesStringSet)
String getComments(OWLDataFactory oFactory, Set< OWLAnnotation > annotationSet)
static String getMessage(String name)
void processPropertyWS(String prUri, String prName, String comment, HashSet< String > objectSetClassURI, UserGroup userGroup, ArrayList< TypeAttrOnto > ontoAttrs, Map< String, AnnotType > newTypesMap, boolean isAnonymous)
static final int LANGUAGE_CZE
static final int SUB_PROPERTY_COMMENT_2
String getUriInOntology()
static final int EXACT_CARDINALITY_ONE_OBJECT_COMMENT_1
HashSet< String > processOWLClassExpression(OWLOntology oModel, OWLClassExpression exp)
String editCommentBaseOnType(String originalComment, boolean action, int objectCount, String propertyName, String oneComment, String moreComment1, String moreComment2)
int createAnnotTypeFromIndividual(OWLOntology oModel, OWLDataFactory oFactory, ArrayList< AnnotType > newTypes, Map< String, AnnotType > newTypesMap, Map< String, AnnotTypeInfo > newTypesMapInfo, UserGroup userGroup, OWLIndividual individual, String name, int anonymousIndividualCount)
Boolean getOntologyUploaded()
Class representing type of annotation. 
void addSuperDataPropertiesToSet(String propertyURI, Set< OWLDataPropertyExpression > superProperties, Set< String > superClasses)
void setiMethod(int iMethod)
String renameIfAnonymous(String uri, BooleanHolder isAnnonymous)
void processOWLClassExpressionIntersectionOfOneOf(OWLClassExpression exp, HashSet< String > intersectionOfSet, HashSet< String > oneOfSet)
ArrayList< TypeAttrOnto > getOntoPropertyMayMove(String propertyURI, ArrayList< TypeAttrOnto > ontoAttrs, ArrayList< TypeAttrOnto > ontoAttrsDeleted)
static final int SOME_VALUES_FROM_ONE_OBJECT_COMMENT_1
Flier with informations for comet handlers. 
UploadedFile getUploadedFile()
Class for boolean reference pass. 
static final int INVERSE_FUNCTIONAL_PROPERTY_ONE_OBJECT_COMMENT
static final int IRREFLEXIVE_PROPERTY_ONE_OBJECT_COMMENT
static final int DISJOINT_WITH_COMMENT_1
static final int SUB_PROPERTY_COMMENT_1
static boolean tryParseInt(String value)
int processRdfPropertyAxioms(HashSet< String > objectSetClassURI, HashSet< String > subjectSetClassURI, HashSet< String > ancestorSetClassURI, Set< OWLAxiom > allAxioms)
String deleteNameInURI(String originURI)
static final int HAS_SELF_COMMENT
void processProperties(String prUri, PropertyReference propertyReference, String comment, HashSet< String > subjectSetClassURI, HashSet< String > objectSetClassURI, Map< String, AnnotType > newTypesMap, Map< String, AnnotTypeInfo > newTypesMapInfo, ArrayList< TypeAttrOnto > ontoAttrs, UserGroup userGroup, Set< String > superPropertiesStringSet, Set< String > inversePropertiesID, OWLOntology oModel)
String upperFirstChar(String str)
static final int UNION_OF_COMMENT_1
void addSuperClassesToAnnotType(ArrayList< AnnotType > newTypes, Map< String, AnnotType > newTypesMap, UserGroup userGroup, AnnotType type, List< String > superClasses)
String procesSpecialPropertyType(String comment, PropertyReference propertyReference, int objectCount, String newPropertyName, OWLOntology oModel)
void noRangePropertyProcess(AnnotType type, String prName, String prUri, String comment)
static final int MIN_CARDINALITY_ONE_OBJECT_COMMENT_1
String getUriInOntology()
Class that creates responses and persists data. 
Class for additional information about AnnotType. 
static final int EXACT_CARDINALITY_MORE_OBJECT_COMMENT_2
static final int LABEL_COMMENT_1
Backbean for for page for uploading ontology. 
static final int EXACT_CARDINALITY_MORE_OBJECT_COMMENT_3
static final int MIN_CARDINALITY_ONE_OBJECT_COMMENT_2
LinkedList< String > processSuperClass(OWLOntology oModel, OWLClass ontClass)
static final int MAX_CARDINALITY_MORE_OBJECT_COMMENT_1
static final int ATTRIBUTES_WITH_ANONYMOUS_NAME_FIRST
OWLObjectProperty getObjectProperty()
static final int MIN_CARDINALITY_MORE_OBJECT_COMMENT_2
static final int TRANSITIVE_PROPERTY_ONE_OBJECT_COMMENT
void setSuccessMessage(String successMessage)
AnnotTypeInfo(String originUri, String correctedUri, OWLClass owlClass)
static final int MIN_CARDINALITY_MORE_OBJECT_COMMENT_3
OWLDataProperty dataProperty
Class responsible for localised strings. 
Informations about client session. 
static final int SYMETRIC_PROPERTY_ONE_OBJECT_COMMENT
AnnotType getAttributeType()
static final int ATTRIBUTES_WITH_ANONYMOUS_NAME_FIRST_AFTER
static final int REFLEXIVE_PROPERTY_MORE_OBJECT_COMMENT_1
static final int SOME_VALUES_FROM_ONE_OBJECT_COMMENT_2
static final int SOME_VALUES_FROM_MORE_OBJECT_COMMENT_2
OWLDataProperty getDataProperty()
List< AnnotType > getAncestorTypes()
Class collect information about restrictions. 
static final int SYMETRIC_PROPERTY_MORE_OBJECT_COMMENT_2
static String getNameFromURI(String uri)
String getSuccessMessage()
static final int REFLEXIVE_PROPERTY_ONE_OBJECT_COMMENT
int recursiveInverseCount
String prepareCommentToAdding(String comment)