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

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


    public void testCustomAboxCoreTbox() throws Exception {
        String path = "/ontologies/imports-disconnected";

        InputStream content = getClass().getResourceAsStream(path + "/abox.owl");
        OntologyInputSource<?> coreSrc = new GraphContentInputSource(content, SupportedFormat.TURTLE);
        Scope scope = onManager.createOntologyScope("imports-disconnected", coreSrc);
        assertNotNull(scope);

        content = getClass().getResourceAsStream(path + "/tbox.owl");
        OntologyInputSource<?> custSrc = new GraphContentInputSource(content, SupportedFormat.TURTLE);
        scope.getCustomSpace().addOntology(custSrc);

        Graph g = scope.export(Graph.class, true);

        // for (Triple t : g)
        // System.out.println(t);
        //
        // OWLOntology o = scope.export(OWLOntology.class, true);
View Full Code Here


    }

    @Test
    public void scopePreservesManagedOntologies() throws Exception {
        String id = "preserve";
        Scope scope = onManager.createOntologyScope(id, new GraphContentInputSource(getClass()
                .getResourceAsStream("/ontologies/mockfoaf.rdf")));
        scope.getCustomSpace().addOntology(
            new GraphContentInputSource(getClass().getResourceAsStream(
                "/ontologies/nonexistentcharacters.owl")));
        Collection<OWLOntologyID> cores = scope.getCoreSpace().listManagedOntologies();
        Collection<OWLOntologyID> customs = scope.getCustomSpace().listManagedOntologies();
        // Simulate Stanbol going down.
        log.info("Stanbol going down...");
        resetOntologyProvider(); // but keep the TcProvider
        resetManagers();

        Scope sc = onManager.getScope(id);
        assertNotNull(sc);
        assertEquals(cores, sc.getCoreSpace().listManagedOntologies());
        assertEquals(customs, sc.getCustomSpace().listManagedOntologies());
        assertEquals(scope, sc); // XXX Remember that only weak equality is implemented.
    }
View Full Code Here

         * rebuild it.
         */
        String id1 = "scope1", id2 = "scope2", sid2 = "auto-" + System.currentTimeMillis();

        // Setup a network
        Scope scope1 = onManager.createOntologyScope(id1);
        assertNotNull(scope1);
        Scope scope2 = onManager.createOntologyScope(id2);
        assertNotNull(scope2);
        onManager.deregisterScope(scope1);

        // A session with a system ID
        Session ses1 = sessionManager.createSession();
View Full Code Here

        // Ensure the metadata graph is there.
        TripleCollection meta = ontologyProvider.getMetaGraph(TripleCollection.class);
        assertNotNull(meta);

        String scopeId = "updateTest";
        Scope scope = onm.createOntologyScope(scopeId, new GraphContentInputSource(getClass()
                .getResourceAsStream("/ontologies/test1.owl")));

        UriRef collector = new UriRef(_NS_STANBOL_INTERNAL + OntologySpace.shortName + "/"
                                      + scope.getCoreSpace().getID());
        UriRef test1id = new UriRef("http://stanbol.apache.org/ontologies/test1.owl"); // Has no versionIRI
        // Be strict: the whole property pair must be there.
        UriRef predicate = MANAGES_URIREF;
        assertTrue(meta.contains(new TripleImpl(collector, predicate, test1id)));
        predicate = IS_MANAGED_BY_URIREF;
        assertTrue(meta.contains(new TripleImpl(test1id, predicate, collector)));

        scope.tearDown(); // To modify the core space.

        scope.getCoreSpace().addOntology(
            new GraphContentInputSource(getClass().getResourceAsStream("/ontologies/minorcharacters.owl")));
        UriRef minorId = new UriRef("http://stanbol.apache.org/ontologies/pcomics/minorcharacters.owl");
        predicate = MANAGES_URIREF;
        assertTrue(meta.contains(new TripleImpl(collector, predicate, minorId)));
        predicate = IS_MANAGED_BY_URIREF;
        assertTrue(meta.contains(new TripleImpl(minorId, predicate, collector)));

        scope.getCustomSpace().addOntology(
            new GraphContentInputSource(getClass().getResourceAsStream("/ontologies/test1.owl")));

        scope.getCustomSpace().addOntology(
            new GraphContentInputSource(getClass().getResourceAsStream("/ontologies/minorcharacters.owl")));
    }
View Full Code Here

    @Override
    public boolean equals(Object arg0) {
        if (arg0 == null) return false;
        if (!(arg0 instanceof Scope)) return false;
        Scope sc = (Scope) arg0;
//        return this.getID().equals(sc.getID()) && this.getDefaultNamespace().equals(sc.getDefaultNamespace())
//               && this.getCoreSpace().equals(sc.getCoreSpace())
//               && this.getCustomSpace().equals(sc.getCustomSpace());
if (!this.getID().equals(sc.getID())) return false;
if (!this.getDefaultNamespace().equals(sc.getDefaultNamespace())) return false;
if (!this.getCoreSpace().equals(sc.getCoreSpace())) return false;
if (!this.getCustomSpace().equals(sc.getCustomSpace())) return false;
        return true;

    }
View Full Code Here

        return false;
    }

    private OWLOntology getFromOntoMgr() throws IOException {
        try {
            Scope scope = null;
            synchronized (onManager) {
                scope = onManager.getScope(this.scopeId);
            }
            if (scope == null) {
                log.error("Scope {} cannot be retrieved", this.scopeId);
                throw new IOException("Scope " + this.scopeId + " cannot be retrieved");
            }
            Session session = null;
            if (sessionManager != null) synchronized (sessionManager) {
                session = sessionManager.getSession(sessionId);
            }
            if (session == null) log.warn("Session {} cannot be retrieved. Ignoring.", this.sessionId);
            final Set<OWLOntology> set = new HashSet<OWLOntology>();
            set.add(scope.export(OWLOntology.class, true));
            if (session != null) set.add(session.export(OWLOntology.class, true));
            if (set.size() == 1) return set.iterator().next();
            OWLOntologyMerger merger = new OWLOntologyMerger(new OWLOntologySetProvider() {
                @Override
                public Set<OWLOntology> getOntologies() {
View Full Code Here

            final Set<OWLOntology> set = new HashSet<OWLOntology>();
            set.add(o);
            for (String scopeID : attachedScopes) {
                log.debug(" ... Merging with attached scope {}.", scopeID);

                Scope sc = onm.getScope(scopeID);
                if (sc != null)

                set.add(sc.export(OWLOntology.class, merge));

                for (OWLOntologyID ontologyId : managedOntologies) {
                    set.add(getOntology(ontologyId, OWLOntology.class, true));
                }
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.