/** * @return for literal values, the literal, else an empty Optional */ default Optional<OWLLiteral> literalValue() { return annotationValue().asLiteral(); }
/** * @return for literal values, the literal, else an empty Optional */ default Optional<OWLLiteral> literalValue() { return annotationValue().asLiteral(); }
/** * @return for literal values, the literal, else an empty Optional */ default Optional<OWLLiteral> literalValue() { return annotationValue().asLiteral(); }
public static String getValueAsLiteralOrURI(OWLAnnotationValue v){ try{ return v.asIRI().get().getIRIString(); }catch(Exception e){ //instead of a resource, it was added as a String return v.asLiteral().get().getLiteral(); } }
@Nullable protected static String handleIAO10001(@Nullable String replacedBy, final Set<OWLAnnotationAssertionAxiom> unrelatedAxioms, OWLAnnotationAssertionAxiom axiom) { OWLAnnotationValue value = axiom.getValue(); Optional<OWLLiteral> asLiteral = value.asLiteral(); if (asLiteral.isPresent()) { return asLiteral.get().getLiteral(); } // fallback: also check for an IRI Optional<IRI> asIRI = value.asIRI(); if (asIRI.isPresent()) { // translate IRI to OBO style ID return getIdentifier(asIRI.get()); } unrelatedAxioms.add(axiom); return replacedBy; }
protected void examineAssertion(OWLPrimitive owlEntity, Set<OWLAxiom> axioms, OWLAnnotationAssertionAxiom ax) { if (ax.getSubject().equals(owlEntity)) { axioms.add(ax); } else { ax.getValue().asLiteral().ifPresent(lit -> { if (OWL2Datatype.XSD_ANY_URI.matches(lit.getDatatype()) && lit.getLiteral().equals(owlEntity.toString())) { axioms.add(ax); } }); } }
protected void examineAssertion(OWLPrimitive owlEntity, Set<OWLAxiom> axioms, OWLAnnotationAssertionAxiom ax) { if (ax.getSubject().equals(owlEntity)) { axioms.add(ax); } else { ax.getValue().asLiteral().ifPresent(lit -> { if (OWL2Datatype.XSD_ANY_URI.matches(lit.getDatatype()) && lit.getLiteral().equals(owlEntity.toString())) { axioms.add(ax); } }); } }
protected void examineAssertion(OWLPrimitive owlEntity, Set<OWLAxiom> axioms, OWLAnnotationAssertionAxiom ax) { if (ax.getSubject().equals(owlEntity)) { axioms.add(ax); } else { ax.getValue().asLiteral().ifPresent(lit -> { if (OWL2Datatype.XSD_ANY_URI.matches(lit.getDatatype()) && lit.getLiteral().equals(owlEntity.toString())) { axioms.add(ax); } }); } }
@Nullable protected static String handleIAO10001(@Nullable String replacedBy, final Set<OWLAnnotationAssertionAxiom> unrelatedAxioms, OWLAnnotationAssertionAxiom axiom) { OWLAnnotationValue value = axiom.getValue(); Optional<OWLLiteral> asLiteral = value.asLiteral(); if (asLiteral.isPresent()) { return asLiteral.get().getLiteral(); } // fallback: also check for an IRI Optional<IRI> asIRI = value.asIRI(); if (asIRI.isPresent()) { // translate IRI to OBO style ID return getIdentifier(asIRI.get()); } unrelatedAxioms.add(axiom); return replacedBy; }
@Nullable protected static String handleIAO10001(@Nullable String replacedBy, final Set<OWLAnnotationAssertionAxiom> unrelatedAxioms, OWLAnnotationAssertionAxiom axiom) { OWLAnnotationValue value = axiom.getValue(); Optional<OWLLiteral> asLiteral = value.asLiteral(); if (asLiteral.isPresent()) { return asLiteral.get().getLiteral(); } // fallback: also check for an IRI Optional<IRI> asIRI = value.asIRI(); if (asIRI.isPresent()) { // translate IRI to OBO style ID return getIdentifier(asIRI.get()); } unrelatedAxioms.add(axiom); return replacedBy; }
@Nullable protected static String handleIAO10001(@Nullable String replacedBy, final Set<OWLAnnotationAssertionAxiom> unrelatedAxioms, OWLAnnotationAssertionAxiom axiom) { OWLAnnotationValue value = axiom.getValue(); Optional<OWLLiteral> asLiteral = value.asLiteral(); if (asLiteral.isPresent()) { return asLiteral.get().getLiteral(); } // fallback: also check for an IRI Optional<IRI> asIRI = value.asIRI(); if (asIRI.isPresent()) { // translate IRI to OBO style ID return getIdentifier(asIRI.get()); } unrelatedAxioms.add(axiom); return replacedBy; }
protected void examineAssertion(OWLPrimitive owlEntity, Set<OWLAxiom> axioms, OWLAnnotationAssertionAxiom ax) { if (ax.getSubject().equals(owlEntity)) { axioms.add(ax); } else { ax.getValue().asLiteral().ifPresent(lit -> { if (OWL2Datatype.XSD_ANY_URI.matches(lit.getDatatype()) && lit.getLiteral().equals(owlEntity.toString())) { axioms.add(ax); } }); } }
protected void expandAssertions(OWLOntology o, OWLAnnotationProperty p) { OWLAnnotationProperty ap425 = df.getOWLAnnotationProperty(IRI_IAO_0000425.getIRI()); getAnnotationObjects(p, o.importsClosure(), ap425).map(a -> a.getValue().asLiteral()) .filter(v -> v.isPresent()) .forEach(v -> { String str = v.get().getLiteral(); LOG.info("assertion mapping {} to {}", p, str); expandAssertionToMap.put(p.getIRI(), str); }); }
protected void expandAssertions(OWLOntology o, OWLAnnotationProperty p) { OWLAnnotationProperty ap425 = df.getOWLAnnotationProperty(IRI_IAO_0000425.getIRI()); getAnnotationObjects(p, o.importsClosure(), ap425).map(a -> a.getValue().asLiteral()) .filter(v -> v.isPresent()) .forEach(v -> { String str = v.get().getLiteral(); LOG.info("assertion mapping {} to {}", p, str); expandAssertionToMap.put(p.getIRI(), str); }); }
protected void expandAssertions(OWLOntology o, OWLAnnotationProperty p) { OWLAnnotationProperty ap425 = df.getOWLAnnotationProperty(IRI_IAO_0000425.getIRI()); getAnnotationObjects(p, o.importsClosure(), ap425).map(a -> a.getValue().asLiteral()) .filter(v -> v.isPresent()) .forEach(v -> { String str = v.get().getLiteral(); LOG.info("assertion mapping {} to {}", p, str); expandAssertionToMap.put(p.getIRI(), str); }); }
protected void expandAssertions(OWLOntology o, OWLAnnotationProperty p) { OWLAnnotationProperty ap425 = df.getOWLAnnotationProperty(IRI_IAO_0000425.getIRI()); getAnnotationObjects(p, o.importsClosure(), ap425).map(a -> a.getValue().asLiteral()) .filter(v -> v.isPresent()) .forEach(v -> { String str = v.get().getLiteral(); LOG.info("assertion mapping {} to {}", p, str); expandAssertionToMap.put(p.getIRI(), str); }); }
private void replaceAnnotationAssertions(@Nonnull List<OWLOntologyChange> changes, @Nonnull Set<IRI> propertyIris, @Nonnull String replacement) { ontologies.forEach(o -> { IRI entityIri = info.getEntityToDeprecate().getIRI(); o.getAnnotationAssertionAxioms(entityIri).stream() .filter(ax -> propertyIris.contains(ax.getProperty().getIRI())) .filter(ax -> ax.getValue().asLiteral().isPresent()) .forEach(ax -> { changes.add(new RemoveAxiom(o, ax)); OWLLiteral currentLiteral = ax.getValue().asLiteral().get(); OWLLiteral replacementLiteral = new LiteralLexicalValueReplacer(dataFactory).replaceLexicalValue( currentLiteral, replacement); OWLAxiom replacementAx = dataFactory.getOWLAnnotationAssertionAxiom( ax.getProperty(), ax.getSubject(), replacementLiteral, ax.getAnnotations()); changes.add(new AddAxiom(o, replacementAx)); }); }); }
private Constant getValue(OWLAnnotationValue value) throws TranslationException { try { if (value instanceof IRI) { return termFactory.getConstantIRI(rdfFactory.createIRI(value.asIRI().get().toString())); } else if (value instanceof OWLLiteral) { return getValueOfLiteral(value.asLiteral().get()); } else throw new OWLAPITranslatorOWL2QL.TranslationException("Found anonymous individual, this feature is not supported:" + value); } catch (OWLRuntimeException ore) { throw new OWLAPITranslatorOWL2QL.TranslationException(ore.getMessage()); } }
/** * Checks if entity is deprecated. * * @param ontology the OWLOntology to check * @param entity the OWLEntity to check * @return true if entity is deprecated */ public static boolean isDeprecated(OWLOntology ontology, OWLEntity entity) { for (OWLOntology o : ontology.getImportsClosure()) { for (OWLAnnotationAssertionAxiom a : o.getAnnotationAssertionAxioms(entity.getIRI())) { if (a.isDeprecatedIRIAssertion()) { OWLLiteral value = a.getValue().asLiteral().orNull(); if (value != null && value.parseBoolean()) { return true; } } } } return false; }
@Override public Concept visit(OWLAnnotationAssertionAxiom axiom) { if (! (axiom.getSubject() instanceof OWLNamedIndividual) ) { return null; } Optional<OWLLiteral> value = axiom.getValue().asLiteral(); if (!value.isPresent()) { return null; } @SuppressWarnings("unchecked") AttributeType<String> attributeType = (AttributeType<String>)visit(axiom.getProperty()); Entity entity = migrator.entity((OWLNamedIndividual)axiom.getSubject()); Attribute<String> attribute = attributeType.putAttribute(value.get().getLiteral()); RelationshipType propertyRelation = migrator.relation(axiom.getProperty()); return propertyRelation.addRelationship() .addRolePlayer(migrator.entityRole(entity.type(), attribute.type()), entity) .addRolePlayer(migrator.resourceRole(attribute.type()), attribute); }