Search in sources :

Example 1 with FrontsTriple

use of org.apache.jena.graph.FrontsTriple in project jena by apache.

the class WhereClauseTest method testAddGraph_frontsTriple.

@ContractTest
public void testAddGraph_frontsTriple() {
    final Node s = NodeFactory.createURI("s");
    final Node p = NodeFactory.createURI("p");
    final Node o = NodeFactory.createURI("o");
    FrontsTriple ft = new FrontsTriple() {

        @Override
        public Triple asTriple() {
            return new Triple(s, p, o);
        }
    };
    WhereClause<?> whereClause = getProducer().newInstance();
    AbstractQueryBuilder<?> builder = whereClause.addGraph("<g>", ft);
    Query query = builder.build();
    ElementPathBlock epb = new ElementPathBlock();
    ElementNamedGraph eng = new ElementNamedGraph(NodeFactory.createURI("g"), epb);
    epb.addTriplePath(new TriplePath(new Triple(s, p, o)));
    WhereValidator visitor = new WhereValidator(eng);
    query.getQueryPattern().visit(visitor);
    assertTrue(visitor.matching);
}
Also used : Triple(org.apache.jena.graph.Triple) FrontsTriple(org.apache.jena.graph.FrontsTriple) ElementNamedGraph(org.apache.jena.sparql.syntax.ElementNamedGraph) ElementSubQuery(org.apache.jena.sparql.syntax.ElementSubQuery) Query(org.apache.jena.query.Query) FrontsTriple(org.apache.jena.graph.FrontsTriple) WhereValidator(org.apache.jena.arq.querybuilder.WhereValidator) Node(org.apache.jena.graph.Node) TriplePath(org.apache.jena.sparql.core.TriplePath) ElementPathBlock(org.apache.jena.sparql.syntax.ElementPathBlock) ContractTest(org.xenei.junit.contract.ContractTest)

Example 2 with FrontsTriple

use of org.apache.jena.graph.FrontsTriple in project jena by apache.

the class SecuredItemImpl method checkCreateReified.

/**
 * Check that a triple can be reified.
 *
 * @param uri   The URI for the reification subject. May be null.
 * @param front the frontstriple that is to be reified.
 * @throws AddDeniedException              on failure to add triple
 * @throws UpdateDeniedException           if the updates of the graph are not
 *                                         allowed.
 * @throws AuthenticationRequiredException if user is not authenticated and is
 *                                         required to be.
 */
protected void checkCreateReified(final String uri, final FrontsTriple front) throws AddDeniedException, UpdateDeniedException, AuthenticationRequiredException {
    checkUpdate();
    Triple t = front.asTriple();
    final Node n = uri == null ? SecurityEvaluator.FUTURE : NodeFactory.createURI(uri);
    checkCreate(new Triple(n, RDF.subject.asNode(), t.getSubject()));
    checkCreate(new Triple(n, RDF.predicate.asNode(), t.getPredicate()));
    checkCreate(new Triple(n, RDF.object.asNode(), t.getObject()));
}
Also used : Triple(org.apache.jena.graph.Triple) FrontsTriple(org.apache.jena.graph.FrontsTriple) Node(org.apache.jena.graph.Node)

Aggregations

FrontsTriple (org.apache.jena.graph.FrontsTriple)2 Node (org.apache.jena.graph.Node)2 Triple (org.apache.jena.graph.Triple)2 WhereValidator (org.apache.jena.arq.querybuilder.WhereValidator)1 Query (org.apache.jena.query.Query)1 TriplePath (org.apache.jena.sparql.core.TriplePath)1 ElementNamedGraph (org.apache.jena.sparql.syntax.ElementNamedGraph)1 ElementPathBlock (org.apache.jena.sparql.syntax.ElementPathBlock)1 ElementSubQuery (org.apache.jena.sparql.syntax.ElementSubQuery)1 ContractTest (org.xenei.junit.contract.ContractTest)1