use of org.apache.jena.graph.Triple in project jena by apache.
the class SecuredRDFListImpl method with.
@Override
public SecuredRDFList with(final RDFNode value) throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException {
checkUpdate();
checkCreate(new Triple(SecurityEvaluator.FUTURE, listFirst().asNode(), value.asNode()));
return SecuredRDFListImpl.getInstance(getModel(), holder.getBaseItem().with(value));
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class SecuredRDFListImpl method size.
@Override
public int size() throws ReadDeniedException, AuthenticationRequiredException {
checkRead();
final Triple t = new Triple(Node.ANY, listFirst().asNode(), Node.ANY);
if (canRead(t)) {
return holder.getBaseItem().size();
}
final ExtendedIterator<RDFNode> iter = iterator();
int i = 0;
while (iter.hasNext()) {
i++;
iter.next();
}
return i;
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class PropertyFunctionGenerator method magicProperty.
// Remove all triples associated with this magic property.
// Make an instance record.
private static PropertyFunctionInstance magicProperty(Context context, Triple pfTriple, BasicPattern triples) {
List<Triple> listTriples = new ArrayList<>();
GNode sGNode = new GNode(triples, pfTriple.getSubject());
GNode oGNode = new GNode(triples, pfTriple.getObject());
List<Node> sList = null;
List<Node> oList = null;
if (GraphList.isListNode(sGNode)) {
sList = GraphList.members(sGNode);
GraphList.allTriples(sGNode, listTriples);
}
if (GraphList.isListNode(oGNode)) {
oList = GraphList.members(oGNode);
GraphList.allTriples(oGNode, listTriples);
}
PropFuncArg subjArgs = new PropFuncArg(sList, pfTriple.getSubject());
PropFuncArg objArgs = new PropFuncArg(oList, pfTriple.getObject());
// Confuses single arg with a list of one.
PropertyFunctionInstance pfi = new PropertyFunctionInstance(subjArgs, pfTriple.getPredicate(), objArgs);
triples.getList().removeAll(listTriples);
return pfi;
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class PropertyFunctionGenerator method makeStages.
private static Op makeStages(BasicPattern triples, Map<Triple, PropertyFunctionInstance> pfInvocations) {
// Step 3 : Make the operation expression.
// For each property function, insert the implementation
// For each block of non-property function triples, make a BGP.
Op op = null;
BasicPattern pattern = null;
for (Triple t : triples) {
if (pfInvocations.containsKey(t)) {
op = flush(pattern, op);
pattern = null;
PropertyFunctionInstance pfi = pfInvocations.get(t);
OpPropFunc opPF = new OpPropFunc(t.getPredicate(), pfi.getSubjectArgList(), pfi.getObjectArgList(), op);
op = opPF;
continue;
}
// Regular triples - make sure there is a basic pattern in progress.
if (pattern == null)
pattern = new BasicPattern();
pattern.add(t);
}
op = flush(pattern, op);
return op;
}
use of org.apache.jena.graph.Triple in project jena by apache.
the class AlgebraGenerator method prepareGroup.
/* Extract filters, merge adjacent BGPs, do BIND.
* When extracting filters, BGP or PathBlocks may become adjacent
* so merge them into one.
* Return a list of elements with any filters at the end.
*/
protected Pair<List<Expr>, List<Element>> prepareGroup(ElementGroup groupElt) {
List<Element> groupElts = new ArrayList<>();
PathBlock currentPathBlock = null;
List<Expr> filters = null;
for (Element elt : groupElt.getElements()) {
if (!fixedFilterPosition && elt instanceof ElementFilter) {
// For fixed position filters, drop through to general element processing.
// It's also illegal SPARQL - filters operate over the whole group.
ElementFilter f = (ElementFilter) elt;
if (filters == null)
filters = new ArrayList<>();
filters.add(f.getExpr());
// Collect filters but do not place them yet.
continue;
}
if (elt instanceof ElementTriplesBlock) {
ElementTriplesBlock etb = (ElementTriplesBlock) elt;
if (currentPathBlock == null) {
ElementPathBlock etb2 = new ElementPathBlock();
currentPathBlock = etb2.getPattern();
groupElts.add(etb2);
}
for (Triple t : etb.getPattern()) currentPathBlock.add(new TriplePath(t));
continue;
}
if (elt instanceof ElementPathBlock) {
ElementPathBlock epb = (ElementPathBlock) elt;
if (currentPathBlock == null) {
ElementPathBlock etb2 = new ElementPathBlock();
currentPathBlock = etb2.getPattern();
groupElts.add(etb2);
}
currentPathBlock.addAll(epb.getPattern());
continue;
}
// else
// Not BGP, path or filters.
// Clear any BGP-related triple accumulators.
currentPathBlock = null;
// Add this element
groupElts.add(elt);
}
return Pair.create(filters, groupElts);
}
Aggregations