use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class TestSolverTDB method beforeClass.
@BeforeClass
public static void beforeClass() {
dataset = TL.createTestDatasetMem();
dataset.begin(ReadWrite.WRITE);
String graphData = ConfigTest.getTestingDataRoot() + "/Data/solver-data.ttl";
RDFDataMgr.read(dataset, graphData);
pmap = new PrefixMappingImpl();
pmap.setNsPrefix("", "http://example/");
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class WhereClauseTest method testAddOptionalObjectsWithPath.
@ContractTest
public void testAddOptionalObjectsWithPath() {
WhereClause<?> whereClause = getProducer().newInstance();
PrefixMapping pmap = new PrefixMappingImpl();
pmap.setNsPrefix("ts", "urn:test:");
Path path = PathParser.parse("ts:two/ts:dos", pmap);
AbstractQueryBuilder<?> builder = whereClause.addOptional(NodeFactory.createURI("one"), path, NodeFactory.createURI("three"));
ElementPathBlock epb = new ElementPathBlock();
ElementOptional optional = new ElementOptional(epb);
TriplePath tp = new TriplePath(NodeFactory.createURI("one"), path, NodeFactory.createURI("three"));
epb.addTriplePath(tp);
WhereValidator visitor = new WhereValidator(optional);
builder.build().getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class SecuredPrefixMappingImpl method withDefaultMappings.
@Override
public SecuredPrefixMapping withDefaultMappings(final PrefixMapping map) throws UpdateDeniedException, AuthenticationRequiredException {
// mapping only updates if there are map entries to add. Since this gets
// called
// when we are doing deep triple checks while writing we need to attempt
// the
// update only if there are new updates to add.
PrefixMapping m = holder.getBaseItem();
PrefixMappingImpl pm = new PrefixMappingImpl();
for (Entry<String, String> e : map.getNsPrefixMap().entrySet()) {
if (m.getNsPrefixURI(e.getKey()) == null && m.getNsURIPrefix(e.getValue()) == null) {
pm.setNsPrefix(e.getKey(), e.getValue());
}
}
if (!pm.getNsPrefixMap().isEmpty()) {
checkUpdate();
holder.getBaseItem().withDefaultMappings(pm);
}
return holder.getSecuredItem();
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.
the class WhereClauseTest method testAddOptionalTriplePath.
@ContractTest
public void testAddOptionalTriplePath() {
WhereClause<?> whereClause = getProducer().newInstance();
PrefixMapping pmap = new PrefixMappingImpl();
pmap.setNsPrefix("ts", "urn:test:");
Path path = PathParser.parse("ts:two/ts:dos", pmap);
AbstractQueryBuilder<?> builder = whereClause.addOptional(new TriplePath(NodeFactory.createURI("one"), path, NodeFactory.createURI("three")));
ElementPathBlock epb = new ElementPathBlock();
ElementOptional optional = new ElementOptional(epb);
TriplePath tp = new TriplePath(NodeFactory.createURI("one"), path, NodeFactory.createURI("three"));
epb.addTriplePath(tp);
WhereValidator visitor = new WhereValidator(optional);
builder.build().getQueryPattern().visit(visitor);
assertTrue(visitor.matching);
}
use of org.apache.jena.shared.impl.PrefixMappingImpl in project webofneeds by researchstudio-sat.
the class WonLinkedDataUtils method getConversationAndNeedsDataset.
public static Dataset getConversationAndNeedsDataset(URI connectionURI, LinkedDataSource linkedDataSource) {
assert linkedDataSource != null : "linkedDataSource must not be null";
int depth = 5;
int maxRequests = 1000;
List<Path> propertyPaths = new ArrayList<>();
PrefixMapping pmap = new PrefixMappingImpl();
pmap.withDefaultMappings(PrefixMapping.Standard);
pmap.setNsPrefix("won", WON.getURI());
pmap.setNsPrefix("msg", WONMSG.getURI());
propertyPaths.add(PathParser.parse("won:hasEventContainer", pmap));
propertyPaths.add(PathParser.parse("won:hasEventContainer/rdfs:member", pmap));
propertyPaths.add(PathParser.parse("won:hasEventContainer/rdfs:member/msg:hasCorrespondingRemoteMessage", pmap));
propertyPaths.add(PathParser.parse("won:hasEventContainer/rdfs:member/msg:hasPreviousMessage", pmap));
propertyPaths.add(PathParser.parse("won:belongsToNeed", pmap));
propertyPaths.add(PathParser.parse("won:belongsToNeed/won:hasEventContainer", pmap));
propertyPaths.add(PathParser.parse("won:belongsToNeed/won:hasEventContainer/rdfs:member", pmap));
propertyPaths.add(PathParser.parse("won:belongsToNeed/won:hasEventContainer/rdfs:member/msg:hasPreviousMessage", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteNeed", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteNeed/won:hasEventContainer", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteNeed/won:hasEventContainer/rdfs:member", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteNeed/won:hasEventContainer/rdfs:member/msg:hasPreviousMessage", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteConnection", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteConnection/won:hasEventContainer", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteConnection/won:hasEventContainer/rdfs:member", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteConnection/won:hasEventContainer/rdfs:member/msg:hasCorrespondingRemoteMessage", pmap));
propertyPaths.add(PathParser.parse("won:hasRemoteConnection/won:hasEventContainer/rdfs:member/msg:hasPreviousMessage", pmap));
URI requesterWebId = WonLinkedDataUtils.getNeedURIforConnectionURI(connectionURI, linkedDataSource);
return linkedDataSource.getDataForResourceWithPropertyPath(connectionURI, requesterWebId, propertyPaths, maxRequests, depth);
}
Aggregations