public Set<Session> getSessions() { Set<Session> result = new HashSet<Session>(); for (String id : sessionManager.getRegisteredSessionIDs()) result.add(sessionManager.getSession(id)); return result; }
@GET @Produces(value = {RDF_XML, OWL_XML, TURTLE, X_TURTLE, FUNCTIONAL_OWL, MANCHESTER_OWL, RDF_JSON, N3, N_TRIPLE, TEXT_PLAIN}) public Response listSessions(@Context UriInfo uriInfo, @Context HttpHeaders headers) { OWLOntologyManager ontMgr = OWLManager.createOWLOntologyManager(); OWLDataFactory df = ontMgr.getOWLDataFactory(); OWLClass cSession = df.getOWLClass(IRI.create("http://stanbol.apache.org/ontologies/meta/Session")); OWLOntology o; try { o = ontMgr.createOntology(IRI.create(uriInfo.getRequestUri())); List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); for (String id : sessionManager.getRegisteredSessionIDs()) { IRI sessionid = IRI.create(sessionManager.getDefaultNamespace() + sessionManager.getID() + "/" + id); OWLNamedIndividual ind = df.getOWLNamedIndividual(sessionid); changes.add(new AddAxiom(o, df.getOWLClassAssertionAxiom(cSession, ind))); } ontMgr.applyChanges(changes); } catch (OWLOntologyCreationException e) { throw new WebApplicationException(e, INTERNAL_SERVER_ERROR); } ResponseBuilder rb = Response.ok(o); MediaType mediaType = MediaTypeUtil.getAcceptableMediaType(headers, null); if (mediaType != null) rb.header(HttpHeaders.CONTENT_TYPE, mediaType); // addCORSOrigin(servletContext, rb, headers); return rb.build(); }
@Override public Set<String> run() { Set<String> handles = new HashSet<String>(); if (onManager != null) { for (Scope scope : onManager.getRegisteredScopes()) { if (scope.getCoreSpace().hasOntology(ontologyId) || scope.getCustomSpace().hasOntology(ontologyId)) { handles.add(scope.getID()); } } } if (sessionManager != null) { for (String sesId : sessionManager.getRegisteredSessionIDs()) { if (sessionManager.getSession(sesId).hasOntology(ontologyId)) { handles.add(sesId); } } } return handles; } });
for (String sesId : sessionManager.getRegisteredSessionIDs()) { if (sessionManager.getSession(sesId).hasOntology(key)) { handles.add(sessionManager.getSession(sesId));