Search in sources :

Example 16 with ImmutableGraph

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();
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) ImmutableGraph(org.apache.clerezza.commons.rdf.ImmutableGraph) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 17 with ImmutableGraph

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();
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) OntologySpace(org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) ImmutableGraph(org.apache.clerezza.commons.rdf.ImmutableGraph) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 18 with ImmutableGraph

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();
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) OntologySpace(org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) ImmutableGraph(org.apache.clerezza.commons.rdf.ImmutableGraph) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 19 with ImmutableGraph

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();
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) ImmutableGraph(org.apache.clerezza.commons.rdf.ImmutableGraph) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 20 with ImmutableGraph

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);
}
Also used : ImmutableGraph(org.apache.clerezza.commons.rdf.ImmutableGraph) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) Graph(org.apache.clerezza.commons.rdf.Graph) BeforeClass(org.junit.BeforeClass)

Aggregations

ImmutableGraph (org.apache.clerezza.commons.rdf.ImmutableGraph)25 Graph (org.apache.clerezza.commons.rdf.Graph)9 IRI (org.semanticweb.owlapi.model.IRI)8 GET (javax.ws.rs.GET)7 Produces (javax.ws.rs.Produces)7 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)7 SimpleGraph (org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph)7 HashSet (java.util.HashSet)6 Path (javax.ws.rs.Path)5 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)5 Triple (org.apache.clerezza.commons.rdf.Triple)5 IRI (org.apache.clerezza.commons.rdf.IRI)4 IndexedGraph (org.apache.stanbol.commons.indexedgraph.IndexedGraph)4 Test (org.junit.Test)4 OWLOntologyID (org.semanticweb.owlapi.model.OWLOntologyID)4 InputStream (java.io.InputStream)3 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)3 TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)3 Parser (org.apache.clerezza.rdf.core.serializedform.Parser)3 OntologySpace (org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace)3