Search in sources :

Example 16 with PrefixMappingImpl

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/");
}
Also used : PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) BeforeClass(org.junit.BeforeClass)

Example 17 with PrefixMappingImpl

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);
}
Also used : TriplePath(org.apache.jena.sparql.core.TriplePath) Path(org.apache.jena.sparql.path.Path) PrefixMapping(org.apache.jena.shared.PrefixMapping) ElementOptional(org.apache.jena.sparql.syntax.ElementOptional) WhereValidator(org.apache.jena.arq.querybuilder.WhereValidator) TriplePath(org.apache.jena.sparql.core.TriplePath) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) ElementPathBlock(org.apache.jena.sparql.syntax.ElementPathBlock) ContractTest(org.xenei.junit.contract.ContractTest)

Example 18 with PrefixMappingImpl

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();
}
Also used : SecuredPrefixMapping(org.apache.jena.permissions.graph.SecuredPrefixMapping) PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl)

Example 19 with PrefixMappingImpl

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);
}
Also used : TriplePath(org.apache.jena.sparql.core.TriplePath) Path(org.apache.jena.sparql.path.Path) PrefixMapping(org.apache.jena.shared.PrefixMapping) ElementOptional(org.apache.jena.sparql.syntax.ElementOptional) WhereValidator(org.apache.jena.arq.querybuilder.WhereValidator) TriplePath(org.apache.jena.sparql.core.TriplePath) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) ElementPathBlock(org.apache.jena.sparql.syntax.ElementPathBlock) ContractTest(org.xenei.junit.contract.ContractTest)

Example 20 with PrefixMappingImpl

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);
}
Also used : Path(org.apache.jena.sparql.path.Path) PrefixMapping(org.apache.jena.shared.PrefixMapping) ArrayList(java.util.ArrayList) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) URI(java.net.URI)

Aggregations

PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)39 PrefixMapping (org.apache.jena.shared.PrefixMapping)34 Test (org.junit.Test)13 Path (org.apache.jena.sparql.path.Path)11 Graph (org.apache.jena.graph.Graph)8 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4 TriplePath (org.apache.jena.sparql.core.TriplePath)4 ElementPathBlock (org.apache.jena.sparql.syntax.ElementPathBlock)4 BeforeClass (org.junit.BeforeClass)4 ElementOptional (org.apache.jena.sparql.syntax.ElementOptional)3 ContractTest (org.xenei.junit.contract.ContractTest)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Triple (org.apache.jena.graph.Triple)2 Dataset (org.apache.jena.query.Dataset)2 Date (java.util.Date)1 Trie (org.apache.jena.atlas.lib.Trie)1 SecuredPrefixMapping (org.apache.jena.permissions.graph.SecuredPrefixMapping)1 Query (org.apache.jena.query.Query)1 UpdateDeniedException (org.apache.jena.shared.UpdateDeniedException)1