Search in sources :

Example 26 with SimpleGraph

use of org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph in project stanbol by apache.

the class RootResource method getMetadata.

public Response getMetadata(@PathParam("ontologyId") String ontologyId, @Context UriInfo uriInfo, @Context HttpHeaders headers) {
    ResponseBuilder rb;
    org.apache.clerezza.commons.rdf.IRI me = new org.apache.clerezza.commons.rdf.IRI(getPublicBaseUri() + "ontonet/" + ontologyId);
    Graph mImmutableGraph = new SimpleGraph();
    for (String alias : getAliases(OntologyUtils.decode(ontologyId))) {
        mImmutableGraph.add(new TripleImpl(new org.apache.clerezza.commons.rdf.IRI(getPublicBaseUri() + "ontonet/" + alias), OWL.sameAs, me));
    }
    rb = Response.ok(mImmutableGraph);
    // addCORSOrigin(servletContext, rb, headers);
    return rb.build();
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) ImmutableGraph(org.apache.clerezza.commons.rdf.ImmutableGraph) Graph(org.apache.clerezza.commons.rdf.Graph) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder)

Example 27 with SimpleGraph

use of org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph in project stanbol by apache.

the class RdfSerializingWriter method getExpandedContext.

private Graph getExpandedContext(GraphNode node, GraphNode recipe) {
    final Graph result = new SimpleGraph(node.getNodeContext());
    final Set<RDFTerm> expandedResources = new HashSet<RDFTerm>();
    expandedResources.add(node.getNode());
    while (true) {
        Set<RDFTerm> additionalExpansionRes = getAdditionalExpansionResources(result, recipe);
        additionalExpansionRes.removeAll(expandedResources);
        if (additionalExpansionRes.size() == 0) {
            return result;
        }
        for (RDFTerm resource : additionalExpansionRes) {
            final GraphNode additionalNode = new GraphNode(resource, node.getGraph());
            result.addAll(additionalNode.getNodeContext());
            expandedResources.add(resource);
        }
    }
}
Also used : SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) Graph(org.apache.clerezza.commons.rdf.Graph) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) RDFTerm(org.apache.clerezza.commons.rdf.RDFTerm) GraphNode(org.apache.clerezza.rdf.utils.GraphNode) HashSet(java.util.HashSet)

Example 28 with SimpleGraph

use of org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph in project stanbol by apache.

the class TripleMatcherGroupImplTest method createGraph.

@Before
public void createGraph() {
    graph = new SimpleGraph();
    graph.add(TripleUtil.uriTriple("S1", "P1", "01"));
    graph.add(TripleUtil.uriTriple("S1", "P1", "02"));
    graph.add(TripleUtil.uriTriple("S2", "P1", "01"));
    graph.add(TripleUtil.uriTriple("S2", "P1", "02"));
    graph.add(TripleUtil.uriTriple("S3", "P1", "01"));
    graph.add(TripleUtil.uriTriple("S4", "P1", "02"));
}
Also used : SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) Before(org.junit.Before)

Example 29 with SimpleGraph

use of org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph in project stanbol by apache.

the class ExistingClerezzaGraphTest method initTestData.

/**
     * Initialises the {@link #entityData} used for this test (called in BeforeClass)
     */
private static void initTestData() {
    IRI entity1 = new IRI("http://www.test.org/entity1");
    Graph entity1Data = new SimpleGraph();
    entity1Data.add(new TripleImpl(entity1, RDF.type, SKOS.Concept));
    entity1Data.add(new TripleImpl(entity1, SKOS.prefLabel, new PlainLiteralImpl("test", EN)));
    entity1Data.add(new TripleImpl(entity1, SKOS.prefLabel, new PlainLiteralImpl("Test", DE)));
    entityData.put(entity1, entity1Data);
    Graph entity2Data = new SimpleGraph();
    IRI entity2 = new IRI("http://www.test.org/entity2");
    entity2Data.add(new TripleImpl(entity2, RDF.type, SKOS.Concept));
    entity2Data.add(new TripleImpl(entity2, SKOS.prefLabel, new PlainLiteralImpl("sub-test", EN)));
    entity2Data.add(new TripleImpl(entity2, SKOS.prefLabel, new PlainLiteralImpl("Untertest", DE)));
    entity2Data.add(new TripleImpl(entity2, SKOS.broader, entity1));
    entityData.put(entity2, entity2Data);
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) ImmutableGraph(org.apache.clerezza.commons.rdf.ImmutableGraph) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) Graph(org.apache.clerezza.commons.rdf.Graph) PlainLiteralImpl(org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)

Example 30 with SimpleGraph

use of org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph in project stanbol by apache.

the class JenaToClerezzaConverter method jenaModelToClerezzaGraph.

/**
	 * 
	 * Converts a Jena {@link Model} to Clerezza {@link Graph}.
	 * 
	 * @param model {@link Model}
	 * @return the equivalent Clerezza {@link Graph}.
	 */
public static org.apache.clerezza.commons.rdf.Graph jenaModelToClerezzaGraph(Model model) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    model.write(out);
    ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
    ParsingProvider parser = new JenaParserProvider();
    org.apache.clerezza.commons.rdf.Graph mGraph = new SimpleGraph();
    parser.parse(mGraph, in, SupportedFormat.RDF_XML, null);
    return mGraph;
}
Also used : JenaParserProvider(org.apache.clerezza.rdf.jena.parser.JenaParserProvider) ParsingProvider(org.apache.clerezza.rdf.core.serializedform.ParsingProvider) ByteArrayInputStream(java.io.ByteArrayInputStream) SimpleGraph(org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Aggregations

SimpleGraph (org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph)46 Graph (org.apache.clerezza.commons.rdf.Graph)34 IRI (org.apache.clerezza.commons.rdf.IRI)24 Test (org.junit.Test)17 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)15 TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)12 ImmutableGraph (org.apache.clerezza.commons.rdf.ImmutableGraph)11 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)10 Triple (org.apache.clerezza.commons.rdf.Triple)10 HashSet (java.util.HashSet)9 ContentItem (org.apache.stanbol.enhancer.servicesapi.ContentItem)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 InputStream (java.io.InputStream)5 HtmlExtractor (org.apache.stanbol.enhancer.engines.htmlextractor.impl.HtmlExtractor)5 RdfEntityFactory (org.apache.stanbol.enhancer.rdfentities.RdfEntityFactory)5 BlankNode (org.apache.clerezza.commons.rdf.BlankNode)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 IOException (java.io.IOException)3 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)3 JenaParserProvider (org.apache.clerezza.rdf.jena.parser.JenaParserProvider)3