org.semanticweb.owlapi.model.OWLAnonymousIndividual Java Examples

The following examples show how to use org.semanticweb.owlapi.model.OWLAnonymousIndividual. 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: SimpleOntologyValues.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * .
 */
public static Annotation mobiAnnotation(OWLAnnotation owlAnno) {
    // TODO: ??? Fix this.
    if (owlAnno == null) {
        return null;
    }

    AnnotationProperty property = mobiAnnotationProperty(owlAnno.getProperty());
    OWLAnnotationValue value = owlAnno.getValue();
    if (value instanceof OWLLiteral) {
        OWLLiteral literal = (OWLLiteral) value;
        Literal simpleLiteral = mobiLiteral(literal);
        return new SimpleAnnotation(property, simpleLiteral);
    } else if (value instanceof org.semanticweb.owlapi.model.IRI) {
        org.semanticweb.owlapi.model.IRI iri = (org.semanticweb.owlapi.model.IRI) value;
        IRI simpleIri = mobiIRI(iri);
        return new SimpleAnnotation(property, simpleIri);
    } else if (value instanceof OWLAnonymousIndividual) {
        OWLAnonymousIndividual individual = (OWLAnonymousIndividual) value;
        Individual simpleIndividual = mobiIndividual(individual);
        return new SimpleAnnotation(property, simpleIndividual);
    } else {
        throw new OWLRuntimeException("Invalid annotation value");
    }
}
 
Example #2
Source File: SimpleOntologyValues.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * .
 */
public static OWLAnnotation owlapiAnnotation(Annotation anno) {
    // TODO: ??? Fix this.
    if (anno == null) {
        return null;
    }
    OWLAnnotationProperty owlAnnoProperty = owlapiAnnotationProperty(anno.getProperty());
    Value value = anno.getValue();
    if (value instanceof IRI) {
        org.semanticweb.owlapi.model.IRI iri = owlapiIRI((IRI) value);
        return new OWLAnnotationImpl(owlAnnoProperty, iri, Stream.empty());
    } else if (value instanceof Literal) {
        OWLLiteral literal = owlapiLiteral((Literal) value);
        return new OWLAnnotationImpl(owlAnnoProperty, literal, Stream.empty());
    } else if (value instanceof SimpleIndividual) {
        OWLIndividual individual = owlapiIndividual((SimpleIndividual) value);
        return new OWLAnnotationImpl(owlAnnoProperty, (OWLAnonymousIndividual) individual, Stream.empty());
    } else {
        throw new MobiOntologyException("Invalid annotation value");
    }
}
 
Example #3
Source File: QueryArgument.java    From sparql-dl-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getValueAsString() {
    if (value instanceof IRI) {
        return value.toString();
    }
    else if (value instanceof OWLLiteral) {
        return ((OWLLiteral) value).getLiteral();
    }
    else if (value instanceof OWLAnonymousIndividual) {
        return ((OWLAnonymousIndividual) value).getID().toString();
    }
    else if (value instanceof Var) {
        return ((Var) value).getName();
    }
    else {
        return value.toString();
    }
}
 
Example #4
Source File: ModelAnnotationSolrDocumentLoader.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private OWLNamedIndividual findEvidenceIndividual(OWLAnnotationValue value) {
	return value.accept(new OWLAnnotationValueVisitorEx<OWLNamedIndividual>() {

		@Override
		public OWLNamedIndividual visit(final IRI iri) {
			OWLNamedIndividual i = null;
			for(OWLNamedIndividual current : model.getIndividualsInSignature()) {
				if (current.getIRI().equals(iri)) {
					i = current;
					break;
				}
			}
			return i;
		}

		@Override
		public OWLNamedIndividual visit(OWLAnonymousIndividual individual) {
			return null;
		}

		@Override
		public OWLNamedIndividual visit(OWLLiteral literal) {
			return null;
		}
	});
}
 
Example #5
Source File: QueryArgumentTest.java    From sparql-dl-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testIsBnode() 
{
	QueryArgument arg = new QueryArgument(mock(OWLAnonymousIndividual.class));
	assertTrue(arg.isBnode());
	QueryArgument arg2 = new QueryArgument(new Var("x"));
	assertFalse(arg2.isBnode());
}
 
Example #6
Source File: Mooncat.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLObject> findTaggedEntities(OWLAnnotationProperty p, Set<OWLAnnotationValue> values, final OWLGraphWrapper graph) {
	if (p == null || values == null || values.isEmpty()) {
		return Collections.emptySet();
	}
	final Set<OWLObject> entities = new HashSet<OWLObject>();
	Set<OWLOntology> allOntologies = graph.getAllOntologies();
	for (OWLOntology ontology : allOntologies) {
		Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAxioms(AxiomType.ANNOTATION_ASSERTION);
		for (OWLAnnotationAssertionAxiom axiom : axioms) {
			if (p.equals(axiom.getProperty()) && values.contains(axiom.getValue())) {
				axiom.getSubject().accept(new OWLAnnotationSubjectVisitor(){

					@Override
					public void visit(IRI iri) {
						OWLObject owlObject = graph.getOWLObject(iri);
						if (owlObject != null) {
							entities.add(owlObject);
						}
					}

					@Override
					public void visit(OWLAnonymousIndividual individual) {
						// do nothing
					}
				});
			}
		}
	}
	return entities;
}
 
