Java Code Examples for org.semanticweb.owlapi.model.IRI#equals()

The following examples show how to use org.semanticweb.owlapi.model.IRI#equals() . 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: OWLGraphWrapperExtended.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private String getOntologyAnnotationValue(OWLOntology o, OboFormatTag tag) {
	IRI dateTagIRI = Obo2Owl.trTagToIRI(tag.getTag());
	Set<OWLAnnotation> annotations = o.getAnnotations();
	for (OWLAnnotation annotation : annotations) {
		OWLAnnotationProperty property = annotation.getProperty();
		if(dateTagIRI.equals(property.getIRI())) {
			OWLAnnotationValue value = annotation.getValue();
			if (value != null) {
				if (value instanceof IRI) {
					return ((IRI) value).toString();
				}
				else if (value instanceof OWLLiteral) {
					return ((OWLLiteral) value).getLiteral();
				}
			}
		}
	}
	return null;
}
 
Example 2
Source File: OWLGraphWrapperBasic.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Merge a specific ontology from the import closure into the main ontology.
 * Removes the import statement.
 * 
 * @param ontologyIRI id of the ontology to merge
 * @throws OWLOntologyCreationException
 */
public void mergeSpecificImport(IRI ontologyIRI) throws OWLOntologyCreationException {
	OWLOntologyManager manager = getManager();
	Set<OWLOntology> imports = sourceOntology.getImportsClosure();
	for (OWLOntology o : imports) {
		if (o.equals(sourceOntology))
			continue;
		Optional<IRI> currentIRI = o.getOntologyID().getOntologyIRI();
		if (currentIRI.isPresent() && currentIRI.get().equals(ontologyIRI)) {
			String comment = "Includes "+summarizeOntology(o);
			LOG.info(comment);
			addCommentToOntology(sourceOntology, comment);
			manager.addAxioms(sourceOntology, o.getAxioms());	
		}
	}
	Set<OWLImportsDeclaration> oids = sourceOntology.getImportsDeclarations();
	for (OWLImportsDeclaration oid : oids) {
		if (ontologyIRI.equals(oid.getIRI())) {
			RemoveImport ri = new RemoveImport(sourceOntology, oid);
			getManager().applyChange(ri);
		}
	}
}
 
Example 3
Source File: AbstractNode.java    From OWL2VOWL with MIT License 5 votes vote down vote up
@Override
public void addComplement(IRI iri) {
	if (iri.equals(VowlThing.GENERIC_THING_IRI)){
		return;
	}
	complements.add(iri);
}
 
Example 4
Source File: AbstractNode.java    From OWL2VOWL with MIT License 5 votes vote down vote up
@Override
public void addElementToIntersection(IRI iri) {
	if (iri.equals(VowlThing.GENERIC_THING_IRI)){
		return;
	}
	intersectionElements.add(iri);
}
 
Example 5
Source File: AbstractNode.java    From OWL2VOWL with MIT License 5 votes vote down vote up
@Override
public void addElementToUnion(IRI iri) {
	if (iri.equals(VowlThing.GENERIC_THING_IRI)){
		return;
	}
	unionElements.add(iri);
}
 
Example 6
Source File: TemplatedTransformer.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private BindingSet unify(IRI qin, IRI var,  Set<IRI> vars) {
	BindingSet bset = new BindingSet();
	if (vars.contains(var)) {
		LOG.info(" UNIFYING: ?"+var+" = "+qin);
		bset.varMap.put(var, qin);
		return bset;
	}
	if (qin.equals(var)) {
		// no variable unification but still a match
		return bset;
	}
	return null;
}
 
