Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.Graph


            // Set the ontology ID
            root.add(new TripleImpl(iri, RDF.type, OWL.Ontology));

            if (merge) {

                Graph custom, core;

                // Get the subjects of "bad" triples (those with subjects of type owl:Ontology).
                Iterator<Triple> it;
                Set<NonLiteral> ontologies = new HashSet<NonLiteral>();
                Set<Resource> importTargets = new HashSet<Resource>();
                custom = this.getCustomSpace().export(Graph.class, merge);
                // root.addAll(space);
                it = custom.filter(null, RDF.type, OWL.Ontology);
                while (it.hasNext())
                    ontologies.add(it.next().getSubject());
                it = custom.filter(null, OWL.imports, null);
                while (it.hasNext())
                    importTargets.add(it.next().getObject());
                core = this.getCoreSpace().export(Graph.class, merge);
                // root.addAll(space);
                it = core.filter(null, RDF.type, OWL.Ontology);
View Full Code Here


            if (merge) {
                log.warn("Merging of Clerezza triple collections is only implemented one level down. Import statements will be preserved for further levels.");
                Iterator<Triple> it;
                Set<Resource> importTargets = new HashSet<Resource>();
                for (OWLOntologyID ontologyId : managedOntologies) {
                    Graph g = getOntology(ontologyId, Graph.class, false);
                    root.addAll(g);

                    it = g.filter(null, OWL.imports, null);
                    while (it.hasNext()) {
                        IRI tgt;
                        Resource r = it.next().getObject();
                        try {
                            if (r instanceof UriRef) tgt = IRI.create(((UriRef) r).getUnicodeString());
                            else if (r instanceof Literal) tgt = IRI.create(((Literal) r).getLexicalForm());
                            else tgt = IRI.create(r.toString());
                            tgt = URIUtils.sanitize(tgt);
                            importTargets.add(new UriRef(tgt.toString()));
                        } catch (Exception ex) {
                            log.error("FAILED to obtain import target from resource {}", r);
                            continue;
                        }

                    }

                    it = g.filter(null, RDF.type, OWL.Ontology);
                    while (it.hasNext()) {
                        NonLiteral ontology = it.next().getSubject();
                        log.debug("Removing all triples related to {} from {}", ontology, iri);
                        Iterator<Triple> it2 = g.filter(ontology, null, null);
                        while (it2.hasNext())
                            root.remove(it2.next());
                    }

                    /*
 
View Full Code Here

     *
     * @return
     */
    public Set<ExecutionNode> getExecutionNodes() {
        if (_executionNodes == null) {
            Graph ep;
            try {
                ep = chain.getExecutionPlan();
            } catch (ChainException e) {
                ep = null;
            }
View Full Code Here

                                      @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

                                        @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

        log.debug("Ontology ID {}", ontologyId);
        ResponseBuilder rb;
        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 {
View Full Code Here

    @Test
    public void testImportModelFromSKOS() throws Exception {
        log.info(" --- testImportModelFromSKOS --- ");
        Parser parser = Parser.getInstance();
        parser.bindParsingProvider(new JenaParserProvider());
        Graph graph = parser.parse(getClass().getResourceAsStream("/sample-scheme.skos.rdf.xml"),
            SupportedFormat.RDF_XML);
        int imported = classifier.importConceptsFromGraph(graph, OntologicalClasses.SKOS_CONCEPT,
            Properties.SKOS_BROADER);
        assertEquals(imported, 4);
        assertEquals(0, classifier.getBroaderConcepts("http://example.com/ns#someconceptscheme/100").size());
View Full Code Here

                                            @DefaultValue("false") @QueryParam("merge") boolean merge,
                                            @Context UriInfo uriInfo,
                                            @Context HttpHeaders headers) {
        if (session == null) return Response.status(NOT_FOUND).build();
        IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/");
        Graph o = session.getOntology(OntologyUtils.decode(ontologyId), Graph.class, merge, prefix);
        ResponseBuilder rb = (o != null) ? Response.ok(o) : Response.status(NOT_FOUND);
        addCORSOrigin(servletContext, rb, headers);
        return rb.build();
    }
View Full Code Here

        if (session == null) rb = Response.status(NOT_FOUND);
        else {
            IRI prefix = IRI.create(getPublicBaseUri() + "ontonet/session/");
            OWLOntologyID id = OntologyUtils.decode(ontologyId);
            if (merge) {
                Graph g = session.getOntology(id, Graph.class, merge, prefix);
                rb = (g != null) ? Response.ok(g) : Response.status(NOT_FOUND);
            } else {
                OWLOntology o = session.getOntology(id, OWLOntology.class, merge, prefix);
                rb = (o != null) ? Response.ok(o) : Response.status(NOT_FOUND);
            }
View Full Code Here

     * Assert union graph on an empty dataset
     */
    @Test
    public void testEmptyUnionGraph(){
        TcProvider provider = getInstance();
        Graph graph = provider.getGraph(UNION_GRAPH_NAME);
        Assert.assertNotNull(graph);
    }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.Graph

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.