Search in sources :

Example 1 with OntologyCollector

use of org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollector in project stanbol by apache.

the class AbstractOntologyCollectorImpl method equals.

@Override
public boolean equals(Object arg0) {
    if (arg0 == null)
        return false;
    if (!(arg0 instanceof OntologyCollector))
        return false;
    if (this == arg0)
        return true;
    log.warn("{} only implements weak equality, i.e. managed ontologies are only checked by public key, not by content.", getClass());
    OntologyCollector coll = (OntologyCollector) arg0;
    return this.getID().equals(coll.getID()) && this.getDefaultNamespace().equals(coll.getDefaultNamespace()) && this.listManagedOntologies().equals(coll.listManagedOntologies()) && this.getSupportedOntologyTypes().equals(coll.getSupportedOntologyTypes());
}
Also used : OntologyCollector(org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollector)

Example 2 with OntologyCollector

use of org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollector in project stanbol by apache.

the class GraphMultiplexer method getHandles.

@Override
public Set<OntologyCollector> getHandles(OWLOntologyID publicKey) {
    Set<OntologyCollector> handles = new HashSet<OntologyCollector>();
    Set<OWLOntologyID> aliases = listAliases(publicKey);
    aliases.add(publicKey);
    for (OWLOntologyID alias : aliases) {
        IRI ontologyId = buildResource(alias);
        for (Iterator<Triple> it = meta.filter(null, MANAGES_URIREF, ontologyId); it.hasNext(); ) {
            BlankNodeOrIRI sub = it.next().getSubject();
            if (sub instanceof IRI)
                checkHandle((IRI) sub, handles);
            else
                throw new InvalidMetaGraphStateException(sub + " is not a valid ontology collector identifer.");
        }
        for (Iterator<Triple> it = meta.filter(ontologyId, IS_MANAGED_BY_URIREF, null); it.hasNext(); ) {
            RDFTerm obj = it.next().getObject();
            if (obj instanceof IRI)
                checkHandle((IRI) obj, handles);
            else
                throw new InvalidMetaGraphStateException(obj + " is not a valid ontology collector identifer.");
        }
    }
    return handles;
// throw new UnsupportedOperationException("Not implemented yet.");
}
Also used : Triple(org.apache.clerezza.commons.rdf.Triple) IRI(org.apache.clerezza.commons.rdf.IRI) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) OntologyCollector(org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollector) OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) RDFTerm(org.apache.clerezza.commons.rdf.RDFTerm) HashSet(java.util.HashSet)

Example 3 with OntologyCollector

use of org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollector in project stanbol by apache.

the class RootResource method performShowOntology.

/**
 * Helper method to make sure a ResponseBuilder is created on every conditions, so that it is then
 * possible to enable CORS on it afterwards.
 *
 * @param ontologyId
 * @return
 */
protected ResponseBuilder performShowOntology(String ontologyId) {
    if (ontologyId == null || ontologyId.isEmpty()) {
        return Response.status(BAD_REQUEST);
    }
    OWLOntologyID key = OntologyUtils.decode(ontologyId);
    if (ontologyProvider.listOrphans().contains(key)) {
        return Response.status(NO_CONTENT);
    }
    OWLOntology o = getOWLOntology(ontologyId, false, uriInfo.getRequestUri());
    if (o == null) {
        return Response.status(NOT_FOUND);
    }
    // Assemble dependency list
    Map<OWLOntologyID, OntologyProvider.Status> deps = new HashMap<OWLOntologyID, OntologyProvider.Status>();
    for (OWLOntologyID dep : getDescriptor().getDependencies(key)) {
        deps.put(dep, ontologyProvider.getStatus(dep));
    }
    Set<OntologyCollector> handles = new HashSet<OntologyCollector>();
    if (onManager != null) {
        for (Scope scope : onManager.getRegisteredScopes()) {
            if (scope.getCoreSpace().hasOntology(key)) {
                handles.add(scope.getCoreSpace());
            }
            if (scope.getCustomSpace().hasOntology(key)) {
                handles.add(scope.getCustomSpace());
            }
        }
    }
    if (sessionManager != null) {
        for (String sesId : sessionManager.getRegisteredSessionIDs()) {
            if (sessionManager.getSession(sesId).hasOntology(key)) {
                handles.add(sessionManager.getSession(sesId));
            }
        }
    }
    return Response.ok(new Viewable("ontology", new OntologyStats(uriInfo, key, o, ontologyProvider.listAliases(key), deps, handles)));
}
Also used : Status(javax.ws.rs.core.Response.Status) HashMap(java.util.HashMap) OntologyCollector(org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollector) Scope(org.apache.stanbol.ontologymanager.servicesapi.scope.Scope) OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) OntologyProvider(org.apache.stanbol.ontologymanager.servicesapi.ontology.OntologyProvider) Viewable(org.apache.stanbol.commons.web.viewable.Viewable) HashSet(java.util.HashSet)

Aggregations

OntologyCollector (org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollector)3 HashSet (java.util.HashSet)2 OWLOntologyID (org.semanticweb.owlapi.model.OWLOntologyID)2 HashMap (java.util.HashMap)1 Status (javax.ws.rs.core.Response.Status)1 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)1 IRI (org.apache.clerezza.commons.rdf.IRI)1 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)1 Triple (org.apache.clerezza.commons.rdf.Triple)1 Viewable (org.apache.stanbol.commons.web.viewable.Viewable)1 OntologyProvider (org.apache.stanbol.ontologymanager.servicesapi.ontology.OntologyProvider)1 Scope (org.apache.stanbol.ontologymanager.servicesapi.scope.Scope)1 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)1