Package org.apache.stanbol.ontologymanager.servicesapi.scope

Examples of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace


        } catch (DuplicateIDException e) {
            scope = onManager.getScope(scopeId);
            onManager.setScopeActive(scopeId, false);
        }
        // All resolvable ontologies stated in the configuration are loaded into the core space.
        OntologySpace ontologySpace = scope.getCoreSpace();
        ontologySpace.tearDown();
        String[] coreScopeOntologySet = engineConfiguration.getScopeCoreOntologies();
        List<String> success = new ArrayList<String>(), failed = new ArrayList<String>();
        try {
            log.info("Will now load requested ontology into the core space of scope '{}'.", scopeId);
            OWLOntologyManager sharedManager = OWLManager.createOWLOntologyManager();
            IRI physicalIRI = null;
            for (int o = 0; o < coreScopeOntologySet.length; o++) {
                String url = coreScopeOntologySet[o];
                try {
                    physicalIRI = IRI.create(url);
                } catch (Exception e) {
                    failed.add(url);
                }
                try {
                    // TODO replace with a Clerezza equivalent
                    ontologySpace.addOntology(new RootOntologySource(physicalIRI, sharedManager));
                    success.add(url);
                } catch (OWLOntologyCreationException e) {
                    log.error("Failed to load ontology from physical location " + physicalIRI
                              + " Continuing with next...", e);
                    failed.add(url);
                }
            }
        } catch (UnmodifiableOntologyCollectorException ex) {
            log.error("Ontology space {} was found locked for modification. Cannot populate.", ontologySpace);
        }
        for (String s : success)
            log.info(" >> {} : SUCCESS", s);
        for (String s : failed)
            log.info(" >> {} : FAILED", s);
        ontologySpace.setUp();
        // if (!onManager.containsScope(scopeId)) onManager.registerScope(scope);
        onManager.setScopeActive(scopeId, true);

        /*
         * The first thing to do is to create a recipe in the rule store that can be used by the engine to
View Full Code Here


    @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) {
        OntologySpace space = scope.getCoreSpace();
        IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
        Graph o = space.export(Graph.class, merge, prefix);
        ResponseBuilder rb = Response.ok(o);
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

    @Produces(value = {RDF_XML, TURTLE, X_TURTLE, MANCHESTER_OWL, FUNCTIONAL_OWL, OWL_XML, TEXT_PLAIN})
    public Response getCoreSpaceOWL(@PathParam("scopeid") String scopeid,
                                    @DefaultValue("false") @QueryParam("merge") boolean merge,
                                    @Context UriInfo uriInfo,
                                    @Context HttpHeaders headers) {
        OntologySpace space = scope.getCoreSpace();
        IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
        OWLOntology o = space.export(OWLOntology.class, merge, prefix);
        ResponseBuilder rb = Response.ok(o);
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

    @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) {
        OntologySpace space = scope.getCustomSpace();
        IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
        Graph o = space.export(Graph.class, merge, prefix);
        ResponseBuilder rb = Response.ok(o);
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

    @Produces(value = {RDF_XML, TURTLE, X_TURTLE, MANCHESTER_OWL, FUNCTIONAL_OWL, OWL_XML, TEXT_PLAIN})
    public Response getCustomSpaceOWL(@PathParam("scopeid") String scopeid,
                                      @DefaultValue("false") @QueryParam("merge") boolean merge,
                                      @Context UriInfo uriInfo,
                                      @Context HttpHeaders headers) {
        OntologySpace space = scope.getCustomSpace();
        IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
        OWLOntology o = space.export(OWLOntology.class, merge, prefix);
        ResponseBuilder rb = Response.ok(o);
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

        if (scope == null) rb = Response.status(NOT_FOUND);
        else {
            IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
            Graph o = null;
            OWLOntologyID id = OntologyUtils.decode(ontologyId);
            OntologySpace spc = scope.getCustomSpace();
            if (spc != null && spc.hasOntology(id)) {
                o = spc.getOntology(id, Graph.class, merge, prefix);
            } else {
                spc = scope.getCoreSpace();
                if (spc != null && spc.hasOntology(id)) o = spc.getOntology(id, Graph.class, merge, prefix);
            }
            if (o == null) rb = Response.status(NOT_FOUND);
            else rb = Response.ok(o);
        }
View Full Code Here

        if (scope == null) rb = Response.status(NOT_FOUND);
        else {
            IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/ontology/");
            OWLOntology o = null;
            OWLOntologyID id = OntologyUtils.decode(ontologyId);
            OntologySpace spc = scope.getCustomSpace();
            if (spc != null && spc.hasOntology(id)) {
                o = spc.getOntology(id, OWLOntology.class, merge, prefix);
            } else {
                spc = scope.getCoreSpace();
                if (spc != null && spc.hasOntology(id)) o = spc.getOntology(id, OWLOntology.class, merge,
                    prefix);
            }
            if (o == null) rb = Response.status(NOT_FOUND);
            else rb = Response.ok(o);
        }
View Full Code Here

                                          @Context UriInfo uriInfo,
                                          @Context HttpHeaders headers) {
        ResponseBuilder rb;
        if (ontologyId != null && !ontologyId.trim().isEmpty()) {
            OWLOntologyID id = OntologyUtils.decode(ontologyId);
            OntologySpace cs = scope.getCustomSpace();
            if (!cs.hasOntology(id)) rb = Response.notModified(); // ontology not managed
            else try {
                onm.setScopeActive(scopeId, false);
                cs.removeOntology(id);
                rb = Response.ok();
            } catch (IrremovableOntologyException e) {
                throw new WebApplicationException(e, FORBIDDEN);
            } catch (UnmodifiableOntologyCollectorException e) {
                throw new WebApplicationException(e, FORBIDDEN);
View Full Code Here

TOP

Related Classes of org.apache.stanbol.ontologymanager.servicesapi.scope.OntologySpace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.