@Override public boolean equals(Object other) { if (other instanceof ProjectionElemList) { ProjectionElemList o = (ProjectionElemList)other; return elements.equals(o.getElements()); } return false; }
private ProjectionElemList visitTemplate(Resource r) throws OpenRDFException { ProjectionElemList projElems = new ProjectionElemList(); Value subj = Statements.singleValue(r, SP.SUBJECT_PROPERTY, store); projElems.addElement(createProjectionElem(subj, "subject")); Value pred = Statements.singleValue(r, SP.PREDICATE_PROPERTY, store); projElems.addElement(createProjectionElem(pred, "predicate")); Value obj = Statements.singleValue(r, SP.OBJECT_PROPERTY, store); projElems.addElement(createProjectionElem(obj, "object")); return projElems; }
/** * @inheritDoc */ @Override public void meet(final ProjectionElemList theProjectionElemList) throws Exception { if (!theProjectionElemList.getElements().isEmpty()) { mProjection.add(theProjectionElemList.clone()); } theProjectionElemList.visitChildren(this); }
@Override public ProjectionElemList clone() { ProjectionElemList clone = (ProjectionElemList)super.clone(); clone.elements = new ArrayList<ProjectionElem>(getElements().size()); for (ProjectionElem pe : getElements()) { clone.addElement(pe.clone()); } return clone; } }
ProjectionElemList projection = new ProjectionElemList(); List<ProjectionElemList> projectionElements = new ArrayList<ProjectionElemList>(); List<ExtensionElem> extensions = new ArrayList<ExtensionElem>(); ValueExpr val = toValue(expr, md); if (val instanceof Var){ projection.addElement(new ProjectionElem(((Var)val).getName())); }else{ String extLabel = extNames.next(); projection.addElement(new ProjectionElem(extLabel)); extensions.add(new ExtensionElem(val, extLabel)); ProjectionElemList p = new ProjectionElemList(); ValueExpr subject = toValue(pa.getSubject(), md); if (subject instanceof Var){ Var v = (Var)subject; p.addElement(new ProjectionElem(v.getName(),"subject")); if (v.getValue() != null){ extensions.add(new ExtensionElem(subject, v.getName())); projection.addElement(new ProjectionElem(extLabel, "subject")); extensions.add(new ExtensionElem(subject, extLabel)); if (predicate instanceof Var){ Var v = (Var)predicate; p.addElement(new ProjectionElem(v.getName(),"predicate")); if (v.getValue() != null){ extensions.add(new ExtensionElem(predicate, v.getName()));
varsBefore.removeAll(varsAfter); for (ProjectionElemList projElems : visitor.projElemLists) { for (ProjectionElem projElem : projElems.getElements()) { String name = projElem.getSourceName(); if (varsBefore.contains(name)) { UnaryTupleOperator proj = (UnaryTupleOperator)projElems.getParentNode(); Extension ext = new Extension(proj.getArg()); proj.setArg(ext);
public void addElements(ProjectionElem... elements) { for (ProjectionElem pe : elements) { addElement(pe); } }
@Override protected void meetNode(QueryModelNode node) throws RepositoryException { super.meetNode(node); if (owner != null && patternNode != null && !(patternNode instanceof StatementPattern)) { StringBuilder builder = new StringBuilder(); builder.append("SELECT"); if (distinct) { builder.append(" DISTINCT"); } else if (reduced || reduce) { builder.append(" REDUCED"); } boolean mapping = false; Map<String, String> bindings = new HashMap<String, String>(); ProjectionElemList list = new ProjectionElemList(); for (String name : patternNode.getBindingNames()) { mapping = addBindingNames(builder, mapping, bindings, list, name); } builder.append("\nWHERE {\n").append(pattern).append("}"); meetNodeLocal(builder, mapping, bindings, list); } reduced = false; distinct = false; pattern = null; // NOPMD patternNode = null; // NOPMD }
@Override public MultiProjection clone() { MultiProjection clone = (MultiProjection)super.clone(); clone.projections = new ArrayList<ProjectionElemList>(getProjections().size()); for (ProjectionElemList pe : getProjections()) { clone.addProjection(pe.clone()); } return clone; } }
ProjectionElemList projection = new ProjectionElemList(); List<ProjectionElemList> projectionElements = new ArrayList<ProjectionElemList>(); List<ExtensionElem> extensions = new ArrayList<ExtensionElem>(); ValueExpr val = toValue(expr, md); if (val instanceof Var) { projection.addElement(new ProjectionElem(((Var) val).getName())); } else { String extLabel = extNames.next(); projection.addElement(new ProjectionElem(extLabel)); extensions.add(new ExtensionElem(val, extLabel)); ProjectionElemList p = new ProjectionElemList(); ValueExpr subject = toValue(pa.getSubject(), md); if (subject instanceof Var) { Var v = (Var) subject; p.addElement(new ProjectionElem(v.getName(), "subject")); if (v.getValue() != null) { extensions.add(new ExtensionElem(subject, v.getName())); projection.addElement(new ProjectionElem(extLabel, "subject")); extensions.add(new ExtensionElem(subject, extLabel)); if (predicate instanceof Var) { Var v = (Var) predicate; p.addElement(new ProjectionElem(v.getName(), "predicate")); if (v.getValue() != null) { extensions.add(new ExtensionElem(predicate, v.getName()));
public void addElements(Iterable<ProjectionElem> elements) { for (ProjectionElem pe : elements) { addElement(pe); } }
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 Projection clone() { Projection clone = (Projection)super.clone(); clone.setProjectionElemList(getProjectionElemList().clone()); return clone; }
/** * Return whether or not this projection looks like an spo binding for a * construct query * * @param theList * the projection element list to inspect * @return true if it has the format of a spo construct projection element, * false otherwise */ public static boolean isSPOElemList(ProjectionElemList theList) { return theList.getElements().size() == 3 && theList.getElements().get(0).getTargetName().equalsIgnoreCase("subject") && theList.getElements().get(1).getTargetName().equalsIgnoreCase("predicate") && theList.getElements().get(2).getTargetName().equalsIgnoreCase("object"); }
ProjectionElemList projection = new ProjectionElemList(); List<ProjectionElemList> projectionElements = new ArrayList<ProjectionElemList>(); List<ExtensionElem> extensions = new ArrayList<ExtensionElem>(); ValueExpr val = toValue(expr, md); if (val instanceof Var) { projection.addElement(new ProjectionElem(((Var) val).getName())); } else { String extLabel = extNames.next(); projection.addElement(new ProjectionElem(extLabel)); extensions.add(new ExtensionElem(val, extLabel)); ProjectionElemList p = new ProjectionElemList(); ValueExpr subject = toValue(pa.getSubject(), md); if (subject instanceof Var) { Var v = (Var) subject; p.addElement(new ProjectionElem(v.getName(), "subject")); if (v.getValue() != null) { extensions.add(new ExtensionElem(subject, v.getName())); projection.addElement(new ProjectionElem(extLabel, "subject")); extensions.add(new ExtensionElem(subject, extLabel)); if (predicate instanceof Var) { Var v = (Var) predicate; p.addElement(new ProjectionElem(v.getName(), "predicate")); if (v.getValue() != null) { extensions.add(new ExtensionElem(predicate, v.getName()));
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 boolean addBindingNames(StringBuilder builder, boolean alreadyMapping, Map<String, String> bindings, ProjectionElemList list, String name) { boolean mapping = alreadyMapping; if (variables.containsKey(name)) { String var = variables.get(name); builder.append(" ?").append(var); bindings.put(name, var); list.addElement(new ProjectionElem(var, name)); if (!name.equals(var)) { mapping = true; } } return mapping; }
@Override public void meet(final ProjectionElemList node) { emit(node.getElements(), " "); }
ProjectionElemList projElemList = new ProjectionElemList(); projElemList.addElement(elem); Var projVar = (Var)child.jjtAccept(this, null); ProjectionElem elem = new ProjectionElem(projVar.getName()); projElemList.addElement(elem); for (ProjectionElem elem : projElemList.getElements()) { if (!elem.hasAggregateOperatorInExpression()) { Set<String> groupNames = group.getBindingNames();
ProjectionElemList list = new ProjectionElemList(); for (String name : patternNode.getBindingNames()) { if (variables.containsKey(name)) { sb.append(" ?").append(var); bindings.put(name, var); list.addElement(new ProjectionElem(var, name)); if (!name.equals(var)) { mapping = true;