Search in sources :

Example 21 with PrefixMappingImpl

use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.

the class SHACLC method withStandardPrefixes.

/**
 * Return a copy of the {@link PrefixMapping} with the SHACLC standard prefixes added
 */
public static PrefixMapping withStandardPrefixes(PrefixMapping prefixMapping) {
    PrefixMapping pm = new PrefixMappingImpl();
    addStandardPrefixes(pm);
    // Add second to override any of the standard settings.
    pm.setNsPrefixes(prefixMapping);
    return pm;
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl)

Example 22 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 = TDBFactory.createDataset();
    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 23 with PrefixMappingImpl

use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.

the class SecuredPrefixMappingTest method testWithDefaultMappings.

@Test
public void testWithDefaultMappings() {
    PrefixMapping pm = new PrefixMappingImpl();
    pm.setNsPrefix("example", "http://example.com");
    try {
        // make sure that it must update
        securedMapping.withDefaultMappings(pm);
        if (!securityEvaluator.evaluate(principal, Action.Update, securedMapping.getModelNode())) {
            Assert.fail("Should have thrown UpdateDeniedException");
        }
    } catch (final UpdateDeniedException e) {
        if (securityEvaluator.evaluate(principal, Action.Update, securedMapping.getModelNode())) {
            Assert.fail(String.format("Should not have thrown UpdateDeniedException Exception: %s - %s", e, e.getTriple()));
        }
    }
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) UpdateDeniedException(org.apache.jena.shared.UpdateDeniedException) PrefixMappingImpl(org.apache.jena.shared.impl.PrefixMappingImpl) Test(org.junit.Test)

Example 24 with PrefixMappingImpl

use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.

the class WhereHandlerTest method testAddOptionalObjectsWithPath.

@Test
public void testAddOptionalObjectsWithPath() {
    PrefixMapping pmap = new PrefixMappingImpl();
    pmap.setNsPrefix("ts", "urn:test:");
    Path path = PathParser.parse("ts:two/ts:dos", pmap);
    handler.addOptional(new TriplePath(NodeFactory.createURI("one"), path, ResourceFactory.createLangLiteral("three", "en-US").asNode()));
    handler.build();
    ElementPathBlock epb = new ElementPathBlock();
    ElementOptional optional = new ElementOptional(epb);
    TriplePath tp = new TriplePath(NodeFactory.createURI("one"), path, ResourceFactory.createLangLiteral("three", "en-US").asNode());
    epb.addTriplePath(tp);
    WhereValidator visitor = new WhereValidator(optional);
    handler.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) Test(org.junit.Test)

Example 25 with PrefixMappingImpl

use of org.apache.jena.shared.impl.PrefixMappingImpl in project jena by apache.

the class WhereHandlerTest method testAddWhereObjectsWithPath.

@Test
public void testAddWhereObjectsWithPath() {
    PrefixMapping pmap = new PrefixMappingImpl();
    pmap.setNsPrefix("ts", "urn:test:");
    Path path = PathParser.parse("ts:two/ts:dos", pmap);
    handler.addWhere(new TriplePath(NodeFactory.createURI("one"), path, ResourceFactory.createLangLiteral("three", "en-US").asNode()));
    handler.build();
    TriplePath tp = new TriplePath(NodeFactory.createURI("one"), path, ResourceFactory.createLangLiteral("three", "en-US").asNode());
    ElementPathBlock epb = new ElementPathBlock();
    epb.addTriple(tp);
    WhereValidator wv = new WhereValidator(epb);
    query.getQueryPattern().visit(wv);
    assertTrue(wv.matching);
}
Also used : TriplePath(org.apache.jena.sparql.core.TriplePath) Path(org.apache.jena.sparql.path.Path) PrefixMapping(org.apache.jena.shared.PrefixMapping) 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) Test(org.junit.Test)

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