use of org.talend.hadoop.distribution.condition.Expression in project tbd-studio-se by Talend.
the class DistributionVersion method getDisplayShowIf.
public String getDisplayShowIf() {
final Expression trueExp = new BooleanExpression(true);
final Expression falseExp = new BooleanExpression(false);
ComponentCondition additionalCondition = displayCondition;
if (additionalCondition != null && (trueExp.getExpressionString().equals(additionalCondition.getConditionString()) || falseExp.getExpressionString().equals(additionalCondition.getConditionString()))) {
// Don't show a version if it's display condition is a BooleanCondition.
return trueExp.getExpressionString().equals(additionalCondition.getConditionString()) ? Boolean.TRUE.toString() : Boolean.FALSE.toString();
} else {
// Compose the ComponentCondition to display a version.
ComponentCondition condition;
org.talend.hadoop.distribution.condition.Expression e = new BasicExpression(distribution.componentType.getDistributionParameter(), EqualityOperator.EQ, distribution.name);
if (additionalCondition != null) {
condition = new MultiComponentCondition(new SimpleComponentCondition(e), BooleanOperator.AND, new NestedComponentCondition(additionalCondition));
} else {
condition = new SimpleComponentCondition(e);
}
return condition.getConditionString();
}
}
use of org.talend.hadoop.distribution.condition.Expression in project tbd-studio-se by Talend.
the class ComponentConditionTest method testGetConditionString.
@Test
public void testGetConditionString() throws Exception {
ComponentCondition dc1 = new SimpleComponentCondition(new BasicExpression(PARAM_1, VALUE_1, EqualityOperator.EQ));
assertEquals(dc1.getConditionString(), LEFT_PAR + PARAM_1 + EQ + SINGLE_QUOTE + VALUE_1 + SINGLE_QUOTE + RIGHT_PAR);
// $NON-NLS-1$ //$NON-NLS-2$
Expression e1 = new BasicExpression("A", "aaa", EqualityOperator.EQ);
// $NON-NLS-1$ //$NON-NLS-2$
Expression e2 = new BasicExpression("Z", "ccc", EqualityOperator.EQ);
// $NON-NLS-1$ //$NON-NLS-2$
Expression e3 = new BasicExpression("A", "bbb", EqualityOperator.EQ);
// $NON-NLS-1$ //$NON-NLS-2$
Expression e4 = new BasicExpression("B", "ccc", EqualityOperator.NOT_EQ);
dc1 = new NestedComponentCondition(new MultiComponentCondition(new SimpleComponentCondition(e1), new NestedComponentCondition(new MultiComponentCondition(new SimpleComponentCondition(e4), new NestedComponentCondition(new MultiComponentCondition(new SimpleComponentCondition(e2), new SimpleComponentCondition(e3), BooleanOperator.AND)), BooleanOperator.OR)), BooleanOperator.AND));
assertEquals(dc1.getConditionString(), result1);
dc1 = new MultiComponentCondition(new SimpleComponentCondition(e1), new MultiComponentCondition(new SimpleComponentCondition(e2), new NestedComponentCondition(new MultiComponentCondition(new SimpleComponentCondition(e4), new SimpleComponentCondition(e3), BooleanOperator.OR)), BooleanOperator.AND), BooleanOperator.AND);
assertEquals(dc1.getConditionString(), result2);
}
use of org.talend.hadoop.distribution.condition.Expression in project tbd-studio-se by Talend.
the class DistributionVersionModule method getModuleRequiredIf.
public ComponentCondition getModuleRequiredIf() {
ComponentCondition condition;
// The import is needed only if the good version and the good distribution are selected, and
// if the Distribution is shown. The second condition to take the
// USE_EXISTING_CONNECTIOn into account.
final ComponentType componentType = distributionVersion.distribution.componentType;
Expression distributionSelected = new BasicExpression(componentType.getDistributionParameter(), EqualityOperator.EQ, distributionVersion.distribution.name);
Expression distributionVersionSelected = new BasicExpression(componentType.getVersionParameter(), EqualityOperator.EQ, distributionVersion.version);
Expression distributionShown = new ShowExpression(componentType.getDistributionParameter());
condition = new MultiComponentCondition(new SimpleComponentCondition(distributionSelected), BooleanOperator.AND, new MultiComponentCondition(new SimpleComponentCondition(distributionVersionSelected), BooleanOperator.AND, new SimpleComponentCondition(distributionShown)));
if (moduleGroup.getRequiredIf() != null) {
condition = new MultiComponentCondition(condition, BooleanOperator.AND, new NestedComponentCondition(moduleGroup.getRequiredIf()));
}
return condition;
}
use of org.talend.hadoop.distribution.condition.Expression in project tbd-studio-se by Talend.
the class ExpressionTest method testGetExpressionString.
@Test
public void testGetExpressionString() throws Exception {
Expression e1 = new BasicExpression(PARAM_1, VALUE_1, EqualityOperator.EQ);
assertEquals(e1.getExpressionString(), LEFT_PAR + PARAM_1 + EQ + SINGLE_QUOTE + VALUE_1 + SINGLE_QUOTE + RIGHT_PAR);
e1 = new BasicExpression(PARAM_1, VALUE_1, EqualityOperator.NOT_EQ);
assertEquals(e1.getExpressionString(), LEFT_PAR + PARAM_1 + NEQ + SINGLE_QUOTE + VALUE_1 + SINGLE_QUOTE + RIGHT_PAR);
e1 = new LinkedNodeExpression(SparkBatchConstant.SPARK_BATCH_SPARKCONFIGURATION_LINKEDPARAMETER, SparkBatchConstant.SPARK_BATCH_AZURE_SPARKCONFIGURATION_LINKEDPARAMETER, EqualityOperator.GE, ESparkVersion.SPARK_3_0.getSparkVersion());
// $NON-NLS-1$
assertEquals("(#LINK@NODE.SPARK_CONFIGURATION.STORAGE_CONFIGURATION ge 'SPARK_3_0_x')", e1.getExpressionString());
}
Aggregations