Java 类org.semanticweb.owlapi.model.OWLAnnotationAxiom 实例源码

项目:owltools    文件:NCBI2OWLTest.java   
private void testExactSynonym(OWLOntology ontology) {
    IRI iri = IRI.create("http://www.geneontology.org/formats/oboInOwl#hasExactSynonym");
    OWLDataFactory df = ontology.getOWLOntologyManager().
        getOWLDataFactory();
    OWLAnnotationProperty property = df.getOWLAnnotationProperty(iri);
    assertTrue("Exact Synonym property in signature",
        ontology.containsAnnotationPropertyInSignature(iri));

    // Check axioms
    Set<OWLAnnotationAxiom> axioms = ontology.getAxioms(property, Imports.EXCLUDED);
    assertEquals("Count class axioms", 0, axioms.size());

    // Check annotations
    List<String> values = new ArrayList<String>();
    values.add("AnnotationAssertion(rdfs:label <http://www.geneontology.org/formats/oboInOwl#hasExactSynonym> \"has_exact_synonym\"^^xsd:string)");

    Set<OWLAnnotationAssertionAxiom> annotations = 
        ontology.getAnnotationAssertionAxioms(iri);
    assertEquals("Count annotations for Exact", 1, annotations.size());

    checkAnnotations(annotations, values);
}
项目:gate-semano    文件:OntologyParser.java   
/**
 * used by the plugin itself
 * stores the annotation value in the ontology manager, so that the next time the ontology is flushed, the annotation value is written into the file.
 *
 * @param av AnnotationValue
 */
public void addAnnotationPropertyValue(AnnotationValue av) {
    try {
        OWLEntity entityClass = getEntity(av.getAnnotatedEntity());
        OWLOntology o = entities2Ontologies.get(entityClass);
        if (o != null && entityClass != null) {
            Set<OWLAnnotationProperty> uris = getAnnotationPropertyUris(av.getAnnotationProperty());
            OWLDataFactory f = manager.getOWLDataFactory();
            OWLLiteral litValue = f.getOWLTypedLiteral(av.formatMetaData());
            for (OWLAnnotationProperty u : uris) {
                // do not store the same value several times:
                boolean found = false;
                for (OWLAnnotation a : entityClass.getAnnotations(o, u)) {

                    if ((new AnnotationValue(u.getIRI()
                            .toString(), entityClass.getIRI().toString(), a.getValue().toString())).contentEquals(av)) {
                        found = true;
                    }
                }
                if (!found) {
                    OWLAnnotation annotation = f.getOWLAnnotation(u, litValue);
                    OWLAnnotationAxiom ax = f.getOWLAnnotationAssertionAxiom(entityClass
                            .getIRI(), annotation);
                    manager.applyChange(new AddAxiom(o, ax));
                    modifiedOntologies.add(o);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}
项目:owlbuilder    文件:Owlbuilder.java   
public void initializeMiscObjProperty(OWLObjectPropertyExpression prope){
    final OWLOntologyManager manager = testWrapper.getManager();
    final OWLDataFactory factory = getDataFactory();
    Set<OWLObjectPropertyAxiom> propertyAxioms =  mergedSources.getAxioms(prope,org.semanticweb.owlapi.model.parameters.Imports.INCLUDED);
    if (propertyAxioms.isEmpty()){
        for (OWLObjectProperty p : prope.getObjectPropertiesInSignature()){
            if (PropertyBean.isSourceIdCached(p.getIRI().toString())){
                PropertyBean pb = PropertyBean.getSourceIdCached(p.getIRI().toString());
                OWLAnnotationProperty labelProperty = factory.getRDFSLabel();
                OWLAnnotationValue labelValue = factory.getOWLLiteral(pb.getLabel());
                OWLAnnotation labelAnnotation = factory.getOWLAnnotation(labelProperty, labelValue);
                OWLAnnotationAxiom labelAxiom = factory.getOWLAnnotationAssertionAxiom(p.getIRI(), labelAnnotation);
                manager.addAxiom(target,labelAxiom);
            }
            else {
                log.warn("Couldn't find propertybean for IRI " + p.getIRI().toString());
            }

        }
    }
    else{
        log.debug("Adding axioms for " + prope.toString());
        manager.addAxioms(target, propertyAxioms);
    }
    //log.info("Annotations");
    if (prope instanceof OWLObjectProperty){
        OWLObjectProperty prop = (OWLObjectProperty) prope;

            Set<OWLAnnotationAssertionAxiom> termAnnotations =
                    mergedSources.getAnnotationAssertionAxioms(prop.getIRI());
            for (OWLAnnotationAssertionAxiom a : termAnnotations){
            //log.info("   Annotation Axiom: " + a.toString());
            if (a.getAnnotation().getProperty().isLabel()){
                manager.addAxiom(target, a);
            }
        }
    }
}
项目:elk-reasoner    文件:OwlConverter.java   
@SuppressWarnings("static-method")
public ElkAnnotationAxiom convert(OWLAnnotationAxiom owlAnnotationAxiom) {
    return owlAnnotationAxiom.accept(OWL_ANNOTATION_AXIOM_CONVERTER);
}
项目:gate-semano    文件:OntologyParser.java   
/**
 * used to implement the generic API and is called to write Data to Ontology
 * stores the annotation value in the ontology manager, so that the next time the ontology is flushed, the annotation value is written into the file.
 *
 * @param theResourceURI
 * @param theAnnotationPropertyURI
 * @param value1
 * @param language
 */
public boolean addAnnotationPropertyValue(String theResourceURI,
                                          String theAnnotationPropertyURI, String value1, String language) {
    try {
        OWLEntity clas = getEntity(theResourceURI);
        OWLOntology o = entities2Ontologies.get(clas);
        if (o != null && clas != null) {
            Set<OWLAnnotationProperty> uris = getAnnotationPropertyUris(theAnnotationPropertyURI);
            OWLDataFactory f = manager.getOWLDataFactory();
            String value = AnnotationValue.formatWithLanguageOnly(value1, language);
            OWLLiteral litValue = f.getOWLTypedLiteral(value);
            for (OWLAnnotationProperty u : uris) {
                Set<OWLAnnotation> allAnnotationsOfClas = new HashSet<OWLAnnotation>();
                for (OWLOntology ox : ontologies) {
                    allAnnotationsOfClas.addAll(clas.getAnnotations(ox, u));
                }
                // do not store the same value several times:
                boolean found = false;
                for (OWLAnnotation a : allAnnotationsOfClas) {
                    //compare the annotation property, the entity, the language and the value
                    AnnotationValue av = new AnnotationValue(a.getProperty().getIRI()
                            .toString(), clas.getIRI().toString(), a.getValue().toString());
                    AnnotationValue newav = new AnnotationValue(theAnnotationPropertyURI, clas.getIRI().toString(), value);
                    if (av.contentEquals(newav)) {
                        found = true;
                    }
                }
                if (!found) {
                    OWLAnnotation annotation = f.getOWLAnnotation(u, litValue);
                    OWLAnnotationAxiom ax = f.getOWLAnnotationAssertionAxiom(clas
                            .getIRI(), annotation);
                    manager.applyChange(new AddAxiom(o, ax));
                    modifiedOntologies.add(o);
                    return true;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
项目:java-skos-api    文件:SKOSAnnotationAssertionImpl.java   
public OWLAnnotationAxiom getAssertionAxiom() {
    return ax;
}