Java源码示例:org.semanticweb.owlapi.model.OWLDataProperty
示例1
@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);
}
}
示例2
@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);
}
}
示例3
@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;
}
示例4
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()));
}
}
示例5
/**
* .
*/
public static DataProperty mobiDataProperty(OWLDataProperty property) {
if (property == null) {
return null;
}
return new SimpleDataProperty(mobiIRI(property.getIRI()));
}
示例6
/**
* .
*/
public static OWLDataProperty owlapiDataProperty(DataProperty property) {
if (property == null) {
return null;
}
return new OWLDataPropertyImpl(owlapiIRI(property.getIRI()));
}
示例7
@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());
}
示例8
@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"));
}
示例9
@Override
public Node<OWLDataProperty> getBottomDataPropertyNode() {
LOGGER_.trace("getBottomDataPropertyNode()");
checkInterrupted();
// TODO Provide implementation
throw unsupportedOwlApiMethod("getBottomDataPropertyNode()");
}
示例10
@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)");
}
示例11
@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)");
}
示例12
@Override
public NodeSet<OWLDataProperty> getDisjointDataProperties(
OWLDataPropertyExpression arg0)
throws InconsistentOntologyException, FreshEntitiesException,
ReasonerInterruptedException, TimeOutException {
LOGGER_.trace("getDisjointDataProperties(OWLDataPropertyExpression)");
checkInterrupted();
// TODO Provide implementation
throw unsupportedOwlApiMethod(
"getDisjointDataProperties(OWLDataPropertyExpression)");
}
示例13
@Override
public Node<OWLDataProperty> getEquivalentDataProperties(
OWLDataProperty arg0)
throws InconsistentOntologyException, FreshEntitiesException,
ReasonerInterruptedException, TimeOutException {
LOGGER_.trace("getEquivalentDataProperties(OWLDataProperty)");
checkInterrupted();
// TODO Provide implementation
throw unsupportedOwlApiMethod(
"getEquivalentDataProperties(OWLDataProperty)");
}
示例14
@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)");
}
示例15
@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)");
}
示例16
@Override
public Node<OWLDataProperty> getTopDataPropertyNode() {
LOGGER_.trace("getTopDataPropertyNode()");
checkInterrupted();
// TODO Provide implementation
throw unsupportedOwlApiMethod("getTopDataPropertyNode()");
}
示例17
@Override
public ElkObjectPropertyExpression visit(OWLDataProperty property) {
throw new IllegalArgumentException("invers of "
+ property.getClass().getSimpleName()
+ " cannot be converted to "
+ ElkObjectPropertyExpression.class.getSimpleName());
}
示例18
@Override
public ElkObjectPropertyExpression visit(OWLDataProperty property) {
throw new IllegalArgumentException(
OWLDataProperty.class.getSimpleName()
+ " cannot be converted to "
+ ElkObjectPropertyExpression.class.getSimpleName());
}
示例19
@Override
public ElkObjectPropertyExpression visit(OWLAnnotationProperty property) {
throw new IllegalArgumentException(
OWLDataProperty.class.getSimpleName()
+ " cannot be converted to "
+ ElkObjectPropertyExpression.class.getSimpleName());
}
示例20
@Override
public OWLDataProperty convert(ElkDataProperty input) {
if (input instanceof ElkDataPropertyWrap<?>) {
return ((ElkDataPropertyWrap<?>) input).getOwlObject();
}
// else
return visit(input);
}
示例21
/** 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)));
}
示例22
/**
* 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;
}
示例23
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");
}
}
}
}
示例24
@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);
}
示例25
public NodeSet<OWLDataProperty> getSubDataProperties(OWLDataProperty pe,
boolean direct) throws InconsistentOntologyException,
FreshEntitiesException, ReasonerInterruptedException,
TimeOutException {
// TODO Auto-generated method stub
return null;
}
示例26
public NodeSet<OWLDataProperty> getSuperDataProperties(OWLDataProperty pe,
boolean direct) throws InconsistentOntologyException,
FreshEntitiesException, ReasonerInterruptedException,
TimeOutException {
// TODO Auto-generated method stub
return null;
}
示例27
public NodeSet<OWLDataProperty> getDisjointDataProperties(
OWLDataPropertyExpression pe) throws InconsistentOntologyException,
FreshEntitiesException, ReasonerInterruptedException,
TimeOutException {
// TODO Auto-generated method stub
return null;
}
示例28
public NodeSet<OWLClass> getDataPropertyDomains(OWLDataProperty pe,
boolean direct) throws InconsistentOntologyException,
FreshEntitiesException, ReasonerInterruptedException,
TimeOutException {
// TODO Auto-generated method stub
return null;
}
示例29
public Set<OWLLiteral> getDataPropertyValues(OWLNamedIndividual ind,
OWLDataProperty pe) throws InconsistentOntologyException,
FreshEntitiesException, ReasonerInterruptedException,
TimeOutException {
// TODO Auto-generated method stub
return null;
}
示例30
@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;
}