private void meetNodeLocalParentOwned(StringBuilder builder, boolean mapping, Map<String, String> bindings, ProjectionElemList list, OwnedTupleExpr owned) throws RepositoryException, MalformedQueryException { owned.prepare(QueryLanguage.SPARQL, builder.toString(), bindings); if (mapping) { Projection proj = new Projection(owned.clone(), list); owned.replaceWith(proj); } }
bindings); if (mapping) { Projection proj = new Projection(owned.clone(), list); owned.replaceWith(proj); bindings); if (mapping) { Projection proj = new Projection(owned, list); patternNode.replaceWith(proj); } else {
private void meetNodeLocalParentNotOwned(StringBuilder builder, boolean mapping, Map<String, String> bindings, ProjectionElemList list) throws RepositoryException, MalformedQueryException { OwnedTupleExpr owned = new OwnedTupleExpr(owner.getOwner(), patternNode.clone()); owned.prepare(QueryLanguage.SPARQL, builder.toString(), bindings); if (mapping) { Projection proj = new Projection(owned, list); patternNode.replaceWith(proj); } else { patternNode.replaceWith(owned); } }
private UnaryTupleOperator projection() { if (!mProjectionPatterns.isEmpty()) { return multiProjection(); } else { Extension aExt = null; ProjectionElemList aList = new ProjectionElemList(); for (String aVar : mProjectionVars) { aList.addElement(new ProjectionElem(aVar)); } Projection aProjection = new Projection(); aProjection.setProjectionElemList(aList); if (aExt != null) { aProjection.setArg(aExt); } return aProjection; } }
private UnaryTupleOperator visitTemplates(Resource templates) throws OpenRDFException { List<ProjectionElemList> projElemLists = new ArrayList<ProjectionElemList>(); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(templates, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElemList projElems = visitTemplate(r); projElemLists.add(projElems); } UnaryTupleOperator expr; if (projElemLists.size() > 1) { MultiProjection proj = new MultiProjection(); proj.setProjections(projElemLists); expr = proj; } else { Projection proj = new Projection(); proj.setProjectionElemList(projElemLists.get(0)); expr = proj; } Reduced reduced = new Reduced(); reduced.setArg(expr); tupleRoot = reduced; SingletonSet stub = new SingletonSet(); expr.setArg(stub); tupleNode = stub; return expr; }
private ParsedGraphQuery createGraphQuery(AugurStatementNode node) { TupleExpr tupleExpr = node.getTupleExpr(); String subjName = node.getSubjectName(); String predName = node.getPredicateName(); String objName = node.getObjectName(); String ctxName = node.getContextName(); ProjectionElem projSubj = new ProjectionElem(subjName, "subject"); ProjectionElem projPred = new ProjectionElem(predName, "predicate"); ProjectionElem projObj = new ProjectionElem(objName, "object"); ProjectionElem projCtx = new ProjectionElem(ctxName, "context"); ProjectionElemList projElemList = new ProjectionElemList(projSubj, projPred, projObj, projCtx); Projection proj = new Projection(tupleExpr, projElemList); ParsedGraphQuery query = new ParsedGraphQuery(proj); if (logger.isDebugEnabled()) { logger.debug(proj.toString()); } return query; }
@Override public TupleExpr visit(ASTDescribe node, Object data) throws VisitorException { TupleExpr tupleExpr = (TupleExpr)data; if (tupleExpr == null) { tupleExpr = new SingletonSet(); } Extension e = new Extension(); ProjectionElemList projectionElements = new ProjectionElemList(); for (int i = 0; i < node.jjtGetNumChildren(); i++) { ValueExpr resource = (ValueExpr)node.jjtGetChild(i).jjtAccept(this, null); if (resource instanceof Var) { projectionElements.addElement(new ProjectionElem(((Var)resource).getName())); } else { String alias = "_describe_" + UUID.randomUUID().toString().replaceAll("-", "_"); ExtensionElem elem = new ExtensionElem(resource, alias); e.addElement(elem); projectionElements.addElement(new ProjectionElem(alias)); } } if (!e.getElements().isEmpty()) { e.setArg(tupleExpr); tupleExpr = e; } Projection p = new Projection(tupleExpr, projectionElements); return new DescribeOperator(p); }
private Projection visitResultVariables(Resource resultVars) throws OpenRDFException { ProjectionElemList projElemList = new ProjectionElemList(); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(resultVars, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElem projElem = visitResultVariable(r); projElemList.addElement(projElem); } Projection proj = new Projection(); proj.setProjectionElemList(projElemList); tupleRoot = proj; SingletonSet stub = new SingletonSet(); proj.setArg(stub); tupleNode = stub; return proj; }
result = new Projection(result, projElemList); result = new Projection(result, projections.get(0));
result = new Projection(result, projElemList); result = new Projection(result, projections.get(0));
result = new Distinct(new Projection(union, pelist));
private Projection visitResultNodes(Resource resultNodes) throws OpenRDFException { ProjectionElemList projElemList = new ProjectionElemList(); Iteration<? extends Resource, QueryEvaluationException> iter = Statements.listResources(resultNodes, store); while (iter.hasNext()) { Resource r = iter.next(); ProjectionElem projElem = visitResultNode(r); projElemList.addElement(projElem); } Projection proj = new Projection(); proj.setProjectionElemList(projElemList); tupleRoot = new DescribeOperator(proj); SingletonSet stub = new SingletonSet(); proj.setArg(stub); tupleNode = stub; return proj; }
result = new Projection(result, projList.get(0));
tuple = new Projection(tuple, projection); }else if (!projectionElements.isEmpty()){ tuple = new MultiProjection(tuple, projectionElements);
tuple = new Projection(tuple, projection); } else if (!projectionElements.isEmpty()) { tuple = new MultiProjection(tuple, projectionElements);
tuple = new Projection(tuple, projection); } else if (!projectionElements.isEmpty()) { tuple = new MultiProjection(tuple, projectionElements);
result = new Projection(result, projElemList);
result = new Projection(result, projElemList);