public OIdentifier getProjectionAlias() { if (alias != null) { return alias; } OIdentifier result; if (all) { result = new OIdentifier("*"); } else { result = expression.getDefaultAlias(); } return result; }
/** * given a property name, calculates if this property name matches this nested projection item, eg. * <ul> * <li>this is a *, so it matches any property name</li> * <li>the field name for this projection item is the same as the input property name</li> * <li>this item has a wildcard and the partial field is a prefix of the input property name</li> * </ul> * * @param propertyName * * @return */ public boolean matches(String propertyName) { if (star) { return true; } if (expression != null) { String fieldString = expression.getDefaultAlias().getStringValue(); if (fieldString.equals(propertyName)) { return true; } if (rightWildcard && propertyName.startsWith(fieldString)) { return true; } } return false; }
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; }
Object key = this.key.execute(new OResultInternal(), ctx); if (key == null) { key = this.key.getDefaultAlias(); value = this.value.getDefaultAlias(); if (value.equals("null")) { value = null;
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; }
if (alias.equals(exp.getDefaultAlias().getStringValue()) && exp.isBaseIdentifier()) { found = true; newGroupBy.getItems().add(exp);
OIdentifier returnAlias; if (returnAliasIdentifier == null) { returnAlias = item.getDefaultAlias(); } else { returnAlias = returnAliasIdentifier;
String alias = item.alias != null ? item.alias.getStringValue() : item.expression.getDefaultAlias().getStringValue(); Object value = item.expression.execute(elem, ctx); if (item.expansion != null) {
if (fields.size() == 1 && fields.get(0).equals(binaryCondition.getLeft().getDefaultAlias().getStringValue())) { OBinaryCondition indexCond = new OBinaryCondition(-1); indexCond.setLeft(new OExpression(new OIdentifier("key")));
OExpression left = ((OBinaryCondition) singleExp).getLeft(); if (left.isBaseIdentifier()) { String fieldName = left.getDefaultAlias().getStringValue(); if (indexField.equals(fieldName)) { OBinaryCompareOperator operator = ((OBinaryCondition) singleExp).getOperator(); OExpression left = ((OContainsValueCondition) singleExp).getLeft(); if (left.isBaseIdentifier()) { String fieldName = left.getDefaultAlias().getStringValue(); if (indexField.equals(fieldName)) { found = true; OExpression left = ((OContainsAnyCondition) singleExp).getLeft(); if (left.isBaseIdentifier()) { String fieldName = left.getDefaultAlias().getStringValue(); if (indexField.equals(fieldName)) { if (!((OContainsAnyCondition) singleExp).getRight().isEarlyCalculated(ctx)) { OExpression left = ((OInCondition) singleExp).getLeft(); if (left.isBaseIdentifier()) { String fieldName = left.getDefaultAlias().getStringValue(); if (indexField.equals(fieldName)) { if (((OInCondition) singleExp).getRightMathExpression() != null) {