use of org.apache.clerezza.commons.rdf.ImmutableGraph in project stanbol by apache.
the class SessionResource method asOntologyGraph.
@GET
@Produces(value = { APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON })
public Response asOntologyGraph(@PathParam(value = "id") String sessionId, @PathParam("scopeid") String scopeid, @DefaultValue("false") @QueryParam("merge") boolean merge, @Context HttpHeaders headers) {
session = sesMgr.getSession(sessionId);
if (session == null)
return Response.status(NOT_FOUND).build();
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/");
// Export to Clerezza ImmutableGraph, which can be rendered as JSON-LD.
ResponseBuilder rb = Response.ok(session.export(ImmutableGraph.class, merge, prefix));
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.clerezza.commons.rdf.ImmutableGraph in project stanbol by apache.
the class ScopeResource method getCoreSpaceGraph.
@GET
@Path("/core")
@Produces(value = { APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON })
public Response getCoreSpaceGraph(@PathParam("scopeid") String scopeid, @DefaultValue("false") @QueryParam("merge") boolean merge, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
scope = onm.getScope(scopeid);
OntologySpace space = scope.getCoreSpace();
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
ImmutableGraph o = space.export(ImmutableGraph.class, merge, prefix);
ResponseBuilder rb = Response.ok(o);
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.clerezza.commons.rdf.ImmutableGraph in project stanbol by apache.
the class ScopeResource method getCustomSpaceGraph.
@GET
@Path("/custom")
@Produces(value = { APPLICATION_JSON, N3, N_TRIPLE, RDF_JSON })
public Response getCustomSpaceGraph(@PathParam("scopeid") String scopeid, @DefaultValue("false") @QueryParam("merge") boolean merge, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
scope = onm.getScope(scopeid);
OntologySpace space = scope.getCustomSpace();
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
ImmutableGraph o = space.export(ImmutableGraph.class, merge, prefix);
ResponseBuilder rb = Response.ok(o);
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.clerezza.commons.rdf.ImmutableGraph in project stanbol by apache.
the class SessionResource method managedOntologyGetMixed.
/**
* Gets the ontology with the given identifier in its version managed by the session.
*
* @param sessionId
* the session identifier.
* @param ontologyId
* the ontology identifier.
* @param uriInfo
* @param headers
* @return the requested managed ontology, or {@link Status#NOT_FOUND} if either the sessionn does not
* exist, or the if the ontology either does not exist or is not managed.
*/
@GET
@Path(value = "/{ontologyId:.+}")
@Produces(value = { RDF_XML, TURTLE, X_TURTLE })
public Response managedOntologyGetMixed(@PathParam("id") String sessionId, @PathParam("ontologyId") String ontologyId, @DefaultValue("false") @QueryParam("merge") boolean merge, // @Context UriInfo uriInfo,
@Context HttpHeaders headers) {
ResponseBuilder rb;
session = sesMgr.getSession(sessionId);
if (session == null)
rb = Response.status(NOT_FOUND);
else {
IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/");
OWLOntologyID id = OntologyUtils.decode(ontologyId);
if (merge) {
ImmutableGraph g = session.getOntology(id, ImmutableGraph.class, merge, prefix);
rb = (g != null) ? Response.ok(g) : Response.status(NOT_FOUND);
} else {
OWLOntology o = session.getOntology(id, OWLOntology.class, merge, prefix);
rb = (o != null) ? Response.ok(o) : Response.status(NOT_FOUND);
}
}
// addCORSOrigin(servletContext, rb, headers);
return rb.build();
}
use of org.apache.clerezza.commons.rdf.ImmutableGraph in project stanbol by apache.
the class ExistingClerezzaGraphTest method initYard.
@BeforeClass
public static final void initYard() {
initTestData();
//create the graphs in Clerezza
tcManager = TcManager.getInstance();
Graph graph = tcManager.createGraph(READ_WRITEGRAPH_URI);
//add the test data to the MGrpah
for (Graph tc : entityData.values()) {
graph.addAll(tc);
}
//create the read only graph
tcManager.createImmutableGraph(READ_ONLY_GRAPH_URI, graph);
//init the ClerezzaYards for the created Clerezza graphs
ClerezzaYardConfig readWriteConfig = new ClerezzaYardConfig("readWriteYardId");
readWriteConfig.setName("Clerezza read/write Yard");
readWriteConfig.setDescription("Tests config with pre-existing Graph");
readWriteConfig.setGraphUri(READ_WRITEGRAPH_URI);
readwriteYard = new ClerezzaYard(readWriteConfig);
ClerezzaYardConfig readOnlyYardConfig = new ClerezzaYardConfig("readOnlyYardId");
readOnlyYardConfig.setName("Clerezza read-only Yard");
readOnlyYardConfig.setDescription("Tests config with pre-existing ImmutableGraph");
readOnlyYardConfig.setGraphUri(READ_ONLY_GRAPH_URI);
readonlyYard = new ClerezzaYard(readOnlyYardConfig);
}
Aggregations