Java Code Examples for org.semanticweb.owlapi.model.OWLDataFactory#getOWLLiteral()

The following examples show how to use org.semanticweb.owlapi.model.OWLDataFactory#getOWLLiteral() . 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: AxiomAnnotationTools.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Append xref annotations onto an existing axiom
 * 
 * @param axiom
 * @param xrefs
 * @param ontology
 * @return
 */
public static OWLAxiom appendXrefAnnotations(OWLAxiom axiom, Set<String> xrefs, OWLOntology ontology) {
    // filter existing
    Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations());
       final OWLOntologyManager manager = ontology.getOWLOntologyManager();
    final OWLDataFactory factory = manager.getOWLDataFactory();

    for (String x : xrefs) {
        OWLAnnotationProperty p = factory.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#hasDbXref"));
        OWLLiteral v = factory.getOWLLiteral(x);
        newAnnotations.add(factory.getOWLAnnotation(p, v));
    }
    final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology);
    return newAxiom;
}
 
Example 2
Source File: OWLGraphWrapperBasic.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void addCommentToOntology(OWLOntology ont, String cmt) {
	OWLDataFactory df = getDataFactory();
	OWLAnnotationProperty p = 
			df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI());
	OWLLiteral v = df.getOWLLiteral(cmt);
	OWLAnnotation ann = df.getOWLAnnotation(p, v);
	AddOntologyAnnotation addAnn = 
			new AddOntologyAnnotation(ont, ann);
	getManager().applyChange(addAnn);
}
 
Example 3
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Convenience method for adding an annotation assertion to the
 * ontology itself, taking a CURIE for the property and an Boolean literal.
 *
 * @param ontology the current ontology
 * @param propertyCURIE will be expanded to the full annotation
 *	property IRI
 * @param value the literal value of the annotation
 * @return the annotation axiom
 */
protected static OWLAnnotation annotate(OWLOntology ontology,
		String propertyCURIE, String value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	IRI iri = format.getIRI(propertyCURIE);
	OWLAnnotationProperty property =
		dataFactory.getOWLAnnotationProperty(iri);
	OWLLiteral literal = dataFactory.getOWLLiteral(value);
	OWLAnnotation annotation = dataFactory.getOWLAnnotation(
			property, literal);
	manager.applyChange(
		new AddOntologyAnnotation(ontology, annotation));
	return annotation;
}
 
Example 4
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Add an synonym annotation, plus an annotation on that annotation
 * that specified the type of synonym. The second annotation has the
 * property oio:hasSynonymType.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param typeCURIE a CURIE string for the type of synonym
 * @param propertyCURIE a CURIE string for the property
 * @param value the string value of the synonym
 * @return the axiom
 */
protected static OWLAnnotationAssertionAxiom synonym(
		OWLOntology ontology, OWLEntity subject,
		String typeCURIE, String propertyCURIE, String value) {
	OWLDataFactory dataFactory = ontology.getOWLOntologyManager().
		getOWLDataFactory();
	IRI type = format.getIRI(typeCURIE);
	OWLAnnotationProperty property =
		dataFactory.getOWLAnnotationProperty(
			format.getIRI(propertyCURIE));
	OWLLiteral literal = dataFactory.getOWLLiteral(value);
	return synonym(ontology, subject, type, property, literal);
}
 
Example 5
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Convenience method for adding an annotation assertion to the
 * ontology, taking a CURIE for the property and a string literal.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param propertyCURIE will be expanded to the full annotation
 *	property IRI
 * @param value the literal value of the annotation
 * @return the annotation axiom
 */
protected static OWLAnnotationAssertionAxiom annotate(
		OWLOntology ontology, OWLEntity subject,
		String propertyCURIE, String value) {
	OWLDataFactory dataFactory = ontology.getOWLOntologyManager().
		getOWLDataFactory();
	OWLLiteral literal = dataFactory.getOWLLiteral(value);
	return annotate(ontology, subject, propertyCURIE, literal);
}
 
Example 6
Source File: OWLConverter.java    From owltools with BSD 3-Clause "New" or "Revised" License 3 votes vote down vote up
/**
 * Convenience method for adding an annotation assertion to the
 * ontology, taking a CURIE for the property and an Boolean literal.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param propertyCURIE will be expanded to the full annotation
 *	property IRI
 * @param value the literal value of the annotation
 * @return the annotation axiom
 */
protected static OWLAnnotationAssertionAxiom annotate(
		OWLOntology ontology, OWLEntity subject,
		String propertyCURIE, boolean value) {
	OWLDataFactory dataFactory = ontology.getOWLOntologyManager().
		getOWLDataFactory();
	OWLLiteral literal = dataFactory.getOWLLiteral(value);
	return annotate(ontology, subject, propertyCURIE, literal);
}