public ONestedProjection copy() { ONestedProjection result = new ONestedProjection(-1); result.includeItems = includeItems.stream().map(x -> x.copy()).collect(Collectors.toList()); result.excludeItems = excludeItems.stream().map(x -> x.copy()).collect(Collectors.toList()); result.starItem = starItem == null ? null : starItem.copy(); result.recursion = recursion == null ? null : recursion.copy(); return result; }
public Object expand(OExpression expression, String name, Object value, OCommandContext ctx, int recursion) { return expansion.apply(expression, value, ctx); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; ONestedProjectionItem that = (ONestedProjectionItem) o; if (exclude != that.exclude) return false; if (star != that.star) return false; if (rightWildcard != that.rightWildcard) return false; if (expression != null ? !expression.equals(that.expression) : that.expression != null) return false; if (expansion != null ? !expansion.equals(that.expansion) : that.expansion != null) return false; return alias != null ? alias.equals(that.alias) : that.alias == null; }
private Object apply(OExpression expression, Map<String, Object> input, OCommandContext ctx, int recursion) { OResultInternal result = new OResultInternal(); if (starItem != null || includeItems.size() == 0) { for (String property : input.keySet()) { if (isExclude(property)) { continue; } result.setProperty(property, convert(tryExpand(expression, property, input.get(property), ctx, recursion))); } } if (includeItems.size() > 0) { //TODO manage wildcards! for (ONestedProjectionItem item : includeItems) { String alias = item.alias != null ? item.alias.getStringValue() : item.expression.getDefaultAlias().getStringValue(); OResultInternal elem = new OResultInternal(); input.entrySet().forEach(x -> elem.setProperty(x.getKey(), x.getValue())); Object value = item.expression.execute(elem, ctx); if (item.expansion != null) { value = item.expand(expression, alias, value, ctx, recursion - 1); } result.setProperty(alias, convert(value)); } } return result; }
final public ONestedProjection NestedProjection() throws ParseException { ONestedProjection jjtn000 = new ONestedProjection(JJTNESTEDPROJECTION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1));ONestedProjectionItem lastItem; try { jj_consume_token(COLON); jjtree.closeNodeScope(jjtn000, true); jjtc000 = false; jjtn000.jjtSetLastToken(getToken(0)); {if (true) return jjtn000;} } catch (Throwable jjte000) { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0));
public void deserialize(OResult fromResult) { all = fromResult.getProperty("all"); if (fromResult.getProperty("alias") != null) { alias = OIdentifier.deserialize(fromResult.getProperty("alias")); } if (fromResult.getProperty("expression") != null) { expression = new OExpression(-1); expression.deserialize(fromResult.getProperty("expression")); } aggregate = fromResult.getProperty("aggregate"); if (fromResult.getProperty("nestedProjection") != null) { nestedProjection = new ONestedProjection(-1); nestedProjection.deserialize(fromResult.getProperty("nestedProjection")); } }
public OProjectionItem copy() { OProjectionItem result = new OProjectionItem(-1); result.all = all; result.alias = alias == null ? null : alias.copy(); result.expression = expression == null ? null : expression.copy(); result.nestedProjection = nestedProjection == null ? null : nestedProjection.copy(); result.aggregate = aggregate; return result; }
@Override public int hashCode() { int result = (all ? 1 : 0); result = 31 * result + (alias != null ? alias.hashCode() : 0); result = 31 * result + (expression != null ? expression.hashCode() : 0); result = 31 * result + (nestedProjection != null ? nestedProjection.hashCode() : 0); result = 31 * result + (aggregate != null ? aggregate.hashCode() : 0); return result; }
private Object apply(OExpression expression, OResult elem, OCommandContext ctx, int recursion) { OResultInternal result = new OResultInternal(); if (starItem != null || includeItems.size() == 0) { for (String property : elem.getPropertyNames()) { if (isExclude(property)) { continue; } result.setProperty(property, convert(tryExpand(expression, property, elem.getProperty(property), ctx, recursion))); } } if (includeItems.size() > 0) { //TODO manage wildcards! for (ONestedProjectionItem item : includeItems) { String alias = item.alias != null ? item.alias.getStringValue() : item.expression.getDefaultAlias().getStringValue(); Object value = item.expression.execute(elem, ctx); if (item.expansion != null) { value = item.expand(expression, alias, value, ctx, recursion - 1); } result.setProperty(alias, convert(value)); } } return result; }
public void deserialize(OResult fromResult) { exclude = fromResult.getProperty("exclude"); star = fromResult.getProperty("star"); if (fromResult.getProperty("field") != null) { expression = new OExpression(-1); expression.deserialize(fromResult.getProperty("expression")); } rightWildcard = fromResult.getProperty("rightWildcard"); if (fromResult.getProperty("expansion") != null) { expansion = new ONestedProjection(-1); expansion.deserialize(fromResult.getProperty("expansion")); } if (fromResult.getProperty("alias") != null) { alias = OIdentifier.deserialize(fromResult.getProperty("alias")); } } }
@Override public ONestedProjectionItem copy() { ONestedProjectionItem result = new ONestedProjectionItem(-1); result.exclude = exclude; result.star = star; result.expression = expression == null ? null : expression.copy(); result.rightWildcard = rightWildcard; result.expansion = expansion == null ? null : expansion.copy(); result.alias = alias == null ? null : alias.copy(); return result; }
@Override public int hashCode() { int result = (exclude ? 1 : 0); result = 31 * result + (star ? 1 : 0); result = 31 * result + (expression != null ? expression.hashCode() : 0); result = 31 * result + (rightWildcard ? 1 : 0); result = 31 * result + (expansion != null ? expansion.hashCode() : 0); result = 31 * result + (alias != null ? alias.hashCode() : 0); return result; }
if (starItem != null || includeItems.size() == 0) { for (String property : elem.getPropertyNames()) { if (isExclude(property)) { continue; result.setProperty(property, convert(tryExpand(expression, property, elem.getProperty(property), ctx, recursion))); value = item.expand(expression, alias, value, ctx, recursion - 1); result.setProperty(alias, convert(value));
return apply(expression, (OResult) input, ctx, recursion == null ? 0 : recursion.getValue().intValue()); return apply(expression, (OIdentifiable) input, ctx, recursion == null ? 0 : recursion.getValue().intValue()); return apply(expression, (Map) input, ctx, recursion == null ? 0 : recursion.getValue().intValue()); return ((Collection) input).stream().map(x -> apply(expression, x, ctx)).collect(Collectors.toList()); List result = new ArrayList(); while (iter.hasNext()) { result.add(apply(expression, iter.next(), ctx));
@Override public OMatchStatement copy() { OMatchStatement result = new OMatchStatement(-1); result.matchExpressions = matchExpressions == null ? null : matchExpressions.stream().map(x -> x == null ? null : x.copy()).collect(Collectors.toList()); result.notMatchExpressions = notMatchExpressions == null ? null : notMatchExpressions.stream().map(x -> x == null ? null : x.copy()).collect(Collectors.toList()); result.returnItems = returnItems == null ? null : returnItems.stream().map(x -> x == null ? null : x.copy()).collect(Collectors.toList()); result.returnAliases = returnAliases == null ? null : returnAliases.stream().map(x -> x == null ? null : x.copy()).collect(Collectors.toList()); result.returnNestedProjections = returnNestedProjections == null ? null : returnNestedProjections.stream().map(x -> x == null ? null : x.copy()).collect(Collectors.toList()); result.groupBy = groupBy == null ? null : groupBy.copy(); result.orderBy = orderBy == null ? null : orderBy.copy(); result.unwind = unwind == null ? null : unwind.copy(); result.skip = skip == null ? null : skip.copy(); result.limit = limit == null ? null : limit.copy(); result.returnDistinct = this.returnDistinct; result.buildPatterns(); return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; OProjectionItem that = (OProjectionItem) o; if (all != that.all) return false; if (alias != null ? !alias.equals(that.alias) : that.alias != null) return false; if (expression != null ? !expression.equals(that.expression) : that.expression != null) return false; if (nestedProjection != null ? !nestedProjection.equals(that.nestedProjection) : that.nestedProjection != null) return false; if (aggregate != null ? !aggregate.equals(that.aggregate) : that.aggregate != null) return false; return true; }
public Object execute(OIdentifiable iCurrentRecord, OCommandContext ctx) { Object result; if (all) { result = iCurrentRecord; } else { result = expression.execute(iCurrentRecord, ctx); } if (nestedProjection != null) { result = nestedProjection.apply(expression, result, ctx); } return convert(result); }
public OMatchExecutionPlanner(OMatchStatement stm) { this.matchExpressions = stm.getMatchExpressions().stream().map(x -> x.copy()).collect(Collectors.toList()); this.notMatchExpressions = stm.getNotMatchExpressions().stream().map(x -> x.copy()).collect(Collectors.toList()); this.returnItems = stm.getReturnItems().stream().map(x -> x.copy()).collect(Collectors.toList()); this.returnAliases = stm.getReturnAliases().stream().map(x -> x == null ? null : x.copy()).collect(Collectors.toList()); this.returnNestedProjections = stm.getReturnNestedProjections().stream().map(x -> x == null ? null : x.copy()) .collect(Collectors.toList()); this.limit = stm.getLimit() == null ? null : stm.getLimit().copy(); this.skip = stm.getSkip() == null ? null : stm.getSkip().copy(); this.returnElements = stm.returnsElements(); this.returnPaths = stm.returnsPaths(); this.returnPatterns = stm.returnsPatterns(); this.returnPathElements = stm.returnsPathElements(); this.returnDistinct = stm.isReturnDistinct(); this.groupBy = stm.getGroupBy() == null ? null : stm.getGroupBy().copy(); this.orderBy = stm.getOrderBy() == null ? null : stm.getOrderBy().copy(); this.unwind = stm.getUnwind() == null ? null : stm.getUnwind().copy(); }
public Object execute(OResult iCurrentRecord, OCommandContext ctx) { Object result; if (all) { result = iCurrentRecord; } else { result = expression.execute(iCurrentRecord, ctx); } if (nestedProjection != null) { if (result instanceof ODocument && ((ODocument) result).isEmpty()) { ((ODocument) result).load(null); } result = nestedProjection.apply(expression, result, ctx); } return convert(result); }
Object val = item.convert(iRecord.getProperty(alias)); if (item.nestedProjection != null) { val = item.nestedProjection.apply(item.expression, val, iContext);