protected void addOntologyAnnotation(OWLAnnotation annotation) { applyChange(new AddOntologyAnnotation(getOntology(), annotation)); }
@Override public boolean canHandleStreaming(IRI subject, IRI predicate, IRI object) { OWLRDFConsumer consumer = getConsumer(); consumer.addOWLRestriction(subject, false); IRI propIRI = consumer.getResourceObject(subject, OWLRDFVocabulary.OWL_ON_PROPERTY.getIRI(), false); if (propIRI != null && (!consumer.isAnonymousNode(object) || consumer.getClassExpressionIfTranslated(object) != null)) { // The filler is either a datatype or named class if (consumer.isObjectPropertyOnly(propIRI)) { consumer.addClassExpression(object, false); consumer.addTriple(subject, predicate, object); consumer.translateClassExpression(subject); return true; } else if (consumer.isDataPropertyOnly(propIRI)) { } } return false; }
@Override public boolean canHandleStreaming(IRI subject, IRI predicate, IRI object) throws UnloadableImportException { getConsumer().addAnnotatedSource(object, subject); // FIXME: This calls .handle from inside canHandleStreaming? getConsumer().checkForAndProcessAnnotatedDeclaration(subject); return false; }
@Override public OWLClassExpression translate(IRI iri) { consumer.addClassExpression(iri, false); return consumer.translateClassExpression(iri); }
public boolean canHandleStreaming(IRI subject, IRI predicate, IRI object) { OWLRDFConsumer consumer = getConsumer(); IRI propIRI = consumer.getResourceObject(subject, OWLRDFVocabulary.OWL_ON_PROPERTY.getIRI(), false); if(propIRI != null && (!consumer.isAnonymousNode(object) || consumer.getClassExpressionIfTranslated(object) != null)) { // The filler is either a datatype or named class if(consumer.isObjectPropertyOnly(propIRI)) { consumer.addOWLClass(object); consumer.addTriple(subject, predicate, object); consumer.translateClassExpression(subject); return true; } else if(consumer.isDataPropertyOnly(propIRI)) { } } return false; }
public SWRLAtom translate(IRI firstObject) { if (consumer.isSWRLBuiltInAtom(firstObject)) { IRI builtInIRI = consumer.getResourceObject(firstObject, BUILT_IN.getIRI(), true); IRI mainIRI = consumer.getResourceObject(firstObject, ARGUMENTS.getIRI(), true); OptimisedListTranslator<SWRLDArgument> listTranslator = new OptimisedListTranslator<SWRLDArgument>( consumer, else if (consumer.isSWRLClassAtom(firstObject)) { IRI classIRI = consumer.getResourceObject(firstObject, CLASS_PREDICATE.getIRI(), true); OWLClassExpression desc = consumer.translateClassExpression(classIRI); return dataFactory.getSWRLClassAtom(desc, iObject); else if (consumer.isSWRLDataRangeAtom(firstObject)) { IRI dataRangeIRI = consumer.getResourceObject(firstObject, DATA_RANGE.getIRI(), true); OWLDataRange dataRange = consumer.translateDataRange(dataRangeIRI); return dataFactory.getSWRLDataRangeAtom(dataRange, dObject); else if (consumer.isSWRLDataValuedPropertyAtom(firstObject)) { SWRLIArgument arg1 = translateSWRLAtomIObject(firstObject, ARGUMENT_1.getIRI()); SWRLDArgument arg2 = translateSWRLAtomDObject(firstObject, ARGUMENT_2.getIRI()); IRI dataPropertyIRI = consumer.getResourceObject(firstObject, PROPERTY_PREDICATE.getIRI(), true); OWLDataPropertyExpression prop = consumer.translateDataPropertyExpression(dataPropertyIRI); return dataFactory.getSWRLDataPropertyAtom(prop, arg1, arg2); else if (consumer.isSWRLIndividualPropertyAtom(firstObject)) { SWRLIArgument arg1 = translateSWRLAtomIObject(firstObject, ARGUMENT_1.getIRI()); SWRLIArgument arg2 = translateSWRLAtomIObject(firstObject, ARGUMENT_2.getIRI()); IRI objectPropertyIRI = consumer.getResourceObject(firstObject, PROPERTY_PREDICATE.getIRI(), true);
@Override public OWLObjectAllValuesFrom translate(IRI mainNode) { getConsumer().consumeTriple(mainNode, RDF_TYPE.getIRI(), OWL_RESTRICTION.getIRI()); IRI propertyIRI = getConsumer().getResourceObject(mainNode, OWL_ON_PROPERTY, true); OWLObjectPropertyExpression property = getConsumer().translateObjectPropertyExpression(propertyIRI); IRI fillerMainNode = getConsumer().getResourceObject(mainNode, OWL_ALL_VALUES_FROM, true); OWLClassExpression filler = getConsumer().translateClassExpression(fillerMainNode); return getDataFactory().getOWLObjectAllValuesFrom(property, filler); } }
getConsumer().addOntology(subject); getConsumer().addOntology(object); OWLImportsDeclaration importsDeclaration = getDataFactory().getOWLImportsDeclaration(object); getConsumer().addImport(importsDeclaration); if (!getConsumer().getConfiguration().isIgnoredImport(object)) { OWLOntologyManager man = getConsumer().getOWLOntologyManager(); man.makeLoadImportRequest(importsDeclaration, getConsumer().getConfiguration()); if (importedOntologyFormat instanceof RDFOntologyFormat) { if (importedOntology.isAnonymous()) { OWLOntologyLoaderConfiguration.MissingOntologyHeaderStrategy missingOntologyHeaderStrategy = getConsumer().getConfiguration().getMissingOntologyHeaderStrategy(); boolean includeGraph = missingOntologyHeaderStrategy.equals(OWLOntologyLoaderConfiguration.MissingOntologyHeaderStrategy.INCLUDE_GRAPH); man.applyChange(new RemoveImport(getConsumer().getOntology(), importsDeclaration)); man.applyChange(new AddImport(getConsumer().getOntology(), decl)); man.applyChange(new AddOntologyAnnotation(getConsumer().getOntology(), anno)); getConsumer().addAxiom(ax); getConsumer().importsClosureChanged();
public void translateRule(IRI mainNode) { Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>(); Set<IRI> predicates = consumer.getPredicatesBySubject(mainNode); for (IRI i : predicates) { if (consumer.isAnnotationProperty(i)) { OWLAnnotationProperty p = consumer.getDataFactory() .getOWLAnnotationProperty(i); OWLLiteral literal = consumer.getLiteralObject(mainNode, i, true); while (literal != null) { annotations.add(consumer.getDataFactory() .getOWLAnnotation(p, literal)); literal = consumer.getLiteralObject(mainNode, i, true); IRI ruleHeadIRI = consumer.getResourceObject(mainNode, SWRLVocabulary.HEAD.getIRI(), true); if (ruleHeadIRI != null) { consequent = listTranslator.translateToSet(ruleHeadIRI); IRI ruleBodyIRI = consumer.getResourceObject(mainNode, SWRLVocabulary.BODY.getIRI(), true); if (ruleBodyIRI != null) { antecedent = listTranslator.translateToSet(ruleBodyIRI); if (!consumer.isAnonymousNode(mainNode)) { rule = consumer.getDataFactory().getSWRLRule(antecedent, consequent, annotations); rule = consumer.getDataFactory().getSWRLRule(antecedent, consequent, annotations); consumer.addAxiom(rule);
@Override public void handleTriple(IRI subject, IRI predicate, IRI object) throws UnloadableImportException { consumeTriple(subject, predicate, object); IRI listNode = getConsumer().getResourceObject(subject, OWLRDFVocabulary.OWL_MEMBERS.getIRI(), true); if (getConsumer().isObjectProperty(getConsumer().getFirstResource(listNode, false))) { Set<OWLAnnotation> annotations = getConsumer().translateAnnotations(subject); List<OWLObjectPropertyExpression> props = getConsumer().translateToObjectPropertyList(listNode); getConsumer().addAxiom(getDataFactory().getOWLDisjointObjectPropertiesAxiom(new HashSet<OWLObjectPropertyExpression>(props), annotations)); } else { Set<OWLAnnotation> annotations = getConsumer().translateAnnotations(subject); List<OWLDataPropertyExpression> props = getConsumer().translateToDataPropertyList(listNode); getConsumer().addAxiom(getDataFactory().getOWLDisjointDataPropertiesAxiom(new HashSet<OWLDataPropertyExpression>(props), annotations)); } }
public void handleTriple(IRI subject, IRI predicate, IRI object) throws UnloadableImportException { consumeTriple(subject, predicate, object); IRI annotatedSource = getObjectOfSourceTriple(subject); IRI annotatedProperty = getObjectOfPropertyTriple(subject); IRI annotatedTarget = getObjectOfTargetTriple(subject); OWLLiteral annotatedTargetLiteral = null; if(annotatedTarget == null) { annotatedTargetLiteral = getTargetLiteral(subject); } Set<OWLAnnotation> annotations = getConsumer().translateAnnotations(subject); getConsumer().setPendingAnnotations(annotations); if (annotatedTarget != null) { getConsumer().handle(annotatedSource, annotatedProperty, annotatedTarget); } else { getConsumer().handle(annotatedSource, annotatedProperty, annotatedTargetLiteral); } if (!annotations.isEmpty()) { OWLAxiom ax = getConsumer().getLastAddedAxiom(); getConsumer().applyChange(new RemoveAxiom(getConsumer().getOntology(), ax.getAxiomWithoutAnnotations())); } }
public void handleTriple(IRI subject, IRI predicate, IRI object) throws UnloadableImportException { consumeTriple(subject, predicate, object); IRI listNode = getConsumer().getResourceObject(subject, OWLRDFVocabulary.OWL_MEMBERS.getIRI(), true); if (getConsumer().isObjectPropertyOnly(getConsumer().getFirstResource(listNode, false))) { translateAndSetPendingAnnotations(subject); List<OWLObjectPropertyExpression> props = getConsumer().translateToObjectPropertyList(listNode); getConsumer().addAxiom(getDataFactory().getOWLDisjointObjectPropertiesAxiom(new HashSet<OWLObjectPropertyExpression>(props), getPendingAnnotations())); } else { translateAndSetPendingAnnotations(subject); List<OWLDataPropertyExpression> props = getConsumer().translateToDataPropertyList(listNode); getConsumer().addAxiom(getDataFactory().getOWLDisjointDataPropertiesAxiom(new HashSet<OWLDataPropertyExpression>(props), getPendingAnnotations())); } }
public void handleTriple(IRI subject, IRI predicate, IRI object) throws UnloadableImportException { consumeTriple(subject, predicate, object); if(!isAnonymous(subject) && getConsumer().getOntologies().isEmpty()) { // Set IRI? OWLOntologyID id = new OWLOntologyID(subject); getConsumer().applyChange(new SetOntologyID(getConsumer().getOntology(), id)); } getConsumer().addOntology(subject); } }
OWLRDFConsumer consumer = new OWLRDFConsumer(ontology, new AnonymousNodeChecker() { @Override public boolean isAnonymousNode(IRI iri) { consumer.setIRIProvider(prov); consumer.setOntologyFormat(format); is = getInputSource(documentSource, configuration); parser.parse(is, consumer);
@Override public OWLObjectMinCardinality translate(IRI mainNode) { int cardi = translateInteger(mainNode, OWL_MIN_QUALIFIED_CARDINALITY); IRI propertyIRI = getConsumer().getResourceObject(mainNode, OWL_ON_PROPERTY, true); OWLObjectPropertyExpression property = getConsumer().translateObjectPropertyExpression(propertyIRI); IRI fillerIRI = getConsumer().getResourceObject(mainNode, OWL_ON_CLASS, true); OWLClassExpression filler = getConsumer().translateClassExpression(fillerIRI); return getDataFactory().getOWLObjectMinCardinality(cardi, property, filler); } }
OWLIndividual ind = translateIndividual(subject); OWLClassExpression ce = translateClassExpression(object); addAxiom(dataFactory.getOWLClassAssertionAxiom(ce, ind, getPendingAnnotations()));
OWLOntology ontology = manager.createOntology( TMP_URI ); OWLRDFConsumer consumer = new OWLRDFConsumer( ontology, new AnonymousNodeChecker() { @Override consumer.startModel( "" ); lang = null; consumer.statementWithLiteralValue( subj, pred, obj, lang, datatypeURI ); consumer.statementWithResourceValue( subj, pred, obj ); consumer.endModel();
@Override public boolean canHandleStreaming(IRI subject, IRI predicate, IRI object) { if(getConsumer().isObjectProperty(object)) { getConsumer().addObjectProperty(subject, false); } else if(getConsumer().isDataProperty(object)) { getConsumer().addDataProperty(object, false); } else if(getConsumer().isAnnotationProperty(object)) { getConsumer().addAnnotationProperty(subject, false); } else if(getConsumer().isObjectProperty(subject)) { getConsumer().addObjectProperty(object, false); } else if(getConsumer().isDataProperty(subject)) { getConsumer().addDataProperty(object, false); } else if(getConsumer().isAnnotationProperty(subject)) { getConsumer().addAnnotationProperty(object, false); } return false; }
public void translateRule(IRI mainNode) { Set<SWRLAtom> consequent = Collections.emptySet(); IRI ruleHeadIRI = consumer.getResourceObject(mainNode, SWRLVocabulary.HEAD.getIRI(), true); if (ruleHeadIRI != null) { consequent = listTranslator.translateToSet(ruleHeadIRI); } Set<SWRLAtom> antecedent = Collections.emptySet(); IRI ruleBodyIRI = consumer.getResourceObject(mainNode, SWRLVocabulary.BODY.getIRI(), true); if (ruleBodyIRI != null) { antecedent = listTranslator.translateToSet(ruleBodyIRI); } SWRLRule rule = null; if (!consumer.isAnonymousNode(mainNode)) { rule = consumer.getDataFactory().getSWRLRule(mainNode, antecedent, consequent); } else { rule = consumer.getDataFactory().getSWRLRule(NodeID.getNodeID(mainNode.toString()), antecedent, consequent); } consumer.addAxiom(rule); } }
public OWLClassExpression translate(IRI IRI) { return consumer.translateClassExpression(IRI); }