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

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


                }
            }
            if (!(rScope instanceof UriRef)) throw new InvalidMetaGraphStateException(
                    rScope + " is not a legal scope identifier.");
            String scopeId = ((UriRef) rScope).getUnicodeString().substring(prefix_scope.length());
            Scope scope = scopeManager.getScope(scopeId);
            switch (spaceType) {
                case CORE:
                    handles.add(scope.getCoreSpace());
                    break;
                case CUSTOM:
                    handles.add(scope.getCustomSpace());
                    break;
            }
        } else if (meta.contains(new TripleImpl(candidate, RDF.type, SESSION_URIREF))) {
            String sessionId = ((UriRef) candidate).getUnicodeString().substring(prefix_session.length());
            handles.add(sessionManager.getSession(sessionId));
View Full Code Here


        assertEquals(1, ontologyProvider.getStore().listTripleCollections().size());
        // This one has an import that we want to hijack locally, so we use the ParentPathInputSource.
        OntologyInputSource<?> ois = new ParentPathInputSource(new File(getClass().getResource(
            "/ontologies/minorcharacters.owl").toURI()));

        Scope sc = onManager.createOntologyScope(scopeId, ois);

        Set<Triple> triples = new HashSet<Triple>();

        for (UriRef iri : ontologyProvider.getStore().listTripleCollections()) {
            log.info("{}", iri.toString());
View Full Code Here

    public void storedOntologyOutlivesScope() throws Exception {
        String ephemeralScopeId = "CaducousScope";
        OntologyInputSource<OWLOntology> ois = new RootOntologySource(IRI.create(getClass().getResource(
            "/ontologies/nonexistentcharacters.owl")));
        OWLOntologyID ontologyId = ois.getRootOntology().getOntologyID();
        Scope scope = onManager.createOntologyScope(ephemeralScopeId);
        // Initially, the ontology is not there
        assertFalse(ontologyProvider.hasOntology(ontologyId));
        // Once added, the ontology is there
        scope.getCustomSpace().addOntology(ois);
        assertTrue(ontologyProvider.hasOntology(ontologyId));
        // Once removed from the scope, the ontology is still there
        scope.getCustomSpace().removeOntology(ontologyId);
        assertTrue(ontologyProvider.hasOntology(ontologyId));
        // Once the scope is killed, the ontology is still there
        // TODO find a more appropriate method to kill scopes?
        scope.tearDown();
        assertTrue(ontologyProvider.hasOntology(ontologyId));
    }
View Full Code Here

        reset();
    }

    @Test
    public void testCreateSessionSpaceAutomatic() throws Exception {
        Scope scope1 = null, scope2 = null, scope3 = null;

        scope1 = collectorfactory.createOntologyScope(scopeId1, src1, src2);
        onManager.registerScope(scope1);
        scope2 = collectorfactory.createOntologyScope(scopeId2, src2, src1);
        onManager.registerScope(scope2);
View Full Code Here

    }

    @Override
    public Scope createOntologyScope(String scopeID, OntologyInputSource<?>... coreOntologies) throws DuplicateIDException {
        // Scope constructor also creates core and custom spaces
        Scope scope = new ScopeImpl(scopeID, getDefaultNamespace(), this, coreOntologies);
        fireScopeCreated(scope);
        return scope;
    }
View Full Code Here

        scopeMap.remove(id);
        fireScopeDeregistered(scope);
    }

    protected void fireScopeActivationChange(String scopeID, boolean activated) {
        Scope scope = scopeMap.get(scopeID);
        if (activated) for (ScopeEventListener l : listeners)
            l.scopeActivated(scope);
        else for (ScopeEventListener l : listeners)
            l.scopeDeactivated(scope);
    }
View Full Code Here

    @Override
    public void setScopeActive(String scopeID, boolean active) {
        if (!containsScope(scopeID)) throw new NoSuchScopeException(scopeID);
        // Prevent no-changes from firing events.
        boolean previousStatus = isScopeActive(scopeID);
        Scope scope = getScope(scopeID);
        if (active == previousStatus) return;
        if (active) {
            scope.setUp();
            activeScopeIRIs.add(scopeID);
        } else {
            scope.tearDown();
            activeScopeIRIs.remove(scopeID);
        }
        fireScopeActivationChange(scopeID, active);
    }
View Full Code Here

                for (String s : customs)
                    log.debug("\tDetected custom ontology {}", s);

                // Create the scope
                log.debug("Rebuilding scope \"{}\"", scopeId);
                Scope sc = null;
                sc = /* factory. */createOntologyScope(scopeId, new BlankOntologySource());

                // Populate the core space
                if (cores.length > 0) {
                    OntologySpace corespc = sc.getCoreSpace();
                    corespc.tearDown();
                    for (int i = 0; i < cores.length; i++)
                        try {
                            corespc.addOntology(new RootOntologySource(IRI.create(cores[i])));
                        } catch (Exception ex) {
                            log.warn("Failed to import ontology " + cores[i], ex);
                            continue;
                        }
                }

                sc.setUp();
                registerScope(sc);
                sc.getCustomSpace().tearDown();
                for (String locationIri : customs) {
                    try {
                        OntologyInputSource<?> src = new RootOntologySource(IRI.create(locationIri));
                        sc.getCustomSpace().addOntology(src);
                        log.debug("Added ontology from location {}", locationIri);
                    } catch (UnmodifiableOntologyCollectorException e) {
                        log.error("An error occurred while trying to add the ontology from location: "
                                  + locationIri, e);
                        continue;
                    }
                }
                sc.getCustomSpace().setUp();
            }

            /**
             * Try to get activation policies
             */
 
View Full Code Here

        this.registerScope(scope);
    }

    @Override
    public Scope createOntologyScope(String scopeID, OntologyInputSource<?>... coreOntologies) throws DuplicateIDException {
        Scope sc = scopeFactory.createOntologyScope(scopeID, coreOntologies);
        configureScope(sc);
        return sc;
    }
View Full Code Here

            int i = 0;
            for (OWLOntologyID coreOnt : coreOnts) {
                log.debug("Core ontology key : {}", coreOnts);
                srcs[i++] = new StoredOntologySource(coreOnt);
            }
            Scope scope;
            try {
                scope = createOntologyScope(scopeId, srcs);
            } catch (DuplicateIDException e) {
                String dupe = e.getDuplicateID();
                log.warn("Scope \"{}\" already exists and will be reused.", dupe);
                scope = getScope(dupe);
            }
            OntologySpace custom = scope.getCustomSpace();
            // Register even if some ontologies were to fail to be restored afterwards.
            scopeMap.put(scopeId, scope);
            for (OWLOntologyID key : struct.getCustomOntologyKeysForScope(scopeId))
                try {
                    log.debug("Custom ontology key : {}", key);
View Full Code Here

TOP

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

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.