Search in sources :

Example 16 with Triple

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

the class GraphSPARQLService method graphBaseFind.

//    @Override
//    public Capabilities getCapabilities()
//    { 
//    	if (capabilities == null)
//            capabilities = new AllCapabilities()
//        	  { @Override public boolean handlesLiteralTyping() { return false; } };
//        return capabilities;
//    }
@Override
protected ExtendedIterator<Triple> graphBaseFind(Triple m) {
    Node s = m.getMatchSubject();
    Var sVar = null;
    if (s == null) {
        sVar = Var.alloc("s");
        s = sVar;
    }
    Node p = m.getMatchPredicate();
    Var pVar = null;
    if (p == null) {
        pVar = Var.alloc("p");
        p = pVar;
    }
    Node o = m.getMatchObject();
    Var oVar = null;
    if (o == null) {
        oVar = Var.alloc("o");
        o = oVar;
    }
    Triple triple = new Triple(s, p, o);
    // Evaluate as an algebra expression
    BasicPattern pattern = new BasicPattern();
    pattern.add(triple);
    Op op = new OpBGP(pattern);
    //        return WrappedIterator.createNoRemove(triples.iterator()) ;
    return null;
}
Also used : Triple(org.apache.jena.graph.Triple) Op(org.apache.jena.sparql.algebra.Op) Var(org.apache.jena.sparql.core.Var) Node(org.apache.jena.graph.Node) OpBGP(org.apache.jena.sparql.algebra.op.OpBGP) BasicPattern(org.apache.jena.sparql.core.BasicPattern)

Example 17 with Triple

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

the class NodeTransformLib method transform.

/** Do a node->node conversion of a BGP - return original BGP for "no change" */
public static BasicPattern transform(NodeTransform nodeTransform, BasicPattern pattern) {
    BasicPattern bgp2 = new BasicPattern();
    boolean changed = false;
    for (Triple triple : pattern) {
        Triple t2 = transform(nodeTransform, triple);
        bgp2.add(t2);
        if (t2 != triple)
            changed = true;
    }
    if (!changed)
        return pattern;
    return bgp2;
}
Also used : Triple(org.apache.jena.graph.Triple)

Example 18 with Triple

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

the class ElementTransformSubst method transform.

@Override
public Element transform(ElementTriplesBlock el) {
    ElementTriplesBlock etb = new ElementTriplesBlock();
    boolean changed = false;
    for (Triple t : el.getPattern()) {
        Triple t2 = transform(t);
        changed = changed || t != t2;
        etb.addTriple(t2);
    }
    if (changed)
        return etb;
    return el;
}
Also used : Triple(org.apache.jena.graph.Triple) ElementTriplesBlock(org.apache.jena.sparql.syntax.ElementTriplesBlock)

Example 19 with Triple

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

the class FmtUtils method formatPattern.

public static void formatPattern(IndentedWriter out, BasicPattern pattern, SerializationContext sCxt) {
    StringBuilder buffer = new StringBuilder();
    boolean first = true;
    for (Triple triple : pattern) {
        if (!first)
            buffer.append("\n");
        stringForTriple(buffer, triple, sCxt);
        buffer.append(" .");
        out.print(buffer.toString());
        buffer.setLength(0);
        first = false;
    }
}
Also used : Triple(org.apache.jena.graph.Triple)

Example 20 with Triple

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

the class IsoMatcher method tuplesTriples.

private static List<Tuple<Node>> tuplesTriples(Iterator<Triple> iter) {
    List<Tuple<Node>> tuples = new ArrayList<>();
    for (; iter.hasNext(); ) {
        Triple t = iter.next();
        Tuple<Node> tuple = tuple(t.getSubject(), t.getPredicate(), t.getObject());
        tuples.add(tuple);
    }
    return tuples;
}
Also used : Triple(org.apache.jena.graph.Triple) Node(org.apache.jena.graph.Node) ArrayList(java.util.ArrayList) Tuple(org.apache.jena.atlas.lib.tuple.Tuple)

Aggregations

Triple (org.apache.jena.graph.Triple)406 Test (org.junit.Test)139 Node (org.apache.jena.graph.Node)95 BaseTest (org.apache.jena.atlas.junit.BaseTest)66 Graph (org.apache.jena.graph.Graph)54 Quad (org.apache.jena.sparql.core.Quad)25 TriplePath (org.apache.jena.sparql.core.TriplePath)22 ArrayList (java.util.ArrayList)20 StatsMatcher (org.apache.jena.sparql.engine.optimizer.StatsMatcher)19 Var (org.apache.jena.sparql.core.Var)17 TripleWritable (org.apache.jena.hadoop.rdf.types.TripleWritable)15 TriplePattern (org.apache.jena.reasoner.TriplePattern)13 Op (org.apache.jena.sparql.algebra.Op)13 BasicPattern (org.apache.jena.sparql.core.BasicPattern)13 Model (org.apache.jena.rdf.model.Model)12 TransitiveGraphCache (org.apache.jena.reasoner.transitiveReasoner.TransitiveGraphCache)11 LongWritable (org.apache.hadoop.io.LongWritable)10 InfGraph (org.apache.jena.reasoner.InfGraph)10 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)10 QuadWritable (org.apache.jena.hadoop.rdf.types.QuadWritable)8