Package org.apache.stanbol.ontologymanager.ontonet.api.scope

Examples of org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologySpace


        log.info("After input source creation, TcManager has {} graphs. ", tcManager.listTripleCollections()
                .size());
        for (UriRef name : tcManager.listTripleCollections())
            log.info("-- {} (a {})", name, tcManager.getTriples(name).getClass().getSimpleName());
        assertEquals(1, tcManager.listTripleCollections().size());
        OntologySpace spc = new CoreOntologySpaceImpl(TestClerezzaInputSources.class.getSimpleName(),
                IRI.create("http://stanbol.apache.org/ontologies/"), provider);
        spc.addOntology(src);
        log.info("After addition to space, TcManager has {} graphs. ", tcManager.listTripleCollections()
                .size());

        for (UriRef name : tcManager.listTripleCollections())
            log.info("-- {} (a {})", name, tcManager.getTriples(name).getClass().getSimpleName());
View Full Code Here


        } catch (DuplicateIDException e) {
            scope = scopeRegistry.getScope(scopeId);
            scopeRegistry.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 RootOntologyIRISource(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 (!scopeRegistry.containsScope(scopeId)) scopeRegistry.registerScope(scope);
        scopeRegistry.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

        // OntologyInputSource<OWLOntology> src = new OntologyContentInputSource(content,mgr);

        OWLOntology original = src.getRootOntology();

        OntologySpace spc = new CustomOntologySpaceImpl("Test", scopeNs, ontologyProvider);
        spc.addOntology(src);

    }
View Full Code Here

     * @throws Exception
     *             if an unexpected error occurs.
     */
    @Test
    public void testIdentifiers() throws Exception {
        OntologySpace shouldBeNull = null, shouldBeNotNull = null;

        /* First test space identifiers. */

        // Null identifier (invalid).
        try {
View Full Code Here

     * @throws Exception
     *             if an unexpected error occurs.
     */
    @Test
    public void testIdentifiers() throws Exception {
        OntologySpace shouldBeNull = null, shouldBeNotNull = null;

        /* First test space identifiers. */

        // Null identifier (invalid).
        try {
View Full Code Here

            // TODO: hack (ma anche no)
            if (!ontiri.isAbsolute()) ontiri = IRI.create(absur);

            // First of all, it could be a simple request for the space root!
            String temp = scopeId + "/" + ontologyId;
            OntologySpace space = scope.getCoreSpace();
            if (temp.equals(space.getID())) rb = Response.ok(space.export(Graph.class, merge));
            else {
                space = scope.getCustomSpace();
                if (temp.equals(space.getID())) rb = Response.ok(space.export(Graph.class, merge));
                else {
                    Graph o = null;
                    IRI ontologyIri = IRI.create(ontologyId);
                    OntologySpace spc = scope.getCustomSpace();
                    if (spc != null && spc.hasOntology(ontologyIri)) {
                        // o = spc.getOntology(ontologyIri, merge);
                        o = spc.getOntology(ontologyIri, Graph.class, merge);
                    } else {
                        spc = scope.getCoreSpace();
                        if (spc != null && spc.hasOntology(ontologyIri))
                        // o = spc.getOntology(ontologyIri, merge);
                        o = spc.getOntology(ontologyIri, Graph.class, merge);
                    }
                    if (o == null) return Response.status(NOT_FOUND).build();
                    else rb = Response.ok(o);
                }
            }
View Full Code Here

            // TODO: hack (ma anche no)
            if (!ontiri.isAbsolute()) ontiri = IRI.create(absur);

            // First of all, it could be a simple request for the space root!
            String temp = scopeId + "/" + ontologyId;
            OntologySpace space = scope.getCoreSpace();
            if (temp.equals(space.getID())) rb = Response.ok(space.export(OWLOntology.class, merge));
            else {
                space = scope.getCustomSpace();
                if (temp.equals(space.getID())) rb = Response.ok(space.export(OWLOntology.class, merge));
                else {
                    OWLOntology o = null;
                    IRI ontologyIri = IRI.create(ontologyId);
                    OntologySpace spc = scope.getCustomSpace();
                    if (spc != null && spc.hasOntology(ontologyIri)) {
                        o = spc.getOntology(ontologyIri, OWLOntology.class, merge);
                    } else {
                        spc = scope.getCoreSpace();
                        if (spc != null && spc.hasOntology(ontologyIri)) o = spc.getOntology(ontologyIri,
                            OWLOntology.class, merge);
                    }
                    if (o == null) return Response.status(NOT_FOUND).build();
                    else rb = Response.ok(o);
                }
View Full Code Here

            // String scopeURI = uriInfo.getAbsolutePath().toString().replace(ontologyid, "");
            // IRI scopeIri = IRI.create(uriInfo.getBaseUri() + "ontology/" + scopeId);
            IRI ontIri = IRI.create(ontologyid);
            ScopeRegistry reg = onm.getScopeRegistry();
            OntologyScope scope = reg.getScope(scopeId);
            OntologySpace cs = scope.getCustomSpace();
            if (cs.hasOntology(ontIri)) {
                try {
                    reg.setScopeActive(scopeId, false);
                    cs.removeOntology(ontIri);
                    reg.setScopeActive(scopeId, true);
                } catch (OntologyCollectorModificationException e) {
                    reg.setScopeActive(scopeId, true);
                    throw new WebApplicationException(e, INTERNAL_SERVER_ERROR);
                }
View Full Code Here

            } else {
                // The root ontology ID is in the form [namespace][scopeId]
                ont = mgr.createOntology(IRI.create(getNamespace() + getID()));
                List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
                // Add the import statement for the custom space, if existing and not empty
                OntologySpace spc = getCustomSpace();
                if (spc != null && spc.getOntologyCount(false) > 0) {
                    IRI spaceIri = IRI.create(getNamespace() + spc.getID());
                    additions.add(new AddImport(ont, df.getOWLImportsDeclaration(spaceIri)));
                }
                // Add the import statement for the core space, if existing and not empty
                spc = getCoreSpace();
                if (spc != null && spc.getOntologyCount(false) > 0) {
                    IRI spaceIri = IRI.create(getNamespace() + spc.getID());
                    additions.add(new AddImport(ont, df.getOWLImportsDeclaration(spaceIri)));
                }
                mgr.applyChanges(additions);
            }
        } catch (OWLOntologyCreationException e) {
View Full Code Here

    public static OWLOntology buildImportTree(OntologyInputSource<OWLOntology,OWLOntologyManager> rootSrc,
                                              Set<OWLOntology> subtrees,
                                              OWLOntologyManager mgr) {

        if (rootSrc instanceof OntologySpaceSource) {
            OntologySpace spc = ((OntologySpaceSource) rootSrc).asOntologySpace();
            for (OWLOntology o : subtrees)
                try {
                    spc.addOntology(new RootOntologySource(o));
                } catch (UnmodifiableOntologyCollectorException e) {
                    logger.error("Cannot add ontology {} to unmodifiable space {}", o, spc);
                    continue;
                }
        }
View Full Code Here

TOP

Related Classes of org.apache.stanbol.ontologymanager.ontonet.api.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.