public void initializeMiscObjProperty(OWLObjectPropertyExpression prope){ final OWLOntologyManager manager = testWrapper.getManager(); final OWLDataFactory factory = getDataFactory(); Set<OWLObjectPropertyAxiom> propertyAxioms = mergedSources.getAxioms(prope,org.semanticweb.owlapi.model.parameters.Imports.INCLUDED); if (propertyAxioms.isEmpty()){ for (OWLObjectProperty p : prope.getObjectPropertiesInSignature()){ if (PropertyBean.isSourceIdCached(p.getIRI().toString())){ PropertyBean pb = PropertyBean.getSourceIdCached(p.getIRI().toString()); OWLAnnotationProperty labelProperty = factory.getRDFSLabel(); OWLAnnotationValue labelValue = factory.getOWLLiteral(pb.getLabel()); OWLAnnotation labelAnnotation = factory.getOWLAnnotation(labelProperty, labelValue); OWLAnnotationAxiom labelAxiom = factory.getOWLAnnotationAssertionAxiom(p.getIRI(), labelAnnotation); manager.addAxiom(target,labelAxiom); } else { log.warn("Couldn't find propertybean for IRI " + p.getIRI().toString()); } } } else{ log.debug("Adding axioms for " + prope.toString()); manager.addAxioms(target, propertyAxioms); } //log.info("Annotations"); if (prope instanceof OWLObjectProperty){ OWLObjectProperty prop = (OWLObjectProperty) prope; Set<OWLAnnotationAssertionAxiom> termAnnotations = mergedSources.getAnnotationAssertionAxioms(prop.getIRI()); for (OWLAnnotationAssertionAxiom a : termAnnotations){ //log.info(" Annotation Axiom: " + a.toString()); if (a.getAnnotation().getProperty().isLabel()){ manager.addAxiom(target, a); } } } }
@SuppressWarnings("static-method") public ElkObjectPropertyAxiom convert( OWLObjectPropertyAxiom owlObjectPropertyAxiom) { return owlObjectPropertyAxiom .accept(OWL_OBJECT_PROPERTY_AXIOM_CONVERTER); }
private OWLOntology createSimpleGraphColoring() { OWLOntology ontoColoring = null; OWLDataFactory factory = OWLManager.getOWLDataFactory(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLObjectPropertyExpression edgeProp = factory.getOWLObjectProperty(IRI.create(String.format("%s#%s", PREFIX, "edge"))); OWLClassExpression classNode = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Node"))); OWLClassExpression classBlue = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Blue"))); OWLClassExpression classRed = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Red"))); OWLClassExpression classGreen = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Green"))); OWLNamedIndividual indNode1 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node1"))); OWLNamedIndividual indNode2 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node2"))); OWLNamedIndividual indNode3 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node3"))); OWLNamedIndividual indNode4 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node4"))); // now the facts // nodes OWLIndividualAxiom axmNodeInst4 =factory.getOWLClassAssertionAxiom(classNode, indNode4); OWLIndividualAxiom axmNodeInst3 =factory.getOWLClassAssertionAxiom(classNode, indNode3); OWLIndividualAxiom axmNodeInst2 =factory.getOWLClassAssertionAxiom(classNode, indNode2); OWLIndividualAxiom axmNodeInst1 =factory.getOWLClassAssertionAxiom(classNode, indNode1); // 1 // | \ // | 3 - 4 // | / // 2 // OWLIndividualAxiom axmEdge12 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode1, indNode2); OWLIndividualAxiom axmEdge13 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode1, indNode3); OWLIndividualAxiom axmEdge23 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode2, indNode3); OWLIndividualAxiom axmEdge34 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode3, indNode4); // symmetry of edge property OWLObjectPropertyAxiom axmEdgeSym = factory.getOWLSymmetricObjectPropertyAxiom(edgeProp); // axioms OWLObjectUnionOf exprColorUnion = factory.getOWLObjectUnionOf(classBlue, classRed, classGreen); OWLSubClassOfAxiom axmNodeColorings = factory.getOWLSubClassOfAxiom(classNode, exprColorUnion); // coloring constraints OWLSubClassOfAxiom axmRedConstraint = factory.getOWLSubClassOfAxiom(classRed, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classGreen, classBlue))); OWLSubClassOfAxiom axmBlueConstraint = factory.getOWLSubClassOfAxiom(classBlue, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classGreen, classRed))); OWLSubClassOfAxiom axmGreenConstraint = factory.getOWLSubClassOfAxiom(classGreen, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classRed, classBlue))); OWLDisjointClassesAxiom axmDisColors = factory.getOWLDisjointClassesAxiom(classRed, classBlue, classGreen); try { ontoColoring = manager.createOntology(); manager.addAxiom(ontoColoring, axmNodeInst1); manager.addAxiom(ontoColoring, axmNodeInst2); manager.addAxiom(ontoColoring, axmNodeInst3); manager.addAxiom(ontoColoring, axmNodeInst4); manager.addAxiom(ontoColoring, axmEdge12); manager.addAxiom(ontoColoring, axmEdge13); manager.addAxiom(ontoColoring, axmEdge23); manager.addAxiom(ontoColoring, axmEdge34); manager.addAxiom(ontoColoring, axmEdgeSym); manager.addAxiom(ontoColoring, axmNodeColorings); manager.addAxiom(ontoColoring, axmRedConstraint); manager.addAxiom(ontoColoring, axmBlueConstraint); manager.addAxiom(ontoColoring, axmGreenConstraint); manager.addAxiom(ontoColoring, axmDisColors); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } return ontoColoring; }