Search in sources :

Example 61 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping 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 62 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class PrologClauseTest method testAddPrefixNode.

@ContractTest
public void testAddPrefixNode() {
    PrologClause<?> prologClause = getProducer().newInstance();
    AbstractQueryBuilder<?> builder = prologClause.addPrefix("pfx", NodeFactory.createURI("uri"));
    Query q = builder.build();
    PrefixMapping map = q.getPrefixMapping();
    assertEquals("uri", map.getNsPrefixURI("pfx"));
    assertEquals(1, map.getNsPrefixMap().size());
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Query(org.apache.jena.query.Query) ContractTest(org.xenei.junit.contract.ContractTest)

Example 63 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class PrologClauseTest method testAddPrefixString.

@ContractTest
public void testAddPrefixString() {
    PrologClause<?> prologClause = getProducer().newInstance();
    AbstractQueryBuilder<?> builder = prologClause.addPrefix("pfx", "uri");
    Query q = builder.build();
    PrefixMapping map = q.getPrefixMapping();
    assertEquals("uri", map.getNsPrefixURI("pfx"));
    assertEquals(1, map.getNsPrefixMap().size());
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Query(org.apache.jena.query.Query) ContractTest(org.xenei.junit.contract.ContractTest)

Example 64 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class PrologClauseTest method testAddPrefixResource.

@ContractTest
public void testAddPrefixResource() {
    PrologClause<?> prologClause = getProducer().newInstance();
    AbstractQueryBuilder<?> builder = prologClause.addPrefix("pfx", ResourceFactory.createResource("uri"));
    Query q = builder.build();
    PrefixMapping map = q.getPrefixMapping();
    assertEquals("uri", map.getNsPrefixURI("pfx"));
    assertEquals(1, map.getNsPrefixMap().size());
}
Also used : PrefixMapping(org.apache.jena.shared.PrefixMapping) Query(org.apache.jena.query.Query) ContractTest(org.xenei.junit.contract.ContractTest)

Example 65 with PrefixMapping

use of org.apache.jena.shared.PrefixMapping in project jena by apache.

the class FusekiNetLib method addDataInto.

public static void addDataInto(DatasetGraph src, DatasetGraph dest) {
    Iterator<Quad> iter = src.find(Node.ANY, Node.ANY, Node.ANY, Node.ANY);
    for (; iter.hasNext(); ) {
        Quad q = iter.next();
        dest.add(q);
    }
    PrefixMapping pmapSrc = src.getDefaultGraph().getPrefixMapping();
    PrefixMapping pmapDest = dest.getDefaultGraph().getPrefixMapping();
    pmapDest.withDefaultMappings(pmapSrc);
}
Also used : Quad(org.apache.jena.sparql.core.Quad) PrefixMapping(org.apache.jena.shared.PrefixMapping)

Aggregations

PrefixMapping (org.apache.jena.shared.PrefixMapping)149 Test (org.junit.Test)47 PrefixMappingImpl (org.apache.jena.shared.impl.PrefixMappingImpl)29 Graph (org.apache.jena.graph.Graph)22 BaseTest (org.apache.jena.atlas.junit.BaseTest)11 Triple (org.apache.jena.graph.Triple)9 Resource (org.apache.jena.rdf.model.Resource)9 Path (org.apache.jena.sparql.path.Path)8 ConfigTest (org.apache.jena.tdb.ConfigTest)8 DatasetPrefixesTDB (org.apache.jena.tdb.store.DatasetPrefixesTDB)8 ContractTest (org.xenei.junit.contract.ContractTest)8 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)7 ArrayList (java.util.ArrayList)5 Node (org.apache.jena.graph.Node)5 Query (org.apache.jena.query.Query)5 Model (org.apache.jena.rdf.model.Model)5 PrefixMappingSDB (org.apache.jena.sdb.graph.PrefixMappingSDB)5 URI (java.net.URI)4 HashMap (java.util.HashMap)4 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)4