Commit bf188a6b authored by Romain Bioteau's avatar Romain Bioteau
Browse files

BS-10783

Fix typo
Refactoring add converter to ease unit testing
parent 02e45eff
......@@ -40,15 +40,22 @@ Require-Bundle: org.bonitasoft.studio.model;bundle-version="1.0.0",
assertj-core;bundle-version="1.5.0";resolution:=optional,
org.bonitasoft.studio.expression.editor,
org.bonitasoft.studio.groovy,
org.bonitasoft.studio.data
Export-Package: org.bonitasoft.studio.engine,org.bonitasoft.studio.eng
ine.command,org.bonitasoft.studio.engine.config,org.bonitasoft.studio
.engine.contribution,org.bonitasoft.studio.engine.export,org.bonitaso
ft.studio.engine.export.switcher,org.bonitasoft.studio.engine.i18n;x-
friends:="org.bonitasoft.studio.engine.test",org.bonitasoft.studio.en
gine.operation,org.bonitasoft.studio.engine.preferences,org.bonitasof
t.studio.engine.store,org.bonitasoft.studio.engine.ui,org.bonitasoft.
studio.engine.ui.dialog,org.bonitasoft.studio.engine.ui.wizard
org.bonitasoft.studio.data,
org.bonitasoft.studio.tests-utils;bundle-version="6.4.0";resolution:=optional
Export-Package: org.bonitasoft.studio.engine,
org.bonitasoft.studio.engine.command,
org.bonitasoft.studio.engine.config,
org.bonitasoft.studio.engine.contribution,
org.bonitasoft.studio.engine.export,
org.bonitasoft.studio.engine.export.expression.converter.comparison,
org.bonitasoft.studio.engine.export.switcher,
org.bonitasoft.studio.engine.i18n;x-friends:="org.bonitasoft.studio.engine.test",
org.bonitasoft.studio.engine.operation,
org.bonitasoft.studio.engine.preferences,
org.bonitasoft.studio.engine.store,
org.bonitasoft.studio.engine.ui,
org.bonitasoft.studio.engine.ui.dialog,
org.bonitasoft.studio.engine.ui.wizard
Bundle-Activator: org.bonitasoft.studio.engine.EnginePlugin
Bundle-ActivationPolicy: lazy
Import-Package: org.bonitasoft.engine.api,
......
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.engine.export.expression.converter.comparison;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doReturn;
import org.bonitasoft.engine.expression.ExpressionType;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.condition.conditionModel.ConditionModelFactory;
import org.bonitasoft.studio.condition.conditionModel.Expression_ProcessRef;
import org.bonitasoft.studio.condition.conditionModel.Operation_Compare;
import org.bonitasoft.studio.condition.conditionModel.Operation_Less_Equals;
import org.bonitasoft.studio.condition.conditionModel.Operation_NotUnary;
import org.bonitasoft.studio.condition.conditionModel.Operation_Unary;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.expression.builders.ExpressionBuilder;
import org.bonitasoft.studio.model.parameter.Parameter;
import org.bonitasoft.studio.model.parameter.builders.ParameterBuilder;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.builders.BooleanDataTypeBuilder;
import org.bonitasoft.studio.model.process.builders.DataBuilder;
import org.bonitasoft.studio.model.process.builders.DoubleDataTypeBuilder;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Spy;
import org.mockito.runners.MockitoJUnitRunner;
/**
* @author Romain Bioteau
*
*/
@RunWith(MockitoJUnitRunner.class)
public class ComparisonExpressionConverterTest {
@Spy
private ComparisonExpressionConverter comparisonExpressionConverter;
private Data variable;
private Parameter parameter;
private Expression binaryExpression;
private Data validVariable;
private Expression notUnaryExpression;
private Expression unaryExpression;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
variable = DataBuilder.createDataBuilder().withName("amount").havingDataType(DoubleDataTypeBuilder.create()).build();
validVariable = DataBuilder.createDataBuilder().withName("valid").havingDataType(BooleanDataTypeBuilder.create()).build();
parameter = ParameterBuilder.create().withName("commission").withType(Double.class.getName()).build();
binaryExpression = ExpressionBuilder.create()
.withExpressionType(ExpressionConstants.CONDITION_TYPE)
.withContent("amount <= commission")
.withReturnType(Boolean.class.getName())
.havingReferencedElements(EcoreUtil.copy(variable), EcoreUtil.copy(parameter)).build();
notUnaryExpression = ExpressionBuilder.create()
.withExpressionType(ExpressionConstants.CONDITION_TYPE)
.withContent("!valid")
.withReturnType(Boolean.class.getName())
.havingReferencedElements(EcoreUtil.copy(validVariable)).build();
unaryExpression = ExpressionBuilder.create()
.withExpressionType(ExpressionConstants.CONDITION_TYPE)
.withContent("valid")
.withReturnType(Boolean.class.getName())
.havingReferencedElements(EcoreUtil.copy(validVariable)).build();
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
@Test
public void should_appliesTo_Condition_expression_type() throws Exception {
assertThat(comparisonExpressionConverter.appliesTo(binaryExpression)).isTrue();
assertThat(comparisonExpressionConverter.appliesTo(null)).isFalse();
assertThat(comparisonExpressionConverter.appliesTo(ExpressionBuilder.create().withExpressionType(ExpressionConstants.CONSTANT_TYPE).build())).isFalse();
}
@Test
public void should_convert_a_studio_expression_into_an_engine_expression_returns_null_if_parsing_fail() throws Exception {
doReturn(null).when(comparisonExpressionConverter).parseConditionExpression(binaryExpression.getContent(), null);
assertThat(comparisonExpressionConverter.convert(binaryExpression)).isNull();
doReturn(ConditionModelFactory.eINSTANCE.createOperation_Compare()).when(comparisonExpressionConverter).parseConditionExpression(
binaryExpression.getContent(), null);
assertThat(comparisonExpressionConverter.convert(binaryExpression)).isNull();
final Operation_Compare compare = ConditionModelFactory.eINSTANCE.createOperation_Compare();
compare.setOp(ConditionModelFactory.eINSTANCE.createExpression_Integer());
doReturn(compare).when(comparisonExpressionConverter).parseConditionExpression(
binaryExpression.getContent(), null);
assertThat(comparisonExpressionConverter.convert(binaryExpression)).isNull();
}
@Test
public void should_convert_a_studio_expression_into_an_engine_expression_for_binary_operation() throws Exception {
final Operation_Compare binaryOperation = ConditionModelFactory.eINSTANCE.createOperation_Compare();
final Operation_Less_Equals less_Equals = ConditionModelFactory.eINSTANCE.createOperation_Less_Equals();
final Expression_ProcessRef processRef = ConditionModelFactory.eINSTANCE.createExpression_ProcessRef();
processRef.setValue(EcoreUtil.copy(variable));
less_Equals.setLeft(processRef);
final Expression_ProcessRef param_Ref = ConditionModelFactory.eINSTANCE.createExpression_ProcessRef();
param_Ref.setValue(EcoreUtil.copy(parameter));
less_Equals.setRight(param_Ref);
binaryOperation.setOp(less_Equals);
doReturn(binaryOperation).when(comparisonExpressionConverter).parseConditionExpression(binaryExpression.getContent(), null);
final org.bonitasoft.engine.expression.Expression engineExpression = comparisonExpressionConverter.convert(binaryExpression);
assertThat(engineExpression).isNotNull();
assertThat(engineExpression.getExpressionType()).isEqualTo(ExpressionType.TYPE_CONDITION.name());
assertThat(engineExpression.getContent()).isEqualTo("<=");
assertThat(engineExpression.getReturnType()).isEqualTo(Boolean.class.getName());
assertThat(engineExpression.getDependencies()).hasSize(2);
final org.bonitasoft.engine.expression.Expression leftOperand = engineExpression.getDependencies().get(0);
assertThat(leftOperand.getExpressionType()).isEqualTo(ExpressionType.TYPE_VARIABLE.name());
assertThat(leftOperand.getContent()).isEqualTo("amount");
final org.bonitasoft.engine.expression.Expression rightOperand = engineExpression.getDependencies().get(1);
assertThat(rightOperand.getExpressionType()).isEqualTo(ExpressionType.TYPE_PARAMETER.name());
assertThat(rightOperand.getContent()).isEqualTo("commission");
}
@Test
public void should_convert_a_studio_expression_into_an_engine_expression_for_notunary_operation() throws Exception {
final Operation_Compare operation_Compare = ConditionModelFactory.eINSTANCE.createOperation_Compare();
final Operation_NotUnary unaryOperation = ConditionModelFactory.eINSTANCE.createOperation_NotUnary();
final Expression_ProcessRef processRef = ConditionModelFactory.eINSTANCE.createExpression_ProcessRef();
processRef.setValue(EcoreUtil.copy(validVariable));
unaryOperation.setValue(processRef);
operation_Compare.setOp(unaryOperation);
doReturn(operation_Compare).when(comparisonExpressionConverter).parseConditionExpression(notUnaryExpression.getContent(), null);
final org.bonitasoft.engine.expression.Expression engineExpression = comparisonExpressionConverter.convert(notUnaryExpression);
assertThat(engineExpression).isNotNull();
assertThat(engineExpression.getExpressionType()).isEqualTo(ExpressionType.TYPE_CONDITION.name());
assertThat(engineExpression.getContent()).isEqualTo("!");
assertThat(engineExpression.getReturnType()).isEqualTo(Boolean.class.getName());
assertThat(engineExpression.getDependencies()).hasSize(1);
final org.bonitasoft.engine.expression.Expression operand = engineExpression.getDependencies().get(0);
assertThat(operand.getExpressionType()).isEqualTo(ExpressionType.TYPE_VARIABLE.name());
assertThat(operand.getContent()).isEqualTo("valid");
}
@Test
public void should_convert_a_studio_expression_into_an_engine_expression_for_unary_operation() throws Exception {
final Operation_Compare operation_Compare = ConditionModelFactory.eINSTANCE.createOperation_Compare();
final Operation_Unary unaryOperation = ConditionModelFactory.eINSTANCE.createOperation_Unary();
final Expression_ProcessRef processRef = ConditionModelFactory.eINSTANCE.createExpression_ProcessRef();
processRef.setValue(EcoreUtil.copy(validVariable));
unaryOperation.setValue(processRef);
operation_Compare.setOp(unaryOperation);
doReturn(operation_Compare).when(comparisonExpressionConverter).parseConditionExpression(unaryExpression.getContent(), null);
final org.bonitasoft.engine.expression.Expression engineExpression = comparisonExpressionConverter.convert(unaryExpression);
assertThat(engineExpression).isNotNull();
assertThat(engineExpression.getExpressionType()).isEqualTo(ExpressionType.TYPE_VARIABLE.name());
assertThat(engineExpression.getContent()).isEqualTo("valid");
assertThat(engineExpression.getReturnType()).isEqualTo(Boolean.class.getName());
assertThat(engineExpression.getDependencies()).isEmpty();
}
}
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.engine.export.expression.converter.comparison;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.engine.expression.Expression;
import org.bonitasoft.engine.expression.ExpressionType;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.condition.conditionModel.ConditionModelFactory;
import org.bonitasoft.studio.condition.conditionModel.Expression_Boolean;
import org.bonitasoft.studio.condition.conditionModel.Expression_Double;
import org.bonitasoft.studio.condition.conditionModel.Expression_Integer;
import org.bonitasoft.studio.condition.conditionModel.Expression_ProcessRef;
import org.bonitasoft.studio.condition.conditionModel.Expression_String;
import org.bonitasoft.studio.model.expression.builders.ExpressionBuilder;
import org.bonitasoft.studio.model.parameter.Parameter;
import org.bonitasoft.studio.model.parameter.builders.ParameterBuilder;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.builders.DataBuilder;
import org.bonitasoft.studio.model.process.builders.DoubleDataTypeBuilder;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Romain Bioteau
*
*/
public class ExpressionConditionModelSwitchTest {
private ExpressionConditionModelSwitch conditionModelSwitch;
private Data variable;
private Parameter parameter;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
variable = DataBuilder.createDataBuilder().withName("amount").havingDataType(DoubleDataTypeBuilder.create()).build();
parameter = ParameterBuilder.create().withName("commission").withType(Double.class.getName()).build();
final ExpressionBuilder builder = ExpressionBuilder.create()
.withExpressionType(ExpressionConstants.CONDITION_TYPE)
.withContent("amount <= 10000 + commission")
.withReturnType(Boolean.class.getName())
.havingReferencedElements(variable, parameter);
conditionModelSwitch = new ExpressionConditionModelSwitch(builder.build());
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
@Test
public void should_doSwitch_a_Expression_Boolean_returns_a_constant_engine_expression_with_boolean_return_type() throws Exception {
final Expression_Boolean expression_Boolean = ConditionModelFactory.eINSTANCE.createExpression_Boolean();
expression_Boolean.setValue(true);
final Expression expression = conditionModelSwitch.doSwitch(expression_Boolean);
assertThat(expression).isNotNull();
assertThat(expression.getExpressionType()).isEqualTo(ExpressionType.TYPE_CONSTANT.name());
assertThat(expression.getContent()).isEqualTo("true");
assertThat(expression.getReturnType()).isEqualTo(Boolean.class.getName());
}
@Test
public void should_doSwitch_a_Expression_Double_returns_a_constant_engine_expression_with_double_return_type() throws Exception {
final Expression_Double expression_Double = ConditionModelFactory.eINSTANCE.createExpression_Double();
expression_Double.setValue(2000d);
final Expression expression = conditionModelSwitch.doSwitch(expression_Double);
assertThat(expression).isNotNull();
assertThat(expression.getExpressionType()).isEqualTo(ExpressionType.TYPE_CONSTANT.name());
assertThat(expression.getContent()).isEqualTo("2000.0");
assertThat(expression.getReturnType()).isEqualTo(Double.class.getName());
}
@Test
public void should_doSwitch_a_Expression_Integer_returns_a_constant_engine_expression_with_long_return_type() throws Exception {
final Expression_Integer expression_Integer = ConditionModelFactory.eINSTANCE.createExpression_Integer();
expression_Integer.setValue(2000);
final Expression expression = conditionModelSwitch.doSwitch(expression_Integer);
assertThat(expression).isNotNull();
assertThat(expression.getExpressionType()).isEqualTo(ExpressionType.TYPE_CONSTANT.name());
assertThat(expression.getContent()).isEqualTo("2000");
assertThat(expression.getReturnType()).isEqualTo(Long.class.getName());
}
@Test
public void should_doSwitch_a_Expression_String_returns_a_constant_engine_expression_with_String_return_type() throws Exception {
final Expression_String expression_String = ConditionModelFactory.eINSTANCE.createExpression_String();
expression_String.setValue("hello");
Expression expression = conditionModelSwitch.doSwitch(expression_String);
assertThat(expression).isNotNull();
assertThat(expression.getExpressionType()).isEqualTo(ExpressionType.TYPE_CONSTANT.name());
assertThat(expression.getContent()).isEqualTo("hello");
assertThat(expression.getReturnType()).isEqualTo(String.class.getName());
expression_String.setValue("");
expression = conditionModelSwitch.doSwitch(expression_String);
assertThat(expression.getContent()).isEqualTo("");
expression_String.setValue(null);
expression = conditionModelSwitch.doSwitch(expression_String);
assertThat(expression.getContent()).isEqualTo("");
}
@Test
public void should_doSwitch_a_Expression_ProcessRef_returns_a_variable_engine_expression() throws Exception {
final Expression_ProcessRef expression_ProcessRef = ConditionModelFactory.eINSTANCE.createExpression_ProcessRef();
expression_ProcessRef.setValue(EcoreUtil.copy(variable));
final Expression expression = conditionModelSwitch.doSwitch(expression_ProcessRef);
assertThat(expression).isNotNull();
assertThat(expression.getExpressionType()).isEqualTo(ExpressionType.TYPE_VARIABLE.name());
assertThat(expression.getContent()).isEqualTo("amount");
assertThat(expression.getReturnType()).isEqualTo(Double.class.getName());
}
@Test
public void should_doSwitch_a_Expression_ProcessRef_returns_a_parameter_engine_expression() throws Exception {
final Expression_ProcessRef expression_ProcessRef = ConditionModelFactory.eINSTANCE.createExpression_ProcessRef();
expression_ProcessRef.setValue(EcoreUtil.copy(parameter));
final Expression expression = conditionModelSwitch.doSwitch(expression_ProcessRef);
assertThat(expression).isNotNull();
assertThat(expression.getExpressionType()).isEqualTo(ExpressionType.TYPE_PARAMETER.name());
assertThat(expression.getContent()).isEqualTo("commission");
assertThat(expression.getReturnType()).isEqualTo(Double.class.getName());
}
}
/**
* Copyright (C) 2014 BonitaSoft S.A.
* BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.engine.export.expression.converter.comparison;
import static org.assertj.core.api.Assertions.assertThat;
import org.bonitasoft.studio.condition.conditionModel.ConditionModelFactory;
import org.bonitasoft.studio.model.process.ProcessFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Romain Bioteau
*
*/
public class OperatorSwitchTest {
private OperatorSwitch operatorSwitch;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
operatorSwitch = new OperatorSwitch();
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
}
@Test
public void should_doSwitch_return_operator_symbols() throws Exception {
assertThat(operatorSwitch.doSwitch(ConditionModelFactory.eINSTANCE.createOperation_Equals())).isEqualTo("==");
assertThat(operatorSwitch.doSwitch(ConditionModelFactory.eINSTANCE.createOperation_Greater())).isEqualTo(">");
assertThat(operatorSwitch.doSwitch(ConditionModelFactory.eINSTANCE.createOperation_Greater_Equals())).isEqualTo(">=");
assertThat(operatorSwitch.doSwitch(ConditionModelFactory.eINSTANCE.createOperation_Less())).isEqualTo("<");
assertThat(operatorSwitch.doSwitch(ConditionModelFactory.eINSTANCE.createOperation_Less_Equals())).isEqualTo("<=");
assertThat(operatorSwitch.doSwitch(ConditionModelFactory.eINSTANCE.createOperation_Not_Equals())).isEqualTo("!=");
}
@Test
public void should_doSwitch_return_null_if_not_an_operator() throws Exception {
assertThat(operatorSwitch.doSwitch(ProcessFactory.eINSTANCE.createPool())).isNull();
}
}
......@@ -14,10 +14,7 @@
*/
package org.bonitasoft.studio.engine.export;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bonitasoft.engine.expression.Expression;
......@@ -31,47 +28,36 @@ import org.bonitasoft.engine.operation.OperatorType;
import org.bonitasoft.studio.common.DataUtil;
import org.bonitasoft.studio.common.DatasourceConstants;
import org.bonitasoft.studio.common.ExpressionConstants;
import org.bonitasoft.studio.common.emf.tools.ModelHelper;
import org.bonitasoft.studio.common.emf.tools.WidgetHelper;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.repository.RepositoryManager;
import org.bonitasoft.studio.condition.conditionModel.Operation_Compare;
import org.bonitasoft.studio.condition.conditionModel.Operation_NotUnary;
import org.bonitasoft.studio.condition.conditionModel.Unary_Operation;
import org.bonitasoft.studio.condition.conditionModel.util.ConditionModelSwitch;
import org.bonitasoft.studio.condition.scoping.ConditionModelGlobalScopeProvider;
import org.bonitasoft.studio.condition.ui.internal.ConditionModelActivator;
import org.bonitasoft.studio.connector.model.definition.Output;
import org.bonitasoft.studio.engine.EnginePlugin;
import org.bonitasoft.studio.engine.export.switcher.ExpressionConditionModelSwitch;
import org.bonitasoft.studio.engine.export.expression.converter.IExpressionConverter;
import org.bonitasoft.studio.engine.export.expression.converter.comparison.ComparisonExpressionConverter;
import org.bonitasoft.studio.model.expression.ListExpression;
import org.bonitasoft.studio.model.expression.Operation;
import org.bonitasoft.studio.model.expression.TableExpression;
import org.bonitasoft.studio.model.form.GroupIterator;
import org.bonitasoft.studio.model.form.Widget;
import org.bonitasoft.studio.model.parameter.Parameter;
import org.bonitasoft.studio.model.process.AbstractProcess;
import org.bonitasoft.studio.model.process.BusinessObjectData;
import org.bonitasoft.studio.model.process.Data;
import org.bonitasoft.studio.model.process.Document;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.resource.XtextResource;
import org.eclipse.xtext.ui.resource.XtextResourceSetProvider;
import org.eclipse.xtext.util.StringInputStream;
import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.IResourceValidator;
import com.google.inject.Injector;
/**
* @author Romain Bioteau
*/
public class EngineExpressionUtil {
private static List<IExpressionConverter> converters;
static {
converters = new ArrayList<IExpressionConverter>();
converters.add(new ComparisonExpressionConverter());
}
public static org.bonitasoft.engine.operation.Operation createOperation(final Operation operation) {
return createOperation(operation, createLeftOperand(operation.getLeftOperand()));
}
......@@ -420,10 +406,16 @@ public class EngineExpressionUtil {
final org.bonitasoft.studio.model.expression.Expression expression) {
String content = expression.getContent();
if (content != null && !content.isEmpty()) {
final String type = expression.getType();
if (ExpressionConstants.CONDITION_TYPE.equals(type)) {
return createComparisonExpression(expressionBuilder, expression);
final IExpressionConverter converter = getConverter(expression);
if (converter != null) {
try {
return converter.convert(expression);
} catch (final InvalidExpressionException e) {
BonitaStudioLog.error(e, EnginePlugin.PLUGIN_ID);
throw new RuntimeException(e);
}
}
final String type = expression.getType();
if (ExpressionConstants.PATTERN_TYPE.equals(type)) {
return createPatternExpression(expressionBuilder, expression);
}
......@@ -465,6 +457,15 @@ public class EngineExpressionUtil {