ontologychangerenderer.java

来自「Semantic Web Ontology Editor」· Java 代码 · 共 1,066 行 · 第 1/3 页

JAVA
1,066
字号
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveEquivalentClass")) {
						try {
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							RemoveEquivalentClass change = new RemoveEquivalentClass(changeOnt, cla, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddSuperClass")) {
						try { 
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							AddSuperClass change = new AddSuperClass(changeOnt, cla, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveSuperClass")) {
						try {
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							if (desc!=null) {
								RemoveSuperClass change = new RemoveSuperClass(changeOnt, cla, desc, null);						
								changes.add(change);						
								// also add RemoveClassAxiom change
								OWLSubClassAxiom subClaAxiom = df.getOWLSubClassAxiom(cla, desc);
								RemoveClassAxiom change2 = new RemoveClassAxiom(changeOnt, subClaAxiom, null);
								changes.add(change2);
							}
							else System.out.println("Unable to create change");
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddSubClassAxiom")) {
						try { 
							OWLDescription sub = this.getOWLObjectNode(annotOnt, arguments[1], changeOnt);
							OWLDescription sup = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							OWLSubClassAxiom subAxiom = df.getOWLSubClassAxiom(sub, sup);
							AddClassAxiom change = new AddClassAxiom(changeOnt, subAxiom, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveSubClassAxiom")) {
						try {
							OWLDescription sub = this.getOWLObjectNode(annotOnt, arguments[1], changeOnt);
							OWLDescription sup = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							if (sub!=null && sup!=null) {
//								RemoveSuperClass change = new RemoveSuperClass(changeOnt, cla, desc, null);						
//								changes.add(change);						
								// also add RemoveClassAxiom change
								OWLSubClassAxiom subClaAxiom = df.getOWLSubClassAxiom(sub, sup);
								RemoveClassAxiom change2 = new RemoveClassAxiom(changeOnt, subClaAxiom, null);
								changes.add(change2);
							}
							else System.out.println("Unable to create change");
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddDisjointClasses")) {
						try {
							Set disjClasses = new HashSet();
							int i = 1;
							while (arguments[i]!=null) {
								disjClasses.add(this.getOWLObjectNode(annotOnt, arguments[i], changeOnt));
								i++;
							}
							OWLDisjointClassesAxiom disAxiom = df.getOWLDisjointClassesAxiom(disjClasses);
							AddClassAxiom change = new AddClassAxiom(changeOnt, disAxiom, null); 
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveDisjointClasses")) {
						try {
							Set disjClasses = new HashSet();
							int i = 1;
							while (arguments[i]!=null) {
								disjClasses.add(this.getOWLObjectNode(annotOnt, arguments[i], changeOnt));
								i++;
							}
							OWLDisjointClassesAxiom disAxiom = df.getOWLDisjointClassesAxiom(disjClasses);
							RemoveClassAxiom change = new RemoveClassAxiom(changeOnt, disAxiom, null); 
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddIntersectionElement")) {
						try {
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							BooleanElementChange change = new BooleanElementChange(OWLAnd.class, "Add", changeOnt, cla, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveIntersectionElement")) {
						try {
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							BooleanElementChange change = new BooleanElementChange(OWLAnd.class, "Remove", changeOnt, cla, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddUnionElement")) {
						try {
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							BooleanElementChange change = new BooleanElementChange(OWLOr.class, "Add", changeOnt, cla, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveUnionElement")) {
						try {
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							BooleanElementChange change = new BooleanElementChange(OWLOr.class, "Remove", changeOnt, cla, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddEnumerationElement")) {
						try {
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLIndividual enumElem = (OWLIndividual) swoopModel.getEntity(changeOnt, new URI(arguments[2]), true, swoopModel.INDIVIDUALS);
							EnumElementChange change = new EnumElementChange("Add", changeOnt, cla, enumElem, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveEnumerationElement")) {
						try {
							OWLClass cla = (OWLClass) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.CLASSES);
							OWLIndividual enumElem = (OWLIndividual) swoopModel.getEntity(changeOnt, new URI(arguments[2]), true, swoopModel.INDIVIDUALS);
							EnumElementChange change = new EnumElementChange("Remove", changeOnt, cla, enumElem, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#SetFunctional")) {
						try {
							OWLProperty prop = (OWLProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							boolean setting = true;
							if (arguments[2].equals("false")) setting = false;
							SetFunctional change = new SetFunctional(changeOnt, prop, setting, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#SetInverseFunctional")) {
						try {
							OWLObjectProperty prop = (OWLObjectProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							boolean setting = true;
							if (arguments[2].equals("false")) setting = false;
							SetInverseFunctional change = new SetInverseFunctional(changeOnt, prop, setting, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#SetTransitive")) {
						try {
							OWLObjectProperty prop = (OWLObjectProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							boolean setting = true;
							if (arguments[2].equals("false")) setting = false;
							SetTransitive change = new SetTransitive(changeOnt, prop, setting, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#SetSymmetric")) {
						try {
							OWLObjectProperty prop = (OWLObjectProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							boolean setting = true;
							if (arguments[2].equals("false")) setting = false;
							SetSymmetric change = new SetSymmetric(changeOnt, prop, setting, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddSuperProperty")) {
						try {	
							OWLProperty prop = (OWLProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							OWLProperty supProp = (OWLProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							AddSuperProperty change = new AddSuperProperty(changeOnt, prop, supProp, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveSuperProperty")) {
						try {
							OWLProperty prop = (OWLProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							OWLProperty supProp = (OWLProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							RemoveSuperProperty change = new RemoveSuperProperty(changeOnt, prop, supProp, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddDomain")) {
						try {
							OWLProperty prop = (OWLProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES); //TODO:could be dataProp??
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);						
							AddDomain change = new AddDomain(changeOnt, prop, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveDomain")) {
						try {
							OWLProperty prop = (OWLProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);						
							RemoveDomain change = new RemoveDomain(changeOnt, prop, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddObjectPropertyRange")) {
						try {
							OWLObjectProperty prop = (OWLObjectProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);						
							AddObjectPropertyRange change = new AddObjectPropertyRange(changeOnt, prop, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveObjectPropertyRange")) {
						try {
							OWLObjectProperty prop = (OWLObjectProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.OBJPROPERTIES);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);						
							RemoveObjectPropertyRange change = new RemoveObjectPropertyRange(changeOnt, prop, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddDataPropertyRange")) {
						try {
							OWLDataProperty prop = (OWLDataProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.DATAPROPERTIES);
							OWLDataType dType = df.getOWLConcreteDataType(new URI(arguments[2]));
							AddDataPropertyRange change = new AddDataPropertyRange(changeOnt, prop, dType, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveDataPropertyRange")) {
						try {
							OWLDataProperty prop = (OWLDataProperty) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.DATAPROPERTIES);
							OWLDataType dType = df.getOWLConcreteDataType(new URI(arguments[2]));
							RemoveDataPropertyRange change = new RemoveDataPropertyRange(changeOnt, prop, dType, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddIndividualClass")) {
						try {
							OWLIndividual indi = (OWLIndividual) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.INDIVIDUALS);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							AddIndividualClass change = new AddIndividualClass(changeOnt, indi, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveIndividualClass")) {
						try {
							OWLIndividual indi = (OWLIndividual) swoopModel.getEntity(changeOnt, new URI(arguments[1]), true, swoopModel.INDIVIDUALS);
							OWLDescription desc = this.getOWLObjectNode(annotOnt, arguments[2], changeOnt);
							RemoveIndividualClass change = new RemoveIndividualClass(changeOnt, indi, desc, null);
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#AddSameIndividuals")) {
						try {
							Set sameInds = new HashSet();
							int i = 1;
							while (arguments[i]!=null) {
								sameInds.add((OWLIndividual) swoopModel.getEntity(changeOnt, new URI(arguments[i]), true, swoopModel.INDIVIDUALS));
								i++;
							}
							OWLSameIndividualsAxiom sameAxiom = df.getOWLSameIndividualsAxiom(sameInds);
							AddIndividualAxiom change = new AddIndividualAxiom(changeOnt, sameAxiom, null); 
							changes.add(change);
						}
						catch (Exception ex) {
							ex.printStackTrace();
						}
					}
					else if (uri.equals(owlapiLocation+"#RemoveSameIndividuals")) {
						try {
							Set sameInds = new HashSet();
							int i = 1;
							while (arguments[i]!=null) {
								sameInds.add((OWLIndividual) swoopModel.getEntity(changeOnt, new URI(arguments[i]), true, swoopModel.INDIVIDUALS));
								i++;
							}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?