use of org.eclipse.sirius.viewpoint.description.tool.Default in project sirius-components by eclipse-sirius.
the class SwitchOperationHandler method handle.
@Override
public IStatus handle(Map<String, Object> variables) {
EList<Case> switchCases = this.switchOperation.getCases();
Map<String, Object> childVariables = new HashMap<>(variables);
IStatus status = new Success();
boolean oneCaseHasBeenExecuted = false;
for (Case switchCase : switchCases) {
String conditionExpression = switchCase.getConditionExpression();
if (conditionExpression != null) {
Optional<Boolean> optionalValueObject = this.interpreter.evaluateExpression(variables, conditionExpression).asBoolean();
if (optionalValueObject.isPresent() && optionalValueObject.get()) {
List<ModelOperation> subModelOperations = switchCase.getSubModelOperations();
status = this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations);
oneCaseHasBeenExecuted = true;
break;
}
}
}
if (!oneCaseHasBeenExecuted) {
Default defaultCase = this.switchOperation.getDefault();
if (defaultCase != null) {
List<ModelOperation> subModelOperations = defaultCase.getSubModelOperations();
status = this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, childVariables, subModelOperations);
}
}
return status;
}
Aggregations