Example #7
Source File: OwlApiUtils.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
public static String getIri(OWLIndividual individual) {
  if (individual.isAnonymous()) {
    return ((OWLAnonymousIndividual)individual).getID().getID();
  } else {
    return individual.asOWLNamedIndividual().getIRI().toString();
  }
}
 
Example #8
Source File: QueryArgument.java    From sparql-dl-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public QueryArgument(OWLAnonymousIndividual value) {
    this.type = QueryArgumentType.BNODE;
    this.value = value;
}
 
Example #9
Source File: QueryArgument.java    From sparql-dl-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public OWLAnonymousIndividual getValueAsBNode() {
    return (OWLAnonymousIndividual) value;
}
 
Example #10
Source File: AbstractElkObjectConverter.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Override
public OWLAnonymousIndividual visit(ElkAnonymousIndividual expression) {
	return owlFactory_.getOWLAnonymousIndividual(expression.getNodeId());
}
 
Example #11
Source File: OwlConverter.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-method")
public ElkAnonymousIndividual convert(
		OWLAnonymousIndividual owlAnonymousIndividual) {
	return new ElkAnonymousIndividualWrap<OWLAnonymousIndividual>(
			owlAnonymousIndividual);
}
 
Example #12
Source File: OwlIndividualConverterVisitor.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Override
public ElkAnonymousIndividual visit(
		OWLAnonymousIndividual owlAnonymousIndividual) {
	return CONVERTER.convert(owlAnonymousIndividual);
}
 
Example #13
Source File: OwlAnnotationSubjectValueVisitor.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Override
public ElkAnonymousIndividual visit(OWLAnonymousIndividual anon) {
	return CONVERTER.convert(anon);
}
 
Example #14
Source File: LegoMetadata.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public String visit(OWLAnonymousIndividual individual) {
	return null;
}
 
Example #15
Source File: GraphOwlVisitor.java    From SciGraph with Apache License 2.0 4 votes vote down vote up
@Override
public Void visit(OWLAnnotationAssertionAxiom axiom) {
  if ((axiom.getSubject() instanceof IRI)
      || (axiom.getSubject() instanceof OWLAnonymousIndividual)) {
    long subject = 0L;
    if (axiom.getSubject() instanceof IRI) {
      subject = getOrCreateNode(((IRI) axiom.getSubject()).toString());
    } else if (axiom.getSubject() instanceof OWLAnonymousIndividual) {
      subject = getOrCreateNode(OwlApiUtils.getIri((OWLAnonymousIndividual) axiom.getSubject()));
    }

    String property = getIri(axiom.getProperty()).toString();
    if (axiom.getValue() instanceof OWLLiteral) {
      Optional<Object> literal =
          OwlApiUtils.getTypedLiteralValue((OWLLiteral) (axiom.getValue()));
      if (literal.isPresent()) {
        graph.addNodeProperty(subject, property, literal.get());
        if (mappedProperties.containsKey(property)) {
          graph.addNodeProperty(subject, mappedProperties.get(property), literal.get());
        }
      }
    } else if ((axiom.getValue() instanceof IRI)
        || (axiom.getValue() instanceof OWLAnonymousIndividual)) {
      long object = 0L;
      if (axiom.getValue() instanceof IRI) {
        object = getOrCreateNode(((IRI) axiom.getValue()).toString());
      } else if (axiom.getValue() instanceof OWLAnonymousIndividual) {
        object = getOrCreateNode(OwlApiUtils.getIri((OWLAnonymousIndividual) axiom.getValue()));
      }
      long assertion =
          getOrCreateRelationship(subject, object, RelationshipType.withName(property));
      graph.setRelationshipProperty(assertion, CommonProperties.IRI, property);
      graph.setRelationshipProperty(assertion, CommonProperties.OWL_TYPE,
          OwlRelationships.OWL_ANNOTATION.name());
    } else {
      logger.info("Ignoring assertion axiom: " + axiom);
    }
  } else {
    logger.info("Ignoring assertion axiom: " + axiom);
  }
  return null;
}
 
Example #16
Source File: QueryArgument.java    From sparql-dl-api with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Factory method to create a QueryArgument instance with type BNODE by string.
 *
 * @param value
 * @return
 */
public static QueryArgument newBnode(OWLAnonymousIndividual value) {
    return new QueryArgument(value);
}