Example 7
Source File: OntologyMetadataMarkdownWriter.java    From owltools with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public static String renderMarkdown(OWLGraphWrapper g, String baseDir, boolean isIncludeImage) {

		OWLOntology ont = g.getSourceOntology();
		StringBuilder out = new StringBuilder();

		String ontId = g.getOntologyId();

		Set<OWLAnnotation> oAnns = ont.getAnnotations();
		System.err.println("NUM1:"+oAnns.size());

		String title = getVal("title", oAnns);

		out.append("## Ontology: "+title+"\n\n");
		out.append("IRI: "+rurl(ont)+"\n\n");

		String desc = getVal("description", oAnns);
		out.append("### Description\n\n");
		out.append(desc+"\n\n");

		Set<OWLOntology> imports = ont.getImports();
		if (imports.size() > 0) {
			out.append("### Imports\n\n");
			for (OWLOntology im : imports) {
				out.append(" * "+rurl(im)+"\n");
			}
		}
		if (isIncludeImage) {
			String imgFn = baseDir + "/" + ontId + ".png";
			out.append("![]("+imgFn+")\n\n");
		}

		System.err.println("NUM:"+oAnns.size());
		if (oAnns.size() > 0) {
			out.append("### Annotations:\n\n");
			for (OWLAnnotation ann : oAnns) {
				String annLabel = g.getLabelOrDisplayId(ann.getProperty());
				OWLAnnotationValue v = ann.getValue();
				String dv = v.toString();
				if (v instanceof OWLLiteral) {
					OWLLiteral lv = ((OWLLiteral)v);
					dv = lv.getLiteral();
					IRI dt = lv.getDatatype().getIRI();
					//System.out.println("DT = "+dt);
					if (dt.equals(OWL2Datatype.XSD_ANY_URI.getIRI())) {
						dv = href(lv.getLiteral());
					}
				}
				out.append(" * "+href(ann.getProperty().getIRI().toString(),annLabel)+" : "+dv+"\n");
			}
		}

		return out.toString();
	}
 
Example 8
Source File: AbstractOWLOntologyLoader.java    From BioSolr with Apache License 2.0 4 votes vote down vote up
protected void evaluateAllAnnotationsValues(OWLEntity owlEntity) {

        IRI owlEntityIRI = owlEntity.getIRI();
        Set<String> synonyms = new HashSet<>();
        Set<String> definitions = new HashSet<>();
        Set<String> slims = new HashSet<>();

        // loop through other annotations in the imports closure
        for (OWLOntology ontology1 : getManager().getOntologies()) {
            for (OWLAnnotation annotation : owlEntity.getAnnotations(ontology1)) {
                OWLAnnotationProperty property = annotation.getProperty();
                IRI propertyIRI = property.getIRI();

                if (getLabelIRI().equals(propertyIRI)) {
                    addClassLabel(owlEntityIRI, evaluateLabelAnnotationValue(owlEntity, annotation.getValue()).get());
                }
                else if (getSynonymIRIs().contains(propertyIRI)) {
                    synonyms.add(getOWLAnnotationValueAsString(annotation.getValue()).get());
                }
                else if (getDefinitionIRIs().contains(propertyIRI)) {
                    definitions.add(getOWLAnnotationValueAsString(annotation.getValue()).get());
                }
                else if (propertyIRI.equals(Namespaces.OBOINOWL.createIRI("subset_property"))) {
                    slims.add(getOWLAnnotationValueAsString(annotation.getValue()).get());
                }
                else if (propertyIRI.equals(Namespaces.OWL.createIRI("deprecated"))) {
                    addObsoleteTerms(owlEntityIRI);
                }
                else {
                    if (getOWLAnnotationValueAsString(annotation.getValue()).isPresent()) {
                        // initialise maps if first time
                        if (!termAnnotations.containsKey(owlEntityIRI)) {
                            HashMap<IRI, Collection<String>> newMap = new HashMap<>();
                            newMap.put(propertyIRI, new HashSet<>());
                            termAnnotations.put(owlEntityIRI, newMap);
                        }

                        if (!termAnnotations.get(owlEntityIRI).containsKey(propertyIRI)) {
                            termAnnotations.get(owlEntityIRI).put(propertyIRI, new HashSet<>());
                        }

                        termAnnotations.get(owlEntityIRI).get(propertyIRI).add(getOWLAnnotationValueAsString(annotation.getValue()).get());
                    }
                }

            }
        }

        if (synonyms.size() > 0) {
            addSynonyms(owlEntityIRI, synonyms);
        }
        if (definitions.size() >0) {
            addDefinitions(owlEntityIRI, definitions);
        }
        if (slims.size() >0) {
            addSlims(owlEntityIRI, slims);
        }
    }