Search in sources :

Example 56 with Triple

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

the class TestDistinctTriples method distinct_triples_03.

@Test
public void distinct_triples_03() throws IOException {
    MapReduceDriver<LongWritable, TripleWritable, TripleWritable, NullWritable, NullWritable, TripleWritable> driver = this.getMapReduceDriver();
    Triple t = new Triple(NodeFactory.createURI("urn:s"), NodeFactory.createURI("urn:p"), NodeFactory.createLiteral("1"));
    Triple t2 = new Triple(t.getSubject(), t.getPredicate(), NodeFactory.createLiteral("2"));
    Assert.assertNotEquals(t, t2);
    TripleWritable tw = new TripleWritable(t);
    TripleWritable tw2 = new TripleWritable(t2);
    Assert.assertNotEquals(tw, tw2);
    driver.addInput(new LongWritable(1), tw);
    driver.addInput(new LongWritable(2), tw2);
    driver.addOutput(NullWritable.get(), tw);
    driver.addOutput(NullWritable.get(), tw2);
    driver.runTest(false);
}
Also used : Triple(org.apache.jena.graph.Triple) TripleWritable(org.apache.jena.hadoop.rdf.types.TripleWritable) LongWritable(org.apache.hadoop.io.LongWritable) NullWritable(org.apache.hadoop.io.NullWritable) Test(org.junit.Test)

Example 57 with Triple

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

the class AbstractTriplesToQuadsMapper method map.

@Override
protected final void map(TKey key, TripleWritable value, Context context) throws IOException, InterruptedException {
    Triple triple = value.get();
    Node graphNode = this.selectGraph(triple);
    context.write(key, new QuadWritable(new Quad(graphNode, triple)));
}
Also used : Triple(org.apache.jena.graph.Triple) Quad(org.apache.jena.sparql.core.Quad) QuadWritable(org.apache.jena.hadoop.rdf.types.QuadWritable) Node(org.apache.jena.graph.Node)

Example 58 with Triple

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

the class TestDistinctTriples method distinct_triples_04.

@Test
public void distinct_triples_04() throws IOException {
    MapReduceDriver<LongWritable, TripleWritable, TripleWritable, NullWritable, NullWritable, TripleWritable> driver = this.getMapReduceDriver();
    Node s1 = NodeFactory.createURI("urn:nf#cbf2b2c7-109e-4097-bbea-f67f272c7fcc");
    Node s2 = NodeFactory.createURI("urn:nf#bb08b75c-1ad2-47ef-acd2-eb2d92b94b89");
    Node p = NodeFactory.createURI("urn:p");
    Node o = NodeFactory.createURI("urn:66.230.159.118");
    Assert.assertNotEquals(s1, s2);
    Triple t1 = new Triple(s1, p, o);
    Triple t2 = new Triple(s2, p, o);
    Assert.assertNotEquals(t1, t2);
    TripleWritable tw1 = new TripleWritable(t1);
    TripleWritable tw2 = new TripleWritable(t2);
    Assert.assertNotEquals(tw1, tw2);
    Assert.assertNotEquals(0, tw1.compareTo(tw2));
    driver.addInput(new LongWritable(1), tw1);
    driver.addInput(new LongWritable(2), tw2);
    driver.addOutput(NullWritable.get(), tw1);
    driver.addOutput(NullWritable.get(), tw2);
    driver.runTest(false);
}
Also used : Triple(org.apache.jena.graph.Triple) TripleWritable(org.apache.jena.hadoop.rdf.types.TripleWritable) Node(org.apache.jena.graph.Node) LongWritable(org.apache.hadoop.io.LongWritable) NullWritable(org.apache.hadoop.io.NullWritable) Test(org.junit.Test)

Example 59 with Triple

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

the class SecuredRDFListImpl method remove.

@Override
public RDFList remove(final RDFNode val) throws UpdateDeniedException, DeleteDeniedException, AuthenticationRequiredException {
    checkUpdate();
    RDFList cell = null;
    boolean denied = false;
    if (!canDelete(new Triple(Node.ANY, listFirst().asNode(), val.asNode()))) {
        // iterate over the deletable items
        // .mapWith(new
        final ExtendedIterator<RDFList> iter = getSecuredRDFListIterator(Action.Delete);
        // SecuredListMap());
        while (iter.hasNext()) {
            cell = iter.next();
            if (val.equals(cell.getRequiredProperty(listFirst()).getObject())) {
                if (canDelete(new Triple(cell.asNode(), listFirst().asNode(), val.asNode()))) {
                    return SecuredRDFListImpl.getInstance(getModel(), baseRemove(cell));
                } else {
                    denied = true;
                }
            }
        }
        if (denied) {
            throw new DeleteDeniedException(SecuredItem.Util.triplePermissionMsg(getModelNode()));
        } else {
            return this;
        }
    } else {
        return SecuredRDFListImpl.getInstance(getModel(), holder.getBaseItem().remove(val));
    }
}
Also used : Triple(org.apache.jena.graph.Triple) SecuredRDFList(org.apache.jena.permissions.model.SecuredRDFList) DeleteDeniedException(org.apache.jena.shared.DeleteDeniedException)

Example 60 with Triple

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

the class SecuredRDFListImpl method removeList.

@Override
public void removeList() throws UpdateDeniedException, AuthenticationRequiredException {
    checkUpdate();
    final Triple t = new Triple(Node.ANY, listFirst().asNode(), Node.ANY);
    // have to be able to read and delete to delete all.
    final Set<Action> perms = SecurityEvaluator.Util.asSet(new Action[] { Action.Delete, Action.Read });
    if (getSecurityEvaluator().evaluate(getSecurityEvaluator().getPrincipal(), perms, this.getModelNode(), t)) {
        holder.getBaseItem().removeList();
    } else {
        for (final Statement s : collectStatements(perms)) {
            if (canDelete(s)) {
                s.remove();
            }
        }
    }
}
Also used : Triple(org.apache.jena.graph.Triple) Action(org.apache.jena.permissions.SecurityEvaluator.Action)

Aggregations

Triple (org.apache.jena.graph.Triple)407 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 Model (org.apache.jena.rdf.model.Model)13 TriplePattern (org.apache.jena.reasoner.TriplePattern)13 Op (org.apache.jena.sparql.algebra.Op)13 BasicPattern (org.apache.jena.sparql.core.BasicPattern)13 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 Resource (org.apache.jena.rdf.model.Resource)9