Package org.apache.stanbol.ontologymanager.sources.clerezza

Examples of org.apache.stanbol.ontologymanager.sources.clerezza.GraphContentInputSource


    @Test
    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)
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...");
View Full Code Here

    @Test
    public void sessionPreservesManagedOntologies() throws Exception {
        String id = "12345"; // The kind of thing an idiot would have on his luggage.
        Session session = sessionManager.createSession(id);
        // Anonymous ontologies must preserve their public keys!
        session.addOntology(new GraphContentInputSource(getClass().getResourceAsStream(
            "/ontologies/nameless_ontology.owl")));
        // Same for named ontologies...
        session.addOntology(new GraphContentInputSource(getClass().getResourceAsStream(
            "/ontologies/nonexistentcharacters.owl")));
        // ... and versioned ontologies too.
        session.addOntology(new GraphContentInputSource(getClass().getResourceAsStream(
            "/ontologies/versiontest_v1.owl")));
        session.addOntology(new GraphContentInputSource(getClass().getResourceAsStream(
            "/ontologies/versiontest_v2.owl")));
        Collection<OWLOntologyID> managed = session.listManagedOntologies();
        assertEquals(4, managed.size());

        // Simulate Stanbol going down.
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

             * For the time being, REST services operate in-memory (i.e. no TcProvider is supplied to the
             * input source). This means that only the final processed graph is stored.
             *
             * TODO : we might find a reason to change that in the future.
             */
            new GraphContentInputSource(content, mt.toString(), ontologyProvider.getStore()));
            if (key == null || key.isAnonymous()) {
                log.error("FAILED parse with media type {}.", mt);
                throw new WebApplicationException(INTERNAL_SERVER_ERROR);
            }
            // FIXME ugly but will have to do for the time being
View Full Code Here

                            }
                            break;
                        } else {
                            content = new FileInputStream(file);
                            log.debug("Recreated input stream for format {}", f);
                            src = new GraphContentInputSource(content, f, ontologyProvider.getStore());
                        }
                    } catch (UnsupportedFormatException e) {
                        log.warn(
                            "POST method failed for media type {}. This should not happen (should fail earlier)",
                            headers.getMediaType());
View Full Code Here

            log.debug("POST content claimed to be of type {}.", mt);
            OntologyInputSource<?> src;
            if (OWL_XML.equals(mt) || FUNCTIONAL_OWL.equals(mt) || MANCHESTER_OWL.equals(mt)) src = new OntologyContentInputSource(
                    content);
            else // content = new BufferedInputStream(content);
            src = new GraphContentInputSource(content, mt, ontologyProvider.getStore());
            log.debug("SUCCESS parse with media type {}.", mt);
            OWLOntologyID key = session.addOntology(src);
            if (key == null || key.isAnonymous()) {
                log.error("FAILED parse with media type {}.", mt);
                throw new WebApplicationException(INTERNAL_SERVER_ERROR);
View Full Code Here

                                rb.entity(new Viewable("/imports/409", this));
                                rb.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_HTML + "; charset=utf-8");
                            }
                        } else {
                            content = new BufferedInputStream(new FileInputStream(file));
                            src = new GraphContentInputSource(content, f, ontologyProvider.getStore());
                        }
                        log.debug("Done in {} ms", System.currentTimeMillis() - b4buf);
                        log.info("SUCCESS parse with format {}.", f);
                        break;
                    } catch (OntologyLoadingException e) {
View Full Code Here

TOP

Related Classes of org.apache.stanbol.ontologymanager.sources.clerezza.GraphContentInputSource

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.