use of org.talend.hadoop.distribution.condition.NestedComponentCondition 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.NestedComponentCondition in project tbd-studio-se by Talend.
the class DynamicSparkStreamingKinesisNodeModuleGroup method getModuleGroups.
@Override
public Set<DistributionModuleGroup> getModuleGroups(String distribution, String version) throws Exception {
Set<DistributionModuleGroup> hs = new HashSet<>();
DynamicPluginAdapter pluginAdapter = getPluginAdapter();
String spark2KinesisMrRequiredRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.SPARK2_KINESIS_MRREQUIRED_MODULE_GROUP.getModuleName());
checkRuntimeId(spark2KinesisMrRequiredRuntimeId);
if (StringUtils.isNotBlank(spark2KinesisMrRequiredRuntimeId)) {
DistributionModuleGroup dmgSpark2 = new DistributionModuleGroup(spark2KinesisMrRequiredRuntimeId, true, new NestedComponentCondition(new MultiComponentCondition(new SparkStreamingLinkedNodeCondition(distribution, version).getCondition(), BooleanOperator.AND, spark2Condition)));
hs.add(dmgSpark2);
}
return hs;
}
use of org.talend.hadoop.distribution.condition.NestedComponentCondition in project tbd-studio-se by Talend.
the class DynamicSparkStreamingKafkaClientModuleGroup method getModuleGroups.
@Override
public Set<DistributionModuleGroup> getModuleGroups(String distribution, String version) throws Exception {
Set<DistributionModuleGroup> hs = new HashSet<>();
DynamicPluginAdapter pluginAdapter = getPluginAdapter();
String sparkKafkaClientMrRequiredRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.SPARK_KAFKA_CLIENT_MRREQUIRED_MODULE_GROUP.getModuleName());
String spark2KafkaClientMrRequiredRuntimeId = pluginAdapter.getRuntimeModuleGroupIdByTemplateId(DynamicModuleGroupConstant.SPARK2_KAFKA_CLIENT_MRREQUIRED_MODULE_GROUP.getModuleName());
checkRuntimeId(sparkKafkaClientMrRequiredRuntimeId);
checkRuntimeId(spark2KafkaClientMrRequiredRuntimeId);
if (StringUtils.isNotBlank(sparkKafkaClientMrRequiredRuntimeId)) {
// Spark 1
DistributionModuleGroup dmgSpark1 = new DistributionModuleGroup(sparkKafkaClientMrRequiredRuntimeId, true, new NestedComponentCondition(new MultiComponentCondition(new SparkStreamingLinkedNodeCondition(distribution, version, SparkStreamingConstant.KAFKA_SPARKCONFIGURATION_LINKEDPARAMETER).getCondition(), BooleanOperator.AND, spark1Condition)));
hs.add(dmgSpark1);
}
if (StringUtils.isNotBlank(spark2KafkaClientMrRequiredRuntimeId)) {
// Spark 2
DistributionModuleGroup dmgSpark2 = new DistributionModuleGroup(spark2KafkaClientMrRequiredRuntimeId, true, new NestedComponentCondition(new MultiComponentCondition(new SparkStreamingLinkedNodeCondition(distribution, version, SparkStreamingConstant.KAFKA_SPARKCONFIGURATION_LINKEDPARAMETER).getCondition(), BooleanOperator.AND, spark2Condition)));
hs.add(dmgSpark2);
}
return hs;
}
use of org.talend.hadoop.distribution.condition.NestedComponentCondition in project tbd-studio-se by Talend.
the class ComponentConditionUtil method buildDistributionShowIf.
/**
* This method creates a condition made of other conditions, contained in the given Set of conditions.
*
* @param conditions - the Set of conditions to merge in a single condition.
* @return a new ComponentCondition made of the other conditions. Returns null in case of at least one condition is
* null.
*/
public static ComponentCondition buildDistributionShowIf(Set<ComponentCondition> conditions) {
if (conditions != null) {
Iterator<ComponentCondition> iter = conditions.iterator();
ComponentCondition previous = null;
while (iter.hasNext()) {
ComponentCondition cc = iter.next();
if (cc == null) {
return null;
}
ComponentCondition wrappedCondition = new NestedComponentCondition(cc);
if (previous != null) {
wrappedCondition = new MultiComponentCondition(previous, BooleanOperator.OR, wrappedCondition);
}
previous = wrappedCondition;
}
if (previous != null) {
return new NestedComponentCondition(previous);
}
}
return null;
}
use of org.talend.hadoop.distribution.condition.NestedComponentCondition 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);
}
Aggregations