use of org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.CInteger in project legend-engine by finos.
the class RelationalGraphFetchUtils method subTreeValidForCaching.
static boolean subTreeValidForCaching(GraphFetchTree graphFetchTree) {
boolean currentValidity = true;
if (graphFetchTree instanceof PropertyGraphFetchTree) {
PropertyGraphFetchTree propertyGraphFetchTree = (PropertyGraphFetchTree) graphFetchTree;
if (propertyGraphFetchTree.parameters != null && !propertyGraphFetchTree.parameters.isEmpty()) {
currentValidity = propertyGraphFetchTree.parameters.stream().allMatch(param -> param instanceof CBoolean || param instanceof CInteger || param instanceof CFloat || param instanceof CDecimal || param instanceof CString || param instanceof CStrictDate || param instanceof CDateTime || param instanceof EnumValue || (param instanceof Collection && ((Collection) param).values.stream().allMatch(x -> x instanceof EnumValue)));
}
}
boolean childrenValidity = graphFetchTree.subTrees == null || graphFetchTree.subTrees.isEmpty() || graphFetchTree.subTrees.stream().allMatch(RelationalGraphFetchUtils::subTreeValidForCaching);
return currentValidity && childrenValidity;
}
use of org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.CInteger in project legend-engine by finos.
the class GraphFetchTreeParseTreeWalker method instanceLiteralToken.
private ValueSpecification instanceLiteralToken(GraphFetchTreeParserGrammar.InstanceLiteralTokenContext ctx) {
ValueSpecification result;
try {
Multiplicity m = this.getPureOne();
if (ctx.STRING() != null) {
List<String> values = new ArrayList<>();
values.add(PureGrammarParserUtility.fromGrammarString(ctx.getText(), true));
CString instance = new CString();
instance.multiplicity = m;
instance.values = values;
instance.sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
result = instance;
} else if (ctx.INTEGER() != null) {
List<Long> values = new ArrayList<>();
values.add(Long.parseLong(ctx.getText()));
CInteger instance = new CInteger();
instance.multiplicity = m;
instance.values = values;
instance.sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
result = instance;
} else if (ctx.FLOAT() != null) {
List<Double> values = new ArrayList<>();
values.add(Double.parseDouble(ctx.getText()));
CFloat instance = new CFloat();
instance.multiplicity = m;
instance.values = values;
instance.sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
result = instance;
} else if (ctx.DATE() != null) {
List<String> values = new ArrayList<>();
// Likely wrong
values.add(ctx.getText());
CDateTime instance = new CDateTime();
instance.multiplicity = this.getPureOne();
instance.values = values.stream().map(value -> value.substring(value.lastIndexOf('%') + 1)).collect(Collectors.toList());
instance.sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
result = instance;
} else if (ctx.BOOLEAN() != null) {
List<Boolean> values = new ArrayList<>();
values.add(Boolean.parseBoolean(ctx.getText()));
CBoolean instance = new CBoolean();
instance.multiplicity = m;
instance.values = values;
instance.sourceInformation = walkerSourceInformation.getSourceInformation(ctx);
result = instance;
} else {
// TODO
throw new UnsupportedOperationException();
}
} catch (Exception e) {
throw new UnsupportedOperationException(ctx.getText());
}
return result;
}
use of org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.CInteger in project legend-engine by finos.
the class NavigationParseTreeWalker method getInstanceInteger.
private CInteger getInstanceInteger(String integerString) {
List<Long> values = new ArrayList<>();
values.add(Long.parseLong(integerString));
CInteger instance = new CInteger();
instance.multiplicity = getMultiplicityOneOne();
instance.values = values;
return instance;
}
use of org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.CInteger in project legend-engine by finos.
the class DomainParseTreeWalker method expression.
private ValueSpecification expression(DomainParserGrammar.ExpressionContext ctx, String exprName, List<String> typeParametersNames, LambdaContext lambdaContext, String space, boolean wrapFlag, boolean addLines) {
ValueSpecification result;
List<ValueSpecification> expressions = Lists.mutable.of();
List<ValueSpecification> parameters;
if (ctx.combinedExpression() != null) {
return this.combinedExpression(ctx.combinedExpression(), exprName, typeParametersNames, lambdaContext, space, wrapFlag, addLines);
}
if (ctx.atomicExpression() != null) {
result = this.atomicExpression(ctx.atomicExpression(), typeParametersNames, lambdaContext, space, wrapFlag, addLines);
} else if (ctx.notExpression() != null) {
result = this.notExpression(ctx.notExpression(), exprName, typeParametersNames, lambdaContext, space, addLines);
} else if (ctx.signedExpression() != null) {
result = this.signedExpression(ctx.signedExpression(), exprName, typeParametersNames, lambdaContext, space, addLines);
} else if (ctx.expressionsArray() != null) {
for (DomainParserGrammar.ExpressionContext eCtx : ctx.expressionsArray().expression()) {
expressions.add(this.expression(eCtx, exprName, typeParametersNames, lambdaContext, space, false, addLines));
}
result = this.collect(expressions, walkerSourceInformation.getSourceInformation(ctx));
} else {
throw new EngineException(ctx.getText() + " is not supported", walkerSourceInformation.getSourceInformation(ctx), EngineErrorType.PARSER);
}
if (ctx.propertyOrFunctionExpression() != null) {
for (DomainParserGrammar.PropertyOrFunctionExpressionContext pfCtx : ctx.propertyOrFunctionExpression()) {
if (pfCtx.propertyExpression() != null) {
result = propertyExpression(pfCtx.propertyExpression(), result, typeParametersNames, lambdaContext, space, addLines);
} else // TODO PropertyBracketExpression is deprecated. Remove else if clause once all use has been addressed
if (pfCtx.propertyBracketExpression() != null) {
if (!allowPropertyBracketExpression) {
throw new EngineException("Bracket operation is not supported", walkerSourceInformation.getSourceInformation(pfCtx.propertyBracketExpression()), EngineErrorType.PARSER);
}
String getPropertyName = "oneString";
parameters = new ArrayList<>();
AppliedProperty appliedProperty = new AppliedProperty();
appliedProperty.property = getPropertyName;
appliedProperty.parameters = Lists.mutable.of(result).withAll(parameters);
if (pfCtx.propertyBracketExpression().STRING() != null) {
CString instance = getInstanceString(pfCtx.propertyBracketExpression().STRING().getText());
instance.sourceInformation = walkerSourceInformation.getSourceInformation(pfCtx.propertyBracketExpression());
appliedProperty.parameters.add(instance);
} else {
CInteger instance = getInstanceInteger(pfCtx.propertyBracketExpression().INTEGER().getText());
instance.sourceInformation = walkerSourceInformation.getSourceInformation(pfCtx.propertyBracketExpression());
appliedProperty.parameters.add(instance);
}
appliedProperty.sourceInformation = walkerSourceInformation.getSourceInformation(pfCtx.propertyBracketExpression());
result = appliedProperty;
} else {
for (int i = 0; i < pfCtx.functionExpression().qualifiedName().size(); i++) {
parameters = this.functionExpressionParameters(pfCtx.functionExpression().functionExpressionParameters(i), typeParametersNames, lambdaContext, addLines, space);
parameters.add(0, result);
result = this.functionExpression(pfCtx.functionExpression().qualifiedName(i), parameters);
}
}
}
}
if (ctx.equalNotEqual() != null) {
result = this.equalNotEqual(ctx.equalNotEqual(), result, exprName, typeParametersNames, lambdaContext, space, wrapFlag, addLines);
}
return result;
}
use of org.finos.legend.engine.protocol.pure.v1.model.valueSpecification.raw.CInteger in project legend-engine by finos.
the class DomainParseTreeWalker method getInstanceInteger.
private CInteger getInstanceInteger(String integerString) {
List<Long> values = new ArrayList<>();
values.add(Long.parseLong(integerString));
CInteger instance = new CInteger();
instance.multiplicity = getMultiplicityOneOne();
instance.values = values;
return instance;
}
Aggregations