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();
}
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);
}
}
}
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"));
}
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);
}
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;
}
Aggregations