private void ImportRelationsComposition() throws Exception { List<ObjectProperty> properties = this.jena.listObjectProperties().toList(); for (ObjectProperty property : properties) { OntClass domain = property.listDomain().next().asClass(); if (domain.isUnionClass()) domain = domain.asUnionClass().listOperands().toList().get(0); OntClass range = property.listRange().next().asClass(); if (range.isUnionClass()) range = range.asUnionClass().listOperands().toList().get(0); Relation r = null; if (property.isSymmetricProperty()) r = this.mobi.createSymmetricRelation( this.getNameObjectProperty( property.getLocalName(), domain.getLocalName().length(), range.getLocalName().length())); else if (property.getInverse() == null) r = this.mobi.createUnidirecionalCompositionRelationship( this.getNameObjectProperty( property.getLocalName(), domain.getLocalName().length(), range.getLocalName().length())); else if (property.getInverse() != null) r = this.mobi.createBidirecionalCompositionRelationship( this.getNameObjectProperty( property.getLocalName(), domain.getLocalName().length(), range.getLocalName().length()), this.getNameObjectProperty( property.getInverse().getLocalName(), range.getLocalName().length(), domain.getLocalName().length())); Class mobiDomain = new Class(domain.getLocalName()); // this.mobi.getClass(domain.getLocalName()); Class mobiRange = new Class(range.getLocalName()); // this.mobi.getClass(range.getLocalName()); if (mobiDomain != null && mobiRange != null) { r.setClassA(mobiDomain); r.setClassB(mobiRange); List<? extends OntResource> individuals = domain.listInstances().toList(); for (OntResource resourceIndividual : individuals) { Individual individualDomain = resourceIndividual.asIndividual(); NodeIterator propertyValues = this.jena.getIndividual(individualDomain.getURI()).listPropertyValues(property); while (propertyValues.hasNext()) { RDFNode node = propertyValues.next(); Individual individualValue = node.as(Individual.class); this.mobi.addConcept(mobiDomain); this.mobi.addConcept(mobiRange); Instance instanceDomain = new Instance(individualDomain.getLocalName()); Instance instanceRange = new Instance(individualValue.getLocalName()); try { this.mobi.isOneOf(instanceDomain, mobiDomain); this.mobi.isOneOf(instanceRange, mobiRange); } catch (ExceptionURI e) { } r.addInstanceRelation(instanceDomain, instanceRange); } } r.processCardinality(); if (r.getInstanceRelationMapA().size() > 0) this.mobi.addConcept(r); } } }