org.semanticweb.owlapi.model.OWLDataProperty Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLDataProperty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Hierarchy getSubDatatypePropertiesOf(ValueFactory vf, ModelFactory mf) {
    long start = getStartTime();
    try {
        Hierarchy hierarchy = new Hierarchy(vf, mf);
        Set<OWLDataProperty> properties = getDeclaredDatatypeProperties(Imports.INCLUDED)
                .collect(Collectors.toSet());
        threadPool.submit(() -> properties.parallelStream()
                .forEach(property -> {
                    IRI propIRI = SimpleOntologyValues.mobiIRI(property.getIRI());
                    hierarchy.addIRI(propIRI);
                    getSubDatatypePropertiesFor(property, true)
                            .forEach(subpropIRI -> hierarchy.addParentChild(propIRI, subpropIRI));
                })).get();
        return hierarchy;
    } catch (InterruptedException | ExecutionException e) {
        throw new MobiOntologyException("Error retrieving getSubDatatypePropertiesOf", e);
    } finally {
        logTrace("getSubDatatypePropertiesOf()", start);
    }
}
 
Example #2
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public Set<IRI> getSubPropertiesFor(IRI iri) {
    long start = getStartTime();
    try {
        org.semanticweb.owlapi.model.IRI owlapiIRI = SimpleOntologyValues.owlapiIRI(iri);
        if (owlOntology.containsDataPropertyInSignature(owlapiIRI, Imports.INCLUDED)) {
            OWLDataProperty owlDataProperty = owlManager.getOWLDataFactory().getOWLDataProperty(owlapiIRI);
            return getSubDatatypePropertiesFor(owlDataProperty, false).collect(Collectors.toSet());
        } else if (owlOntology.containsObjectPropertyInSignature(owlapiIRI, Imports.INCLUDED)) {
            OWLObjectProperty owlObjectProperty = owlManager.getOWLDataFactory().getOWLObjectProperty(owlapiIRI);
            return getSubObjectPropertiesFor(owlObjectProperty, false).collect(Collectors.toSet());
        } else if (owlOntology.containsAnnotationPropertyInSignature(owlapiIRI, Imports.INCLUDED)) {
            OWLAnnotationProperty owlAnnotationProperty = owlManager.getOWLDataFactory()
                    .getOWLAnnotationProperty(owlapiIRI);
            return getSubAnnotationPropertiesFor(owlAnnotationProperty, false).collect(Collectors.toSet());
        } else {
            return Collections.emptySet();
        }
    } finally {
        logTrace("getSubPropertiesFor(IRI)", start);
    }
}
 
Example #3
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 6 votes vote down vote up
@Override
public Void visit(OWLDataPropertyAssertionAxiom axiom) {
  long individual = getOrCreateNode(getIri(axiom.getSubject()));
  OWLDataProperty property = axiom.getProperty().asOWLDataProperty();
  // TODO: fix this Set<OWLDataRange> ranges = property.getRanges(ontology);
  // Except without the ontology we can't verify the range...
  String propertyName = property.getIRI().toString();
  Optional<Object> literal = OwlApiUtils.getTypedLiteralValue(axiom.getObject());

  if (literal.isPresent()) {
    graph.setNodeProperty(individual, propertyName, literal.get());
    if (mappedProperties.containsKey(propertyName)) {
      graph.addNodeProperty(individual, mappedProperties.get(propertyName), literal.get());
    }
  }
  return null;
}
 
Example #4
Source File: ElkReasoner.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual arg0,
		OWLDataProperty arg1)
		throws InconsistentOntologyException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	LOGGER_.trace(
			"getDataPropertyValues(OWLNamedIndividual, OWLDataProperty)");

	checkInterrupted();
	// TODO Provide implementation
	throw unsupportedOwlApiMethod(
			"getDataPropertyValues(OWLNamedIndividual, OWLDataProperty)");
}
 
Example #5
Source File: ElkReasoner.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public Node<OWLDataProperty> getEquivalentDataProperties(
		OWLDataProperty arg0)
		throws InconsistentOntologyException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	LOGGER_.trace("getEquivalentDataProperties(OWLDataProperty)");

	checkInterrupted();
	// TODO Provide implementation
	throw unsupportedOwlApiMethod(
			"getEquivalentDataProperties(OWLDataProperty)");
}
 
