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);
}
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)));
}
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);
}
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));
}
}
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();
}
}
}
}
Aggregations