Example #6
Source File: SimpleOntology.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
private Stream<IRI> getSubDatatypePropertiesFor(OWLDataProperty property, boolean direct) {
    if (direct) {
        return owlOntology.axioms(AxiomType.SUB_DATA_PROPERTY, Imports.INCLUDED)
                .filter(axiom -> axiom.getSuperProperty().equals(property))
                .map(OWLSubPropertyAxiom::getSubProperty)
                .filter(subproperty -> !subproperty.isBottomEntity() && subproperty.isOWLDataProperty()
                        && !subproperty.asOWLDataProperty().getIRI().equals(property.getIRI()))
                .map(subproperty -> SimpleOntologyValues.mobiIRI(subproperty.asOWLDataProperty().getIRI()));
    } else {
        return owlReasoner.getSubDataProperties(property, false).entities()
                .filter(subproperty -> !subproperty.isBottomEntity()
                        && !subproperty.getIRI().equals(property.getIRI()))
                .map(subproperty -> SimpleOntologyValues.mobiIRI(subproperty.getIRI()));
    }
}
 
Example #7
Source File: SimpleOntologyValues.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * .
 */
public static DataProperty mobiDataProperty(OWLDataProperty property) {
    if (property == null) {
        return null;
    }
    return new SimpleDataProperty(mobiIRI(property.getIRI()));
}
 
Example #8
Source File: SimpleOntologyValues.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * .
 */
public static OWLDataProperty owlapiDataProperty(DataProperty property) {
    if (property == null) {
        return null;
    }
    return new OWLDataPropertyImpl(owlapiIRI(property.getIRI()));
}
 
Example #9
Source File: SimpleOntologyValuesTest.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void testMobiDataProperty() throws Exception {
    OWLDataProperty property = mock(OWLDataProperty.class);
    org.semanticweb.owlapi.model.IRI owlIRI = mock(org.semanticweb.owlapi.model.IRI.class);
    IRI iri = mock(IRI.class);
    
    expect(property.getIRI()).andReturn(owlIRI).anyTimes();
    mockStaticPartial(SimpleOntologyValues.class, "mobiIRI");
    expect(SimpleOntologyValues.mobiIRI(owlIRI)).andReturn(iri);
    
    replay(property, owlIRI, iri, SimpleOntologyValues.class);
    
    Assert.assertEquals(iri, SimpleOntologyValues.mobiDataProperty(property).getIRI());
}
 
Example #10
Source File: SimpleOntologyTest.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    restrictionInputStream = getClass().getResourceAsStream("/restriction-test-ontology.ttl");
    hasDoctypeInputStream = getClass().getResourceAsStream("/hasDoctype.owl");
    testFile = Paths.get(getClass().getResource("/test.owl").toURI()).toFile();

    MockitoAnnotations.initMocks(this);

    ontologyIRI = VALUE_FACTORY.createIRI("http://test.com/ontology1");
    when(versionIRI.stringValue()).thenReturn("http://test.com/ontology1/1.0.0");

    mockStatic(SimpleOntologyValues.class);

    when(SimpleOntologyValues.owlapiIRI(any(IRI.class))).thenAnswer(i -> org.semanticweb.owlapi.model.IRI.create(i.getArgumentAt(0, IRI.class).stringValue()));
    when(SimpleOntologyValues.mobiIRI(any(org.semanticweb.owlapi.model.IRI.class))).thenAnswer(i -> vf.createIRI(i.getArgumentAt(0, org.semanticweb.owlapi.model.IRI.class).toString()));
    when(SimpleOntologyValues.owlapiClass(any(OClass.class))).thenAnswer(i -> new OWLClassImpl(org.semanticweb.owlapi.model.IRI.create(i.getArgumentAt(0, OClass.class).getIRI().stringValue())));
    when(SimpleOntologyValues.mobiObjectProperty(any(OWLObjectProperty.class))).thenAnswer(i -> new SimpleObjectProperty(vf.createIRI(i.getArgumentAt(0, OWLObjectProperty.class).getIRI().toString())));
    when(SimpleOntologyValues.mobiDataProperty(any(OWLDataProperty.class))).thenAnswer(i -> new SimpleDataProperty(vf.createIRI(i.getArgumentAt(0, OWLDataProperty.class).getIRI().toString())));

    when(ontologyIdMock.getOntologyIRI()).thenReturn(Optional.of(ontologyIRI));
    when(ontologyIdMock.getVersionIRI()).thenReturn(Optional.of(versionIRI));
    when(ontologyIdMock.getOntologyIdentifier()).thenReturn(ontologyIRI);

    when(ontologyManager.createOntologyId(any(IRI.class), any(IRI.class))).thenReturn(ontologyIdMock);
    when(ontologyManager.createOntologyId(any(IRI.class))).thenReturn(ontologyIdMock);
    when(ontologyManager.createOntologyId()).thenReturn(ontologyIdMock);
    when(ontologyManager.getOntologyRecordResource(any(IRI.class))).thenReturn(Optional.empty());
    when(transformer.sesameModel(any(Model.class))).thenReturn(new LinkedHashModel());
    when(transformer.sesameResource(any(Resource.class))).thenReturn(new SimpleIRI("http://test.com/ontology1"));
}
 
Example #11
Source File: ElkReasoner.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public Node<OWLDataProperty> getBottomDataPropertyNode() {
	LOGGER_.trace("getBottomDataPropertyNode()");

	checkInterrupted();
	// TODO Provide implementation
	throw unsupportedOwlApiMethod("getBottomDataPropertyNode()");
}
 
Example #12
Source File: ElkReasoner.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public NodeSet<OWLClass> getDataPropertyDomains(OWLDataProperty arg0,
		boolean arg1)
		throws InconsistentOntologyException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	LOGGER_.trace("getDataPropertyDomains(OWLDataProperty, boolean)");

	checkInterrupted();
	// TODO Provide implementation
	throw unsupportedOwlApiMethod(
			"getDataPropertyDomains(OWLDataProperty, boolean)");
}
 
Example #13
Source File: ElkReasoner.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public NodeSet<OWLDataProperty> getSubDataProperties(OWLDataProperty arg0,
		boolean arg1)
		throws InconsistentOntologyException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	LOGGER_.trace("getSubDataProperties(OWLDataProperty, boolean)");
	checkInterrupted();
	// TODO Provide implementation
	throw unsupportedOwlApiMethod(
			"getSubDataProperties(OWLDataProperty, boolean)");
}
 
Example #14
Source File: ElkReasoner.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public NodeSet<OWLDataProperty> getSuperDataProperties(OWLDataProperty arg0,
		boolean arg1)
		throws InconsistentOntologyException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	LOGGER_.trace("getSuperDataProperties(OWLDataProperty, boolean)");
	checkInterrupted();
	// TODO Provide implementation
	throw unsupportedOwlApiMethod(
			"getSuperDataProperties(OWLDataProperty, boolean)");
}
 
Example #15
Source File: ElkReasoner.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public NodeSet<OWLDataProperty> getDisjointDataProperties(
		OWLDataPropertyExpression arg0)
		throws InconsistentOntologyException, FreshEntitiesException,
		ReasonerInterruptedException, TimeOutException {
	LOGGER_.trace("getDisjointDataProperties(OWLDataPropertyExpression)");

	checkInterrupted();
	// TODO Provide implementation
	throw unsupportedOwlApiMethod(
			"getDisjointDataProperties(OWLDataPropertyExpression)");
}
 
Example #16
Source File: ElkReasoner.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public Node<OWLDataProperty> getTopDataPropertyNode() {
	LOGGER_.trace("getTopDataPropertyNode()");
	checkInterrupted();
	// TODO Provide implementation
	throw unsupportedOwlApiMethod("getTopDataPropertyNode()");
}
 
Example #17
Source File: OwlObjectPropertyExpressionConverterVisitor.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public ElkObjectPropertyExpression visit(OWLAnnotationProperty property) {
	throw new IllegalArgumentException(
			OWLDataProperty.class.getSimpleName()
					+ " cannot be converted to "
					+ ElkObjectPropertyExpression.class.getSimpleName());
}
 
Example #18
Source File: OwlObjectInverseOfConverterVisitor.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public ElkObjectPropertyExpression visit(OWLDataProperty property) {
	throw new IllegalArgumentException("invers of "
			+ property.getClass().getSimpleName()
			+ " cannot be converted to "
			+ ElkObjectPropertyExpression.class.getSimpleName());
}
 
Example #19
Source File: OwlObjectPropertyExpressionConverterVisitor.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public ElkObjectPropertyExpression visit(OWLDataProperty property) {
	throw new IllegalArgumentException(
			OWLDataProperty.class.getSimpleName()
					+ " cannot be converted to "
					+ ElkObjectPropertyExpression.class.getSimpleName());
}
 
Example #20
Source File: ElkConverter.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Override
public OWLDataProperty convert(ElkDataProperty input) {
	if (input instanceof ElkDataPropertyWrap<?>) {
		return ((ElkDataPropertyWrap<?>) input).getOwlObject();
	}
	// else
	return visit(input);
}
 
Example #21
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
@Override
public Void visit(OWLDeclarationAxiom axiom) {
  String iri = getIri(axiom);
  long node = getOrCreateNode(iri);
  addDefinedBy(node);
  if (axiom.getEntity() instanceof OWLClass) {
    graph.addLabel(node, OwlLabels.OWL_CLASS);
  } else if (axiom.getEntity() instanceof OWLNamedIndividual) {
    graph.addLabel(node, OwlLabels.OWL_NAMED_INDIVIDUAL);
  } else if (axiom.getEntity() instanceof OWLObjectProperty) {
    if (!graph.getLabels(node).contains(OwlLabels.OWL_OBJECT_PROPERTY)) {
      graph.addLabel(node, OwlLabels.OWL_OBJECT_PROPERTY);
      if (ontology.isPresent()) {
        OWLObjectProperty property = (OWLObjectProperty) axiom.getEntity();
        graph.setNodeProperty(node, EdgeProperties.SYMMETRIC,
            !property.isAsymmetric(ontology.get()));
        graph.setNodeProperty(node, EdgeProperties.REFLEXIVE,
            property.isReflexive(ontology.get()));
        graph.setNodeProperty(node, EdgeProperties.TRANSITIVE,
            property.isTransitive(ontology.get()));
      }
    }
  } else if (axiom.getEntity() instanceof OWLDataProperty) {
    graph.setLabel(node, OwlLabels.OWL_DATA_PROPERTY);
  } else {
    // logger.warning("Unhandled declaration type " + axiom.getEntity().getClass().getName());
  }
  return null;
}
 
Example #22
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind,
		OWLDataProperty pe) throws InconsistentOntologyException,
		FreshEntitiesException, ReasonerInterruptedException,
		TimeOutException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #23
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public NodeSet<OWLClass> getDataPropertyDomains(OWLDataProperty pe,
		boolean direct) throws InconsistentOntologyException,
		FreshEntitiesException, ReasonerInterruptedException,
		TimeOutException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #24
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public NodeSet<OWLDataProperty> getDisjointDataProperties(
		OWLDataPropertyExpression pe) throws InconsistentOntologyException,
		FreshEntitiesException, ReasonerInterruptedException,
		TimeOutException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #25
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public NodeSet<OWLDataProperty> getSuperDataProperties(OWLDataProperty pe,
		boolean direct) throws InconsistentOntologyException,
		FreshEntitiesException, ReasonerInterruptedException,
		TimeOutException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #26
Source File: GraphReasoner.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public NodeSet<OWLDataProperty> getSubDataProperties(OWLDataProperty pe,
		boolean direct) throws InconsistentOntologyException,
		FreshEntitiesException, ReasonerInterruptedException,
		TimeOutException {
	// TODO Auto-generated method stub
	return null;
}
 
Example #27
Source File: ManchesterOWLSyntaxObjectHTMLRenderer.java    From robot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Given an OWLDataProperty, write a hyperlink describing it to the writer. */
@Override
public void visit(OWLDataProperty property) {
  write(
      String.format(
          "<a href=\"%s\">%s</a>",
          property.getIRI().toString(), getShortFormProvider().getShortForm(property)));
}
 
Example #28
Source File: QuotedEntityChecker.java    From robot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Find a data property with the given name. Quotation marks will be removed if necessary.
 *
 * @param name the name of the entity to find
 * @return a data property, or null
 */
@Override
public OWLDataProperty getOWLDataProperty(@Nonnull String name) {
  IRI iri = getIRI(dataProperties, name);
  if (iri != null) {
    return dataFactory.getOWLDataProperty(iri);
  }
  if (ioHelper != null) {
    iri = ioHelper.createIRI(name, true);
    if (iri != null) {
      return dataFactory.getOWLDataProperty(iri);
    }
  }
  return null;
}
 
Example #29
Source File: AbstractConverter.java    From OWL2VOWL with MIT License 5 votes vote down vote up
private void processDataProperties(OWLOntology ontology, VowlData vowlData) {
	for (OWLDataProperty property : ontology.dataPropertiesInSignature(Imports.INCLUDED)
			.collect(Collectors.toSet())) {
		for (OWLDataPropertyAxiom propertyAxiom : ontology.axioms(property, Imports.INCLUDED)
				.collect(Collectors.toSet())) {
			try {
				propertyAxiom.accept(new DataPropertyVisitor(vowlData, property));
			} catch (Exception e) {
				logger.info("DataPropertyVisitor : Failed to accept OWLDataPropertyAxiom -> Skipping");
			}
		}
	}
}
 
Example #30
Source File: EntityCreationVisitor.java    From OWL2VOWL with MIT License 5 votes vote down vote up
@Override
public void visit(OWLDataProperty property) {
	VowlDatatypeProperty prop;

	if (!property.isAnonymous()) {
		prop = new VowlDatatypeProperty(property.getIRI());
	} else {
		// TODO anonymous behaviour
		logger.info("Anonymous OWLDataProperty " + property);
		return;
	}

	vowlData.addDatatypeProperty(prop);
}