This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/master by this push:
new e36c39eede Cleanup XML of action Simple Eval #1991
new a9b1c5d975 Merge pull request #2905 from nadment/1991
e36c39eede is described below
commit e36c39eede8527a68665e0984a20788706efca0f
Author: Nicolas Adment <[email protected]>
AuthorDate: Sat May 6 21:41:22 2023 +0200
Cleanup XML of action Simple Eval #1991
---
.../actions/simpleeval/ActionSimpleEval.java | 774 ++++++++-------------
.../actions/simpleeval/ActionSimpleEvalDialog.java | 248 +++----
.../simpleeval/messages/messages_de_DE.properties | 1 -
.../simpleeval/messages/messages_en_US.properties | 3 +-
.../simpleeval/messages/messages_es_AR.properties | 2 +-
.../simpleeval/messages/messages_fr_FR.properties | 1 -
.../simpleeval/messages/messages_it_IT.properties | 1 -
.../simpleeval/messages/messages_ko_KR.properties | 1 -
.../simpleeval/messages/messages_pt_BR.properties | 2 +-
.../simpleeval/messages/messages_zh_CN.properties | 2 +-
.../actions/simpleeval/ActionSimpleEvalTest.java | 63 ++
.../WorkflowActionSimpleEvalLoadSaveTest.java | 71 --
.../src/test/resources/simple-eval-action.xml | 30 +
13 files changed, 493 insertions(+), 706 deletions(-)
diff --git
a/plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEval.java
b/plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEval.java
index 1a5dcd3386..381f61b2ab 100644
---
a/plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEval.java
+++
b/plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEval.java
@@ -22,18 +22,15 @@ import org.apache.hop.core.Result;
import org.apache.hop.core.RowMetaAndData;
import org.apache.hop.core.annotations.Action;
import org.apache.hop.core.exception.HopException;
-import org.apache.hop.core.exception.HopXmlException;
import org.apache.hop.core.row.value.ValueMetaString;
import org.apache.hop.core.util.StringUtil;
import org.apache.hop.core.util.Utils;
-import org.apache.hop.core.variables.IVariables;
-import org.apache.hop.core.xml.XmlHandler;
import org.apache.hop.i18n.BaseMessages;
-import org.apache.hop.metadata.api.IHopMetadataProvider;
+import org.apache.hop.metadata.api.HopMetadataProperty;
+import org.apache.hop.metadata.api.IEnumHasCode;
+import org.apache.hop.metadata.api.IEnumHasCodeAndDescription;
import org.apache.hop.workflow.action.ActionBase;
import org.apache.hop.workflow.action.IAction;
-import org.w3c.dom.Node;
-
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -50,350 +47,267 @@ import java.util.regex.Pattern;
documentationUrl = "/workflow/actions/simpleeval.html")
public class ActionSimpleEval extends ActionBase implements Cloneable, IAction
{
private static final Class<?> PKG = ActionSimpleEval.class; // For Translator
+
+ public enum ValueType implements IEnumHasCodeAndDescription {
+ FIELD("field", BaseMessages.getString(PKG,
"ActionSimpleEval.EvalPreviousField.Label")),
+ VARIABLE("variable", BaseMessages.getString(PKG,
"ActionSimpleEval.EvalVariable.Label"));
- public static final String[] valueTypeDesc =
- new String[] {
- BaseMessages.getString(PKG,
"ActionSimpleEval.EvalPreviousField.Label"),
- BaseMessages.getString(PKG, "ActionSimpleEval.EvalVariable.Label"),
- };
- public static final String[] valueTypeCode = new String[] {"field",
"variable"};
- public static final int VALUE_TYPE_FIELD = 0;
- public static final int VALUE_TYPE_VARIABLE = 1;
- public int valuetype;
-
- public static final String[] successConditionDesc =
- new String[] {
- BaseMessages.getString(PKG, "ActionSimpleEval.SuccessWhenEqual.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenDifferent.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenContains.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotContains.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenStartWith.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotStartWith.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenEndWith.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotEndWith.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenRegExp.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenInList.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotInList.Label")
- };
- public static final String[] successConditionCode =
- new String[] {
- "equal",
- "different",
- "contains",
- "notcontains",
- "startswith",
- "notstatwith",
- "endswith",
- "notendwith",
- "regexp",
- "inlist",
- "notinlist"
- };
-
- public static final int SUCCESS_CONDITION_EQUAL = 0;
- public static final int SUCCESS_CONDITION_DIFFERENT = 1;
- public static final int SUCCESS_CONDITION_CONTAINS = 2;
- public static final int SUCCESS_CONDITION_NOT_CONTAINS = 3;
- public static final int SUCCESS_CONDITION_START_WITH = 4;
- public static final int SUCCESS_CONDITION_NOT_START_WITH = 5;
- public static final int SUCCESS_CONDITION_END_WITH = 6;
- public static final int SUCCESS_CONDITION_NOT_END_WITH = 7;
- public static final int SUCCESS_CONDITION_REGEX = 8;
- public static final int SUCCESS_CONDITION_IN_LIST = 9;
- public static final int SUCCESS_CONDITION_NOT_IN_LIST = 10;
-
- public int successcondition;
-
- public static final String[] fieldTypeDesc =
- new String[] {
- BaseMessages.getString(PKG, "ActionSimpleEval.FieldTypeString.Label"),
- BaseMessages.getString(PKG, "ActionSimpleEval.FieldTypeNumber.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.FieldTypeDateTime.Label"),
- BaseMessages.getString(PKG, "ActionSimpleEval.FieldTypeBoolean.Label"),
- };
- public static final String[] fieldTypeCode =
- new String[] {"string", "number", "datetime", "boolean"};
- public static final int FIELD_TYPE_STRING = 0;
- public static final int FIELD_TYPE_NUMBER = 1;
- public static final int FIELD_TYPE_DATE_TIME = 2;
- public static final int FIELD_TYPE_BOOLEAN = 3;
-
- public int fieldtype;
-
- public static final String[] successNumberConditionDesc =
- new String[] {
- BaseMessages.getString(PKG, "ActionSimpleEval.SuccessWhenEqual.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenDifferent.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenSmallThan.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenSmallOrEqualThan.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenGreaterThan.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenGreaterOrEqualThan.Label"),
- BaseMessages.getString(PKG, "ActionSimpleEval.SuccessBetween.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenInList.Label"),
- BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotInList.Label"),
- };
- public static final String[] successNumberConditionCode =
- new String[] {
- "equal",
- "different",
- "smaller",
- "smallequal",
- "greater",
- "greaterequal",
- "between",
- "inlist",
- "notinlist"
- };
- public static final int SUCCESS_NUMBER_CONDITION_EQUAL = 0;
- public static final int SUCCESS_NUMBER_CONDITION_DIFFERENT = 1;
- public static final int SUCCESS_NUMBER_CONDITION_SMALLER = 2;
- public static final int SUCCESS_NUMBER_CONDITION_SMALLER_EQUAL = 3;
- public static final int SUCCESS_NUMBER_CONDITION_GREATER = 4;
- public static final int SUCCESS_NUMBER_CONDITION_GREATER_EQUAL = 5;
- public static final int SUCCESS_NUMBER_CONDITION_BETWEEN = 6;
- public static final int SUCCESS_NUMBER_CONDITION_IN_LIST = 7;
- public static final int SUCCESS_NUMBER_CONDITION_NOT_IN_LIST = 8;
-
- public int successnumbercondition;
-
- public static final String[] successBooleanConditionDesc =
- new String[] {
- BaseMessages.getString(PKG, "ActionSimpleEval.SuccessWhenTrue.Label"),
- BaseMessages.getString(PKG, "ActionSimpleEval.SuccessWhenFalse.Label")
- };
- public static final String[] successBooleanConditionCode = new String[]
{"true", "false"};
- public static final int SUCCESS_BOOLEAN_CONDITION_TRUE = 0;
- public static final int SUCCESS_BOOLEAN_CONDITION_FALSE = 1;
-
- public int successbooleancondition;
-
- private String fieldname;
- private String variablename;
- private String mask;
- private String comparevalue;
- private String minvalue;
- private String maxvalue;
+ private final String code;
+ private final String description;
- private boolean successwhenvarset;
+ ValueType(String code, String description) {
+ this.code = code;
+ this.description = description;
+ }
- public ActionSimpleEval(String n) {
- super(n, "");
- valuetype = VALUE_TYPE_FIELD;
- successcondition = SUCCESS_CONDITION_EQUAL;
- successnumbercondition = SUCCESS_NUMBER_CONDITION_EQUAL;
- successbooleancondition = SUCCESS_BOOLEAN_CONDITION_FALSE;
- minvalue = null;
- maxvalue = null;
- comparevalue = null;
- fieldname = null;
- variablename = null;
- fieldtype = FIELD_TYPE_STRING;
- mask = null;
- successwhenvarset = false;
- }
+ public static String[] getDescriptions() {
+ return IEnumHasCodeAndDescription.getDescriptions(ValueType.class);
+ }
- public ActionSimpleEval() {
- this("");
- }
+ public static ValueType lookupDescription(String description) {
+ return IEnumHasCodeAndDescription.lookupDescription(ValueType.class,
description, FIELD);
+ }
- @Override
- public Object clone() {
- ActionSimpleEval je = (ActionSimpleEval) super.clone();
- return je;
- }
+ public static ValueType lookupCode(String code) {
+ return IEnumHasCode.lookupCode(ValueType.class, code, FIELD);
+ }
- private static String getValueTypeCode(int i) {
- if (i < 0 || i >= valueTypeCode.length) {
- return valueTypeCode[0];
+ @Override
+ public String getCode() {
+ return code;
}
- return valueTypeCode[i];
- }
- private static String getFieldTypeCode(int i) {
- if (i < 0 || i >= fieldTypeCode.length) {
- return fieldTypeCode[0];
+ @Override
+ public String getDescription() {
+ return description;
}
- return fieldTypeCode[i];
}
- private static String getSuccessConditionCode(int i) {
- if (i < 0 || i >= successConditionCode.length) {
- return successConditionCode[0];
+ public enum SuccessStringCondition implements IEnumHasCodeAndDescription {
+ EQUAL("equal", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenEqual.Label")),
+ DIFFERENT("different",BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenDifferent.Label")),
+ CONTAINS("contains", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenContains.Label")),
+ NOT_CONTAINS("notcontains", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotContains.Label")),
+ START_WITH("startswith", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenStartWith.Label")),
+ NOT_START_WITH("notstatwith", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotStartWith.Label")),
+ END_WITH("endswith", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenEndWith.Label")),
+ NOT_END_WITH("notendwith", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotEndWith.Label")),
+ REGEX("regexp", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenRegExp.Label")),
+ IN_LIST("inlist", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenInList.Label")),
+ NOT_IN_LIST("notinlist", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotInList.Label"));
+
+ private final String code;
+ private final String description;
+
+ SuccessStringCondition(String code, String description) {
+ this.code = code;
+ this.description = description;
}
- return successConditionCode[i];
- }
- public static String getSuccessNumberConditionCode(int i) {
- if (i < 0 || i >= successNumberConditionCode.length) {
- return successNumberConditionCode[0];
+ public static String[] getDescriptions() {
+ return
IEnumHasCodeAndDescription.getDescriptions(SuccessStringCondition.class);
}
- return successNumberConditionCode[i];
- }
- private static String getSuccessBooleanConditionCode(int i) {
- if (i < 0 || i >= successBooleanConditionCode.length) {
- return successBooleanConditionCode[0];
+ public static SuccessStringCondition lookupDescription(String description)
{
+ return
IEnumHasCodeAndDescription.lookupDescription(SuccessStringCondition.class,
description, EQUAL);
}
- return successBooleanConditionCode[i];
- }
- @Override
- public String getXml() {
- StringBuilder xml = new StringBuilder(300);
-
- xml.append(super.getXml());
- xml.append(" ").append(XmlHandler.addTagValue("valuetype",
getValueTypeCode(valuetype)));
- xml.append(" ").append(XmlHandler.addTagValue("fieldname",
fieldname));
- xml.append(" ").append(XmlHandler.addTagValue("variablename",
variablename));
- xml.append(" ").append(XmlHandler.addTagValue("fieldtype",
getFieldTypeCode(fieldtype)));
- xml.append(" ").append(XmlHandler.addTagValue("mask", mask));
- xml.append(" ").append(XmlHandler.addTagValue("comparevalue",
comparevalue));
- xml.append(" ").append(XmlHandler.addTagValue("minvalue", minvalue));
- xml.append(" ").append(XmlHandler.addTagValue("maxvalue", maxvalue));
- xml.append(" ")
- .append(
- XmlHandler.addTagValue("successcondition",
getSuccessConditionCode(successcondition)));
- xml.append(" ")
- .append(
- XmlHandler.addTagValue(
- "successnumbercondition",
getSuccessNumberConditionCode(successnumbercondition)));
- xml.append(" ")
- .append(
- XmlHandler.addTagValue(
- "successbooleancondition",
- getSuccessBooleanConditionCode(successbooleancondition)));
- xml.append(" ").append(XmlHandler.addTagValue("successwhenvarset",
successwhenvarset));
- return xml.toString();
- }
+ public static SuccessStringCondition lookupCode(String code) {
+ return IEnumHasCode.lookupCode(SuccessStringCondition.class, code,
EQUAL);
+ }
- private static int getValueTypeByCode(String tt) {
- if (tt == null) {
- return 0;
+ /**
+ * Gets code
+ *
+ * @return value of code
+ */
+ @Override
+ public String getCode() {
+ return code;
}
- for (int i = 0; i < valueTypeCode.length; i++) {
- if (valueTypeCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ /**
+ * Gets description
+ *
+ * @return value of description
+ */
+ @Override
+ public String getDescription() {
+ return description;
}
- return 0;
}
- private static int getSuccessNumberByCode(String tt) {
- if (tt == null) {
- return 0;
+ public enum FieldType implements IEnumHasCodeAndDescription {
+ STRING("string", BaseMessages.getString(PKG,
"ActionSimpleEval.FieldTypeString.Label")),
+ NUMBER("number", BaseMessages.getString(PKG,
"ActionSimpleEval.FieldTypeNumber.Label")),
+ DATE_TIME("datetime", BaseMessages.getString(PKG,
"ActionSimpleEval.FieldTypeDateTime.Label")),
+ BOOLEAN("boolean", BaseMessages.getString(PKG,
"ActionSimpleEval.FieldTypeBoolean.Label"));
+
+ private final String code;
+ private final String description;
+
+ FieldType(String code, String description) {
+ this.code = code;
+ this.description = description;
}
- for (int i = 0; i < successNumberConditionCode.length; i++) {
- if (successNumberConditionCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ public static String[] getDescriptions() {
+ return IEnumHasCodeAndDescription.getDescriptions(FieldType.class);
}
- return 0;
- }
- private static int getSuccessBooleanByCode(String tt) {
- if (tt == null) {
- return 0;
+ public static FieldType lookupDescription(String description) {
+ return IEnumHasCodeAndDescription.lookupDescription(FieldType.class,
description, STRING);
}
- for (int i = 0; i < successBooleanConditionCode.length; i++) {
- if (successBooleanConditionCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ public static FieldType lookupCode(String code) {
+ return IEnumHasCode.lookupCode(FieldType.class, code, STRING);
}
- return 0;
- }
- private static int getFieldTypeByCode(String tt) {
- if (tt == null) {
- return 0;
+ @Override
+ public String getCode() {
+ return code;
}
- for (int i = 0; i < fieldTypeCode.length; i++) {
- if (fieldTypeCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ @Override
+ public String getDescription() {
+ return description;
}
- return 0;
}
- private static int getSuccessConditionByCode(String tt) {
- if (tt == null) {
- return 0;
+ public enum SuccessNumberCondition implements IEnumHasCodeAndDescription {
+ EQUAL("equal", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenEqual.Label")),
+ DIFFERENT("different", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenDifferent.Label")),
+ SMALLER("smaller", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenSmallThan.Label")),
+ SMALLER_EQUAL("smallequal", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenSmallOrEqualThan.Label")),
+ GREATER("greater", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenGreaterThan.Label")),
+ GREATER_EQUAL("greaterequal", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenGreaterOrEqualThan.Label")),
+ BETWEEN("between", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessBetween.Label")),
+ IN_LIST("inlist", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenInList.Label")),
+ NOT_IN_LIST("notinlist", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenNotInList.Label"));
+
+ private final String code;
+ private final String description;
+
+ SuccessNumberCondition(String code, String description) {
+ this.code = code;
+ this.description = description;
}
- for (int i = 0; i < successConditionCode.length; i++) {
- if (successConditionCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ public static String[] getDescriptions() {
+ return
IEnumHasCodeAndDescription.getDescriptions(SuccessNumberCondition.class);
}
- return 0;
- }
- public void setSuccessWhenVarSet(boolean successwhenvarset) {
- this.successwhenvarset = successwhenvarset;
- }
+ public static SuccessNumberCondition lookupDescription(String description)
{
+ return
IEnumHasCodeAndDescription.lookupDescription(SuccessNumberCondition.class,
description, EQUAL);
+ }
- public boolean isSuccessWhenVarSet() {
- return this.successwhenvarset;
- }
+ public static SuccessNumberCondition lookupCode(String code) {
+ return IEnumHasCode.lookupCode(SuccessNumberCondition.class, code,
EQUAL);
+ }
- public static int getSuccessNumberConditionByCode(String tt) {
- if (tt == null) {
- return 0;
+ @Override
+ public String getCode() {
+ return code;
}
- for (int i = 0; i < successNumberConditionCode.length; i++) {
- if (successNumberConditionCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ @Override
+ public String getDescription() {
+ return description;
}
- return 0;
}
+
+ public enum SuccessBooleanCondition implements IEnumHasCodeAndDescription {
+ TRUE("true", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenTrue.Label")),
+ FALSE("false", BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessWhenFalse.Label"));
+
+ private final String code;
+ private final String description;
- private static int getSuccessBooleanConditionByCode(String tt) {
- if (tt == null) {
- return 0;
+ SuccessBooleanCondition(String code, String description) {
+ this.code = code;
+ this.description = description;
}
- for (int i = 0; i < successBooleanConditionCode.length; i++) {
- if (successBooleanConditionCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ public static String[] getDescriptions() {
+ return
IEnumHasCodeAndDescription.getDescriptions(SuccessBooleanCondition.class);
+ }
+
+ public static SuccessBooleanCondition lookupDescription(String
description) {
+ return
IEnumHasCodeAndDescription.lookupDescription(SuccessBooleanCondition.class,
description, TRUE);
+ }
+
+ public static SuccessBooleanCondition lookupCode(String code) {
+ return IEnumHasCode.lookupCode(SuccessBooleanCondition.class, code,
TRUE);
+ }
+
+ @Override
+ public String getCode() {
+ return code;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
}
- return 0;
+ }
+
+ @HopMetadataProperty(key = "valuetype", storeWithCode = true)
+ private ValueType valueType;
+ @HopMetadataProperty(key = "fieldtype", storeWithCode = true)
+ private FieldType fieldType;
+ @HopMetadataProperty(key = "fieldname")
+ private String fieldName;
+ @HopMetadataProperty(key = "variablename")
+ private String variableName;
+ @HopMetadataProperty(key = "mask")
+ private String mask;
+ @HopMetadataProperty(key = "comparevalue")
+ private String compareValue;
+ @HopMetadataProperty(key = "minvalue")
+ private String minValue;
+ @HopMetadataProperty(key = "maxvalue")
+ private String maxValue;
+ @HopMetadataProperty(key = "successcondition", storeWithCode = true)
+ private SuccessStringCondition successStringCondition;
+ @HopMetadataProperty(key = "successwhenvarset")
+ private boolean successWhenVarSet;
+ @HopMetadataProperty(key = "successbooleancondition", storeWithCode = true)
+ private SuccessBooleanCondition successBooleanCondition;
+ @HopMetadataProperty(key = "successnumbercondition", storeWithCode = true)
+ private SuccessNumberCondition successNumberCondition;
+
+ public ActionSimpleEval(String n) {
+ super(n, "");
+ valueType = ValueType.FIELD;
+ fieldType = FieldType.STRING;
+ successStringCondition = SuccessStringCondition.EQUAL;
+ successNumberCondition = SuccessNumberCondition.EQUAL;
+ successBooleanCondition = SuccessBooleanCondition.TRUE;
+ minValue = null;
+ maxValue = null;
+ compareValue = null;
+ fieldName = null;
+ variableName = null;
+ mask = null;
+ successWhenVarSet = false;
+ }
+
+ public ActionSimpleEval() {
+ this("");
}
@Override
- public void loadXml(Node entrynode, IHopMetadataProvider metadataProvider,
IVariables variables)
- throws HopXmlException {
- try {
- super.loadXml(entrynode);
-
- valuetype =
getValueTypeByCode(Const.NVL(XmlHandler.getTagValue(entrynode, "valuetype"),
""));
- fieldname = XmlHandler.getTagValue(entrynode, "fieldname");
- fieldtype =
getFieldTypeByCode(Const.NVL(XmlHandler.getTagValue(entrynode, "fieldtype"),
""));
- variablename = XmlHandler.getTagValue(entrynode, "variablename");
- mask = XmlHandler.getTagValue(entrynode, "mask");
- comparevalue = XmlHandler.getTagValue(entrynode, "comparevalue");
- minvalue = XmlHandler.getTagValue(entrynode, "minvalue");
- maxvalue = XmlHandler.getTagValue(entrynode, "maxvalue");
- successcondition =
- getSuccessConditionByCode(
- Const.NVL(XmlHandler.getTagValue(entrynode, "successcondition"),
""));
- successnumbercondition =
- getSuccessNumberConditionByCode(
- Const.NVL(XmlHandler.getTagValue(entrynode,
"successnumbercondition"), ""));
- successbooleancondition =
- getSuccessBooleanConditionByCode(
- Const.NVL(XmlHandler.getTagValue(entrynode,
"successbooleancondition"), ""));
- successwhenvarset =
- "Y".equalsIgnoreCase(XmlHandler.getTagValue(entrynode,
"successwhenvarset"));
- } catch (HopXmlException xe) {
- throw new HopXmlException(
- BaseMessages.getString(PKG,
"ActionSimple.Error.Exception.UnableLoadXML"), xe);
- }
+ public Object clone() {
+ ActionSimpleEval je = (ActionSimpleEval) super.clone();
+ return je;
+ }
+
+ public void setSuccessWhenVarSet(boolean successwhenvarset) {
+ this.successWhenVarSet = successwhenvarset;
+ }
+
+ public boolean isSuccessWhenVarSet() {
+ return this.successWhenVarSet;
}
@Override
@@ -404,8 +318,8 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
result.setResult(false);
String sourcevalue = null;
- switch (valuetype) {
- case VALUE_TYPE_FIELD:
+ switch (valueType) {
+ case FIELD:
List<RowMetaAndData> rows = result.getRows();
RowMetaAndData resultRow = null;
if (isDetailed()) {
@@ -423,7 +337,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
// get first row
resultRow = rows.get(0);
- String realfieldname = resolve(fieldname);
+ String realfieldname = resolve(fieldName);
int indexOfField = -1;
indexOfField = resultRow.getRowMeta().indexOfValue(realfieldname);
if (indexOfField == -1) {
@@ -440,8 +354,8 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
resultRow = null;
rows = null;
break;
- case VALUE_TYPE_VARIABLE:
- if (Utils.isEmpty(variablename)) {
+ case VARIABLE:
+ if (Utils.isEmpty(variableName)) {
logError(BaseMessages.getString(PKG,
"ActionSimpleEval.Error.VariableMissing"));
return result;
}
@@ -482,34 +396,34 @@ public class ActionSimpleEval extends ActionBase
implements Cloneable, IAction {
}
boolean success = false;
- String realCompareValue = resolve(comparevalue);
+ String realCompareValue = resolve(compareValue);
if (realCompareValue == null) {
realCompareValue = "";
}
- String realMinValue = resolve(minvalue);
- String realMaxValue = resolve(maxvalue);
+ String realMinValue = resolve(minValue);
+ String realMaxValue = resolve(maxValue);
- switch (fieldtype) {
- case FIELD_TYPE_STRING:
- switch (successcondition) {
- case SUCCESS_CONDITION_EQUAL: // equal
+ switch (fieldType) {
+ case STRING:
+ switch (successStringCondition) {
+ case EQUAL: // equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG, "ActionSimpleEval.Log.CompareWithValue",
sourcevalue, realCompareValue));
}
success = (sourcevalue.equals(realCompareValue));
- if (valuetype == VALUE_TYPE_VARIABLE && !success) {
+ if (valueType == ValueType.VARIABLE && !success) {
// make the empty value evaluate to true when compared to a not
set variable
if (Utils.isEmpty(realCompareValue)) {
- String variableName = StringUtil.getVariableName(variablename);
- if (System.getProperty(variableName) == null) {
+ String key = StringUtil.getVariableName(variableName);
+ if (System.getProperty(key) == null) {
success = true;
}
}
}
break;
- case SUCCESS_CONDITION_DIFFERENT: // different
+ case DIFFERENT: // different
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -517,7 +431,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (!sourcevalue.equals(realCompareValue));
break;
- case SUCCESS_CONDITION_CONTAINS: // contains
+ case CONTAINS: // contains
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -525,7 +439,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (sourcevalue.contains(realCompareValue));
break;
- case SUCCESS_CONDITION_NOT_CONTAINS: // not contains
+ case NOT_CONTAINS: // not contains
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -533,7 +447,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (!sourcevalue.contains(realCompareValue));
break;
- case SUCCESS_CONDITION_START_WITH: // starts with
+ case START_WITH: // starts with
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -541,7 +455,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (sourcevalue.startsWith(realCompareValue));
break;
- case SUCCESS_CONDITION_NOT_START_WITH: // not start with
+ case NOT_START_WITH: // not start with
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -549,7 +463,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (!sourcevalue.startsWith(realCompareValue));
break;
- case SUCCESS_CONDITION_END_WITH: // ends with
+ case END_WITH: // ends with
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -557,7 +471,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (sourcevalue.endsWith(realCompareValue));
break;
- case SUCCESS_CONDITION_NOT_END_WITH: // not ends with
+ case NOT_END_WITH: // not ends with
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -565,7 +479,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (!sourcevalue.endsWith(realCompareValue));
break;
- case SUCCESS_CONDITION_REGEX: // regexp
+ case REGEX: // regexp
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -573,7 +487,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success =
(Pattern.compile(realCompareValue).matcher(sourcevalue).matches());
break;
- case SUCCESS_CONDITION_IN_LIST: // in list
+ case IN_LIST: // in list
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -585,7 +499,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
success = (sourcevalue.equals(parts[i].trim()));
}
break;
- case SUCCESS_CONDITION_NOT_IN_LIST: // not in list
+ case NOT_IN_LIST: // not in list
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -602,7 +516,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
break;
}
break;
- case FIELD_TYPE_NUMBER:
+ case NUMBER:
double valuenumber;
try {
valuenumber = Double.parseDouble(sourcevalue);
@@ -614,8 +528,8 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
double valuecompare;
- switch (successnumbercondition) {
- case SUCCESS_NUMBER_CONDITION_EQUAL: // equal
+ switch (successNumberCondition) {
+ case EQUAL: // equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -634,7 +548,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (valuenumber == valuecompare);
break;
- case SUCCESS_NUMBER_CONDITION_DIFFERENT: // different
+ case DIFFERENT: // different
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -653,7 +567,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (valuenumber != valuecompare);
break;
- case SUCCESS_NUMBER_CONDITION_SMALLER: // smaller
+ case SMALLER: // smaller
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -672,7 +586,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (valuenumber < valuecompare);
break;
- case SUCCESS_NUMBER_CONDITION_SMALLER_EQUAL: // smaller or equal
+ case SMALLER_EQUAL: // smaller or equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -691,7 +605,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (valuenumber <= valuecompare);
break;
- case SUCCESS_NUMBER_CONDITION_GREATER: // greater
+ case GREATER: // greater
try {
valuecompare = Double.parseDouble(realCompareValue);
} catch (Exception e) {
@@ -705,7 +619,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (valuenumber > valuecompare);
break;
- case SUCCESS_NUMBER_CONDITION_GREATER_EQUAL: // greater or equal
+ case GREATER_EQUAL: // greater or equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -724,7 +638,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (valuenumber >= valuecompare);
break;
- case SUCCESS_NUMBER_CONDITION_BETWEEN: // between min and max
+ case BETWEEN: // between min and max
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -763,7 +677,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (valuenumber >= valuemin && valuenumber <= valuemax);
break;
- case SUCCESS_NUMBER_CONDITION_IN_LIST: // in list
+ case IN_LIST: // in list
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -784,7 +698,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
success = (valuenumber == valuecompare);
}
break;
- case SUCCESS_NUMBER_CONDITION_NOT_IN_LIST: // not in list
+ case NOT_IN_LIST: // not in list
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -811,7 +725,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
break;
}
break;
- case FIELD_TYPE_DATE_TIME:
+ case DATE_TIME:
String realMask = resolve(mask);
SimpleDateFormat df = new SimpleDateFormat();
if (!Utils.isEmpty(realMask)) {
@@ -827,8 +741,8 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
Date datecompare;
- switch (successnumbercondition) {
- case SUCCESS_NUMBER_CONDITION_EQUAL: // equal
+ switch (successNumberCondition) {
+ case EQUAL: // equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -842,7 +756,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (datevalue.equals(datecompare));
break;
- case SUCCESS_NUMBER_CONDITION_DIFFERENT: // different
+ case DIFFERENT: // different
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -856,7 +770,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (!datevalue.equals(datecompare));
break;
- case SUCCESS_NUMBER_CONDITION_SMALLER: // smaller
+ case SMALLER: // smaller
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -870,7 +784,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (datevalue.before(datecompare));
break;
- case SUCCESS_NUMBER_CONDITION_SMALLER_EQUAL: // smaller or equal
+ case SMALLER_EQUAL: // smaller or equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -884,7 +798,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (datevalue.before(datecompare) ||
datevalue.equals(datecompare));
break;
- case SUCCESS_NUMBER_CONDITION_GREATER: // greater
+ case GREATER: // greater
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -898,7 +812,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (datevalue.after(datecompare));
break;
- case SUCCESS_NUMBER_CONDITION_GREATER_EQUAL: // greater or equal
+ case GREATER_EQUAL: // greater or equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -912,7 +826,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
success = (datevalue.after(datecompare) ||
datevalue.equals(datecompare));
break;
- case SUCCESS_NUMBER_CONDITION_BETWEEN: // between min and max
+ case BETWEEN: // between min and max
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -945,7 +859,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
((datevalue.after(datemin) || datevalue.equals(datemin))
&& (datevalue.before(datemax) ||
datevalue.equals(datemax)));
break;
- case SUCCESS_NUMBER_CONDITION_IN_LIST: // in list
+ case IN_LIST: // in list
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -963,7 +877,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
success = (datevalue.equals(datecompare));
}
break;
- case SUCCESS_NUMBER_CONDITION_NOT_IN_LIST: // not in list
+ case NOT_IN_LIST: // not in list
if (isDebug()) {
logDebug(
BaseMessages.getString(
@@ -987,7 +901,7 @@ public class ActionSimpleEval extends ActionBase implements
Cloneable, IAction {
}
df = null;
break;
- case FIELD_TYPE_BOOLEAN:
+ case BOOLEAN:
boolean valuebool;
try {
valuebool = ValueMetaString.convertStringToBoolean(sourcevalue);
@@ -998,11 +912,11 @@ public class ActionSimpleEval extends ActionBase
implements Cloneable, IAction {
return result;
}
- switch (successbooleancondition) {
- case SUCCESS_BOOLEAN_CONDITION_FALSE: // false
+ switch (successBooleanCondition) {
+ case FALSE: // false
success = (!valuebool);
break;
- case SUCCESS_BOOLEAN_CONDITION_TRUE: // true
+ case TRUE: // true
success = (valuebool);
break;
default:
@@ -1051,166 +965,96 @@ public class ActionSimpleEval extends ActionBase
implements Cloneable, IAction {
return datevalue;
}
- public static String getValueTypeDesc(int i) {
- if (i < 0 || i >= valueTypeDesc.length) {
- return valueTypeDesc[0];
- }
- return valueTypeDesc[i];
+ public void setMinValue(String minvalue) {
+ this.minValue = minvalue;
}
- public static String getFieldTypeDesc(int i) {
- if (i < 0 || i >= fieldTypeDesc.length) {
- return fieldTypeDesc[0];
- }
- return fieldTypeDesc[i];
+ public String getMinValue() {
+ return minValue;
}
- public static String getSuccessConditionDesc(int i) {
- if (i < 0 || i >= successConditionDesc.length) {
- return successConditionDesc[0];
- }
- return successConditionDesc[i];
+ public void setCompareValue(String comparevalue) {
+ this.compareValue = comparevalue;
}
- public static String getSuccessNumberConditionDesc(int i) {
- if (i < 0 || i >= successNumberConditionDesc.length) {
- return successNumberConditionDesc[0];
- }
- return successNumberConditionDesc[i];
+ public String getMask() {
+ return mask;
}
- public static String getSuccessBooleanConditionDesc(int i) {
- if (i < 0 || i >= successBooleanConditionDesc.length) {
- return successBooleanConditionDesc[0];
- }
- return successBooleanConditionDesc[i];
+ public void setMask(String mask) {
+ this.mask = mask;
}
- public static int getValueTypeByDesc(String tt) {
- if (tt == null) {
- return 0;
- }
-
- for (int i = 0; i < valueTypeDesc.length; i++) {
- if (valueTypeDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
- }
-
- // If this fails, try to match using the code.
- return getValueTypeByCode(tt);
+ public String getFieldName() {
+ return fieldName;
}
- public static int getFieldTypeByDesc(String tt) {
- if (tt == null) {
- return 0;
- }
-
- for (int i = 0; i < fieldTypeDesc.length; i++) {
- if (fieldTypeDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
- }
-
- // If this fails, try to match using the code.
- return getFieldTypeByCode(tt);
+ public void setFieldName(String fieldname) {
+ this.fieldName = fieldname;
}
- public static int getSuccessConditionByDesc(String tt) {
- if (tt == null) {
- return 0;
- }
-
- for (int i = 0; i < successConditionDesc.length; i++) {
- if (successConditionDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
- }
-
- // If this fails, try to match using the code.
- return getSuccessConditionByCode(tt);
+ public String getVariableName() {
+ return variableName;
}
- public static int getSuccessNumberConditionByDesc(String tt) {
- if (tt == null) {
- return 0;
- }
-
- for (int i = 0; i < successNumberConditionDesc.length; i++) {
- if (successNumberConditionDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
- }
-
- // If this fails, try to match using the code.
- return getSuccessNumberByCode(tt);
+ public void setVariableName(String variablename) {
+ this.variableName = variablename;
}
- public static int getSuccessBooleanConditionByDesc(String tt) {
- if (tt == null) {
- return 0;
- }
-
- for (int i = 0; i < successBooleanConditionDesc.length; i++) {
- if (successBooleanConditionDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
- }
-
- // If this fails, try to match using the code.
- return getSuccessBooleanByCode(tt);
+ public String getCompareValue() {
+ return compareValue;
}
- public void setMinValue(String minvalue) {
- this.minvalue = minvalue;
+ public void setMaxValue(String maxvalue) {
+ this.maxValue = maxvalue;
}
- public String getMinValue() {
- return minvalue;
+ public String getMaxValue() {
+ return maxValue;
}
- public void setCompareValue(String comparevalue) {
- this.comparevalue = comparevalue;
+ @Override
+ public boolean isEvaluation() {
+ return true;
}
- public String getMask() {
- return mask;
+ public ValueType getValueType() {
+ return valueType;
}
- public void setMask(String mask) {
- this.mask = mask;
+ public FieldType getFieldType() {
+ return fieldType;
}
- public String getFieldName() {
- return fieldname;
+ public SuccessStringCondition getSuccessStringCondition() {
+ return successStringCondition;
}
- public void setFieldName(String fieldname) {
- this.fieldname = fieldname;
+ public void setValueType(ValueType valuetype) {
+ this.valueType = valuetype;
}
- public String getVariableName() {
- return variablename;
+ public void setFieldType(FieldType fieldtype) {
+ this.fieldType = fieldtype;
}
- public void setVariableName(String variablename) {
- this.variablename = variablename;
+ public void setSuccessStringCondition(SuccessStringCondition
successcondition) {
+ this.successStringCondition = successcondition;
}
- public String getCompareValue() {
- return comparevalue;
+ public SuccessBooleanCondition getSuccessBooleanCondition() {
+ return successBooleanCondition;
}
- public void setMaxValue(String maxvalue) {
- this.maxvalue = maxvalue;
+ public SuccessNumberCondition getSuccessNumberCondition() {
+ return successNumberCondition;
}
- public String getMaxValue() {
- return maxvalue;
+ public void setSuccessBooleanCondition(SuccessBooleanCondition
successBooleanCondition) {
+ this.successBooleanCondition = successBooleanCondition;
}
- @Override
- public boolean isEvaluation() {
- return true;
+ public void setSuccessNumberCondition(SuccessNumberCondition
successNumberCondition) {
+ this.successNumberCondition = successNumberCondition;
}
}
diff --git
a/plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEvalDialog.java
b/plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEvalDialog.java
index a57fdeb01f..45ead479ec 100644
---
a/plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEvalDialog.java
+++
b/plugins/actions/simpleeval/src/main/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEvalDialog.java
@@ -34,24 +34,26 @@ import org.apache.hop.ui.workflow.dialog.WorkflowDialog;
import org.apache.hop.workflow.WorkflowMeta;
import org.apache.hop.workflow.action.IAction;
import org.apache.hop.workflow.action.IActionDialog;
+import org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.FieldType;
+import
org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.SuccessBooleanCondition;
+import
org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.SuccessNumberCondition;
+import
org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.SuccessStringCondition;
+import org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.ValueType;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-/** This dialog allows you to edit the XML valid action settings. */
+/** This dialog allows you to edit the Simple Eval action settings. */
public class ActionSimpleEvalDialog extends ActionDialog implements
IActionDialog {
private static final Class<?> PKG = ActionSimpleEval.class; // For Translator
@@ -64,19 +66,19 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
private Label wlSuccessWhenSet;
private Button wSuccessWhenSet;
- private Label wlSuccessCondition;
+ private Label wlSuccessStringCondition;
private Label wlFieldType;
private Label wlMask;
- private CCombo wSuccessCondition;
- private CCombo wValueType;
- private CCombo wFieldType;
+ private Combo wSuccessStringCondition;
+ private Combo wValueType;
+ private Combo wFieldType;
private ComboVar wMask;
private Label wlSuccessNumberCondition;
- private CCombo wSuccessNumberCondition;
+ private Combo wSuccessNumberCondition;
private Label wlSuccessBooleanCondition;
- private CCombo wSuccessBooleanCondition;
+ private Combo wSuccessBooleanCondition;
private Label wlCompareValue;
private TextVar wCompareValue;
@@ -107,7 +109,6 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
PropsUi.setLook(shell);
WorkflowDialog.setShellImage(shell, action);
- ModifyListener lsMod = e -> action.setChanged();
changed = action.hasChanged();
FormLayout formLayout = new FormLayout();
@@ -141,12 +142,12 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
wlName.setLayoutData(fdlName);
wName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wName);
- wName.addModifyListener(lsMod);
FormData fdName = new FormData();
fdName.left = new FormAttachment(middle, 0);
fdName.top = new FormAttachment(0, margin);
fdName.right = new FormAttachment(100, 0);
wName.setLayoutData(fdName);
+ wName.addListener(SWT.Modify, e -> action.setChanged());
CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
PropsUi.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
@@ -188,8 +189,8 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdlValueType.right = new FormAttachment(middle, -margin);
fdlValueType.top = new FormAttachment(0, margin);
wlValueType.setLayoutData(fdlValueType);
- wValueType = new CCombo(wSource, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
- wValueType.setItems(ActionSimpleEval.valueTypeDesc);
+ wValueType = new Combo(wSource, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
+ wValueType.setItems(ValueType.getDescriptions());
PropsUi.setLook(wValueType);
FormData fdValueType = new FormData();
@@ -197,14 +198,7 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdValueType.top = new FormAttachment(0, margin);
fdValueType.right = new FormAttachment(100, 0);
wValueType.setLayoutData(fdValueType);
- wValueType.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- refresh();
- }
- });
+ wValueType.addListener(SWT.Selection, e -> refresh());
// Name of the field to evaluate
wlFieldName = new Label(wSource, SWT.RIGHT);
@@ -223,12 +217,12 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
SWT.SINGLE | SWT.LEFT | SWT.BORDER,
BaseMessages.getString(PKG, "ActionSimpleEval.FieldName.Tooltip"));
PropsUi.setLook(wFieldName);
- wFieldName.addModifyListener(lsMod);
FormData fdFieldName = new FormData();
fdFieldName.left = new FormAttachment(middle, 0);
fdFieldName.top = new FormAttachment(wValueType, margin);
fdFieldName.right = new FormAttachment(100, -margin);
wFieldName.setLayoutData(fdFieldName);
+ wFieldName.addListener(SWT.Modify, e -> action.setChanged());
// Name of the variable to evaluate
wlVariableName = new Label(wSource, SWT.RIGHT);
@@ -247,12 +241,12 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
SWT.SINGLE | SWT.LEFT | SWT.BORDER,
BaseMessages.getString(PKG, "ActionSimpleEval.Variable.Tooltip"));
PropsUi.setLook(wVariableName);
- wVariableName.addModifyListener(lsMod);
FormData fdVariableName = new FormData();
fdVariableName.left = new FormAttachment(middle, 0);
fdVariableName.top = new FormAttachment(wValueType, margin);
fdVariableName.right = new FormAttachment(100, -margin);
wVariableName.setLayoutData(fdVariableName);
+ wVariableName.addListener(SWT.Modify, e -> action.setChanged());
// Field type
wlFieldType = new Label(wSource, SWT.RIGHT);
@@ -263,8 +257,8 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdlFieldType.right = new FormAttachment(middle, -margin);
fdlFieldType.top = new FormAttachment(wVariableName, margin);
wlFieldType.setLayoutData(fdlFieldType);
- wFieldType = new CCombo(wSource, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
- wFieldType.setItems(ActionSimpleEval.fieldTypeDesc);
+ wFieldType = new Combo(wSource, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
+ wFieldType.setItems(FieldType.getDescriptions());
PropsUi.setLook(wFieldType);
FormData fdFieldType = new FormData();
@@ -272,14 +266,7 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdFieldType.top = new FormAttachment(wVariableName, margin);
fdFieldType.right = new FormAttachment(100, 0);
wFieldType.setLayoutData(fdFieldType);
- wFieldType.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- refresh();
- }
- });
+ wFieldType.addListener(SWT.Selection, e -> {refresh();
action.setChanged();});
// Mask
wlMask = new Label(wSource, SWT.RIGHT);
@@ -300,11 +287,7 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdMask.top = new FormAttachment(wFieldType, margin);
fdMask.right = new FormAttachment(100, 0);
wMask.setLayoutData(fdMask);
- wMask.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {}
- });
+ wMask.addListener(SWT.Selection, e -> action.setChanged());
FormData fdSource = new FormData();
fdSource.left = new FormAttachment(0, margin);
@@ -347,43 +330,31 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdSuccessWhenSet.top = new FormAttachment(wlSuccessWhenSet, 0, SWT.CENTER);
fdSuccessWhenSet.right = new FormAttachment(100, 0);
wSuccessWhenSet.setLayoutData(fdSuccessWhenSet);
- wSuccessWhenSet.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- refresh();
- action.setChanged();
- }
- });
-
- // Success Condition
- wlSuccessCondition = new Label(wSuccessOn, SWT.RIGHT);
- wlSuccessCondition.setText(
+ wSuccessWhenSet.addListener(SWT.Selection, e -> {refresh();
action.setChanged();});
+
+ // Success String Condition
+ wlSuccessStringCondition = new Label(wSuccessOn, SWT.RIGHT);
+ wlSuccessStringCondition.setText(
BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessCondition.Label"));
- PropsUi.setLook(wlSuccessCondition);
- FormData fdlSuccessCondition = new FormData();
- fdlSuccessCondition.left = new FormAttachment(0, 0);
- fdlSuccessCondition.right = new FormAttachment(middle, 0);
- fdlSuccessCondition.top = new FormAttachment(wlSuccessWhenSet, 2 * margin);
- wlSuccessCondition.setLayoutData(fdlSuccessCondition);
-
- wSuccessCondition = new CCombo(wSuccessOn, SWT.SINGLE | SWT.READ_ONLY |
SWT.BORDER);
- wSuccessCondition.setItems(ActionSimpleEval.successConditionDesc);
- wSuccessCondition.select(0); // +1: starts at -1
-
- PropsUi.setLook(wSuccessCondition);
- FormData fdSuccessCondition = new FormData();
- fdSuccessCondition.left = new FormAttachment(middle, 0);
- fdSuccessCondition.top = new FormAttachment(wSuccessWhenSet, margin);
- fdSuccessCondition.right = new FormAttachment(100, 0);
- wSuccessCondition.setLayoutData(fdSuccessCondition);
- wSuccessCondition.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {}
- });
-
- // Success number(date) Condition
+ PropsUi.setLook(wlSuccessStringCondition);
+ FormData fdlSuccessStringCondition = new FormData();
+ fdlSuccessStringCondition.left = new FormAttachment(0, 0);
+ fdlSuccessStringCondition.right = new FormAttachment(middle, -margin);
+ fdlSuccessStringCondition.top = new FormAttachment(wSuccessWhenSet,
margin);
+ wlSuccessStringCondition.setLayoutData(fdlSuccessStringCondition);
+
+ wSuccessStringCondition = new Combo(wSuccessOn, SWT.SINGLE | SWT.READ_ONLY
| SWT.BORDER);
+ wSuccessStringCondition.setItems(SuccessStringCondition.getDescriptions());
+ wSuccessStringCondition.select(0); // +1: starts at -1
+ PropsUi.setLook(wSuccessStringCondition);
+ FormData fdSuccessStringCondition = new FormData();
+ fdSuccessStringCondition.left = new FormAttachment(middle, 0);
+ fdSuccessStringCondition.top = new FormAttachment(wSuccessWhenSet, margin);
+ fdSuccessStringCondition.right = new FormAttachment(100, 0);
+ wSuccessStringCondition.setLayoutData(fdSuccessStringCondition);
+ wSuccessStringCondition.addListener(SWT.Selection, e -> {refresh();
action.setChanged();});
+
+ // Success Number or Date Condition
wlSuccessNumberCondition = new Label(wSuccessOn, SWT.RIGHT);
wlSuccessNumberCondition.setText(
BaseMessages.getString(PKG,
"ActionSimpleEval.SuccessNumberCondition.Label"));
@@ -394,8 +365,8 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdlSuccessNumberCondition.top = new FormAttachment(wSuccessWhenSet,
margin);
wlSuccessNumberCondition.setLayoutData(fdlSuccessNumberCondition);
- wSuccessNumberCondition = new CCombo(wSuccessOn, SWT.SINGLE |
SWT.READ_ONLY | SWT.BORDER);
-
wSuccessNumberCondition.setItems(ActionSimpleEval.successNumberConditionDesc);
+ wSuccessNumberCondition = new Combo(wSuccessOn, SWT.SINGLE | SWT.READ_ONLY
| SWT.BORDER);
+ wSuccessNumberCondition.setItems(SuccessNumberCondition.getDescriptions());
wSuccessNumberCondition.select(0); // +1: starts at -1
PropsUi.setLook(wSuccessNumberCondition);
@@ -404,13 +375,7 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdSuccessNumberCondition.top = new FormAttachment(wSuccessWhenSet, margin);
fdSuccessNumberCondition.right = new FormAttachment(100, 0);
wSuccessNumberCondition.setLayoutData(fdSuccessNumberCondition);
- wSuccessNumberCondition.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- refresh();
- }
- });
+ wSuccessNumberCondition.addListener(SWT.Selection, e -> {refresh();
action.setChanged();});
// Success Boolean Condition
wlSuccessBooleanCondition = new Label(wSuccessOn, SWT.RIGHT);
@@ -423,8 +388,8 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdlSuccessBooleanCondition.top = new FormAttachment(wSuccessWhenSet,
margin);
wlSuccessBooleanCondition.setLayoutData(fdlSuccessBooleanCondition);
- wSuccessBooleanCondition = new CCombo(wSuccessOn, SWT.SINGLE |
SWT.READ_ONLY | SWT.BORDER);
-
wSuccessBooleanCondition.setItems(ActionSimpleEval.successBooleanConditionDesc);
+ wSuccessBooleanCondition = new Combo(wSuccessOn, SWT.SINGLE |
SWT.READ_ONLY | SWT.BORDER);
+
wSuccessBooleanCondition.setItems(SuccessBooleanCondition.getDescriptions());
wSuccessBooleanCondition.select(0); // +1: starts at -1
PropsUi.setLook(wSuccessBooleanCondition);
@@ -433,13 +398,7 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
fdSuccessBooleanCondition.top = new FormAttachment(wSuccessWhenSet,
margin);
fdSuccessBooleanCondition.right = new FormAttachment(100, 0);
wSuccessBooleanCondition.setLayoutData(fdSuccessBooleanCondition);
- wSuccessBooleanCondition.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- refresh();
- }
- });
+ wSuccessBooleanCondition.addListener(SWT.Selection, e -> {refresh();
action.setChanged();});
// Compare with value
wlCompareValue = new Label(wSuccessOn, SWT.RIGHT);
@@ -458,13 +417,13 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
SWT.SINGLE | SWT.LEFT | SWT.BORDER,
BaseMessages.getString(PKG,
"ActionSimpleEval.CompareValue.Tooltip"));
PropsUi.setLook(wCompareValue);
- wCompareValue.addModifyListener(lsMod);
FormData fdCompareValue = new FormData();
fdCompareValue.left = new FormAttachment(middle, 0);
fdCompareValue.top = new FormAttachment(wSuccessNumberCondition, margin);
fdCompareValue.right = new FormAttachment(100, -margin);
wCompareValue.setLayoutData(fdCompareValue);
-
+ wCompareValue.addListener(SWT.Modify, e -> action.setChanged());
+
// Min value
wlMinValue = new Label(wSuccessOn, SWT.RIGHT);
wlMinValue.setText(BaseMessages.getString(PKG,
"ActionSimpleEval.MinValue.Label"));
@@ -482,13 +441,13 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
SWT.SINGLE | SWT.LEFT | SWT.BORDER,
BaseMessages.getString(PKG, "ActionSimpleEval.MinValue.Tooltip"));
PropsUi.setLook(wMinValue);
- wMinValue.addModifyListener(lsMod);
FormData fdMinValue = new FormData();
fdMinValue.left = new FormAttachment(middle, 0);
fdMinValue.top = new FormAttachment(wSuccessNumberCondition, margin);
fdMinValue.right = new FormAttachment(100, -margin);
wMinValue.setLayoutData(fdMinValue);
-
+ wMinValue.addListener(SWT.Modify, e -> action.setChanged());
+
// Maximum value
wlMaxValue = new Label(wSuccessOn, SWT.RIGHT);
wlMaxValue.setText(BaseMessages.getString(PKG,
"ActionSimpleEval.MaxValue.Label"));
@@ -506,13 +465,13 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
SWT.SINGLE | SWT.LEFT | SWT.BORDER,
BaseMessages.getString(PKG, "ActionSimpleEval.MaxValue.Tooltip"));
PropsUi.setLook(wMaxValue);
- wMaxValue.addModifyListener(lsMod);
FormData fdMaxValue = new FormData();
fdMaxValue.left = new FormAttachment(middle, 0);
fdMaxValue.top = new FormAttachment(wMinValue, margin);
fdMaxValue.right = new FormAttachment(100, -margin);
wMaxValue.setLayoutData(fdMaxValue);
-
+ wMaxValue.addListener(SWT.Modify, e -> action.setChanged());
+
FormData fdSuccessOn = new FormData();
fdSuccessOn.left = new FormAttachment(0, margin);
fdSuccessOn.top = new FormAttachment(wSource, margin);
@@ -557,44 +516,26 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
/** Copy information from the meta-data input to the dialog fields. */
public void getData() {
wName.setText(Const.nullToEmpty(action.getName()));
- wValueType.setText(ActionSimpleEval.getValueTypeDesc(action.valuetype));
- if (action.getFieldName() != null) {
- wFieldName.setText(action.getFieldName());
- }
- if (action.getVariableName() != null) {
- wVariableName.setText(action.getVariableName());
- }
+ wValueType.setText(action.getValueType().getDescription());
+ wFieldName.setText(Const.nullToEmpty(action.getFieldName()));
+ wVariableName.setText(Const.nullToEmpty(action.getVariableName()));
wSuccessWhenSet.setSelection(action.isSuccessWhenVarSet());
- wFieldType.setText(ActionSimpleEval.getFieldTypeDesc(action.fieldtype));
- if (action.getMask() != null) {
- wMask.setText(action.getMask());
- }
- if (action.getCompareValue() != null) {
- wCompareValue.setText(action.getCompareValue());
- }
- if (action.getMinValue() != null) {
- wMinValue.setText(action.getMinValue());
- }
- if (action.getMaxValue() != null) {
- wMaxValue.setText(action.getMaxValue());
- }
-
wSuccessCondition.setText(ActionSimpleEval.getSuccessConditionDesc(action.successcondition));
- wSuccessNumberCondition.setText(
-
ActionSimpleEval.getSuccessNumberConditionDesc(action.successnumbercondition));
- wSuccessBooleanCondition.setText(
-
ActionSimpleEval.getSuccessBooleanConditionDesc(action.successbooleancondition));
+ wFieldType.setText(action.getFieldType().getDescription());
+ wMask.setText(Const.nullToEmpty(action.getMask()));
+ wCompareValue.setText(Const.nullToEmpty(action.getCompareValue()));
+ wMinValue.setText(Const.nullToEmpty(action.getMinValue()));
+ wMaxValue.setText(Const.nullToEmpty(action.getMaxValue()));
+
wSuccessStringCondition.setText(action.getSuccessStringCondition().getDescription());
+
wSuccessNumberCondition.setText(action.getSuccessNumberCondition().getDescription());
+
wSuccessBooleanCondition.setText(action.getSuccessBooleanCondition().getDescription());
wName.selectAll();
wName.setFocus();
}
private void refresh() {
- boolean evaluatepreviousRowField =
- ActionSimpleEval.getValueTypeByDesc(wValueType.getText())
- == ActionSimpleEval.VALUE_TYPE_FIELD;
- boolean evaluateVariable =
- ActionSimpleEval.getValueTypeByDesc(wValueType.getText())
- == ActionSimpleEval.VALUE_TYPE_VARIABLE;
+ boolean evaluatepreviousRowField =
ValueType.lookupDescription(wValueType.getText()) == ValueType.FIELD;
+ boolean evaluateVariable =
ValueType.lookupDescription(wValueType.getText()) == ValueType.VARIABLE;
wlVariableName.setVisible(evaluateVariable);
wVariableName.setVisible(evaluateVariable);
wlFieldName.setVisible(evaluatepreviousRowField);
@@ -607,38 +548,27 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
wlFieldType.setVisible(!successWhenSet);
wFieldType.setVisible(!successWhenSet);
- boolean valueTypeDate =
- ActionSimpleEval.getFieldTypeByDesc(wFieldType.getText())
- == ActionSimpleEval.FIELD_TYPE_DATE_TIME;
+ boolean valueTypeDate = FieldType.lookupDescription(wFieldType.getText())
== FieldType.DATE_TIME;
wlMask.setVisible(!successWhenSet && valueTypeDate);
wMask.setVisible(!successWhenSet && valueTypeDate);
- boolean valueTypeString =
- ActionSimpleEval.getFieldTypeByDesc(wFieldType.getText())
- == ActionSimpleEval.FIELD_TYPE_STRING;
- wlSuccessCondition.setVisible(!successWhenSet && valueTypeString);
- wSuccessCondition.setVisible(!successWhenSet && valueTypeString);
-
- boolean valueTypeNumber =
- ActionSimpleEval.getFieldTypeByDesc(wFieldType.getText())
- == ActionSimpleEval.FIELD_TYPE_NUMBER
- || ActionSimpleEval.getFieldTypeByDesc(wFieldType.getText())
- == ActionSimpleEval.FIELD_TYPE_DATE_TIME;
+ boolean valueTypeString =
FieldType.lookupDescription(wFieldType.getText()) == FieldType.STRING;
+ wlSuccessStringCondition.setVisible(!successWhenSet && valueTypeString);
+ wSuccessStringCondition.setVisible(!successWhenSet && valueTypeString);
+
+ boolean valueTypeNumber =
FieldType.lookupDescription(wFieldType.getText()) == FieldType.NUMBER
+ || FieldType.lookupDescription(wFieldType.getText()) ==
FieldType.DATE_TIME;
wlSuccessNumberCondition.setVisible(!successWhenSet && valueTypeNumber);
wSuccessNumberCondition.setVisible(!successWhenSet && valueTypeNumber);
- boolean valueTypeBoolean =
- ActionSimpleEval.getFieldTypeByDesc(wFieldType.getText())
- == ActionSimpleEval.FIELD_TYPE_BOOLEAN;
+ boolean valueTypeBoolean =
FieldType.lookupDescription(wFieldType.getText()) == FieldType.BOOLEAN;
wlSuccessBooleanCondition.setVisible(!successWhenSet && valueTypeBoolean);
wSuccessBooleanCondition.setVisible(!successWhenSet && valueTypeBoolean);
boolean compareValue =
valueTypeString
|| (!valueTypeString
- && ActionSimpleEval.getSuccessNumberConditionByDesc(
- wSuccessNumberCondition.getText())
- != ActionSimpleEval.SUCCESS_NUMBER_CONDITION_BETWEEN);
+ &&
SuccessNumberCondition.lookupDescription(wSuccessNumberCondition.getText()) !=
SuccessNumberCondition.BETWEEN);
wlCompareValue.setVisible(!successWhenSet && compareValue &&
!valueTypeBoolean);
wCompareValue.setVisible(!successWhenSet && compareValue &&
!valueTypeBoolean);
wlMinValue.setVisible(!successWhenSet && !compareValue &&
!valueTypeBoolean);
@@ -662,23 +592,19 @@ public class ActionSimpleEvalDialog extends ActionDialog
implements IActionDialo
mb.open();
return;
}
- action.setName(wName.getText());
- action.valuetype =
ActionSimpleEval.getValueTypeByDesc(wValueType.getText());
+ action.setName(wName.getText());
+ action.setValueType(ValueType.lookupDescription(wValueType.getText()));
action.setFieldName(wFieldName.getText());
action.setVariableName(wVariableName.getText());
-
- action.fieldtype =
ActionSimpleEval.getFieldTypeByDesc(wFieldType.getText());
+ action.setFieldType(FieldType.lookupDescription(wFieldType.getText()));
action.setMask(wMask.getText());
action.setCompareValue(wCompareValue.getText());
action.setMinValue(wMinValue.getText());
action.setMaxValue(wMaxValue.getText());
- action.successcondition =
-
ActionSimpleEval.getSuccessConditionByDesc(wSuccessCondition.getText());
- action.successnumbercondition =
-
ActionSimpleEval.getSuccessNumberConditionByDesc(wSuccessNumberCondition.getText());
- action.successbooleancondition =
-
ActionSimpleEval.getSuccessBooleanConditionByDesc(wSuccessBooleanCondition.getText());
+
action.setSuccessStringCondition(SuccessStringCondition.lookupDescription(wSuccessStringCondition.getText()));
+
action.setSuccessNumberCondition(SuccessNumberCondition.lookupDescription(wSuccessNumberCondition.getText()));
+
action.setSuccessBooleanCondition(SuccessBooleanCondition.lookupDescription(wSuccessBooleanCondition.getText()));
action.setSuccessWhenVarSet(wSuccessWhenSet.getSelection());
dispose();
}
diff --git
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_de_DE.properties
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_de_DE.properties
index b41592fa08..2053551f62 100644
---
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_de_DE.properties
+++
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_de_DE.properties
@@ -29,7 +29,6 @@ ActionSimpleEval.Error.FieldNotExist=Feld [{0}] konnte im
vorhergehenden Actionr
ActionSimpleEval.Error.NoRows=Das vorherige Result ist leer!
ActionSimpleEval.ValueType.Label=Evaluieren
ActionSimpleEval.SuccessWhenDifferent.Label=Wenn Wert anders ist als
-ActionSimple.Error.Exception.UnableLoadXML=Konnte Action nicht aus XML laden
ActionSimpleEval.MinValue.Label=Minimum
ActionSimpleEval.MinValue.Tooltip=Minimum
ActionSimpleEval.CompareValue.Tooltip=Wert
diff --git
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_en_US.properties
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_en_US.properties
index d2038a98ed..03e068356d 100644
---
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_en_US.properties
+++
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_en_US.properties
@@ -35,7 +35,6 @@ ActionSimpleEval.Log.CompareWithValues=Comparing incoming
value [{0}] (min) and
ActionSimpleEval.Error.NoRows=The previous result is empty\!
ActionSimpleEval.ValueType.Label=Evaluate
ActionSimpleEval.SuccessWhenDifferent.Label=If value is different from
-ActionSimple.Error.Exception.UnableLoadXML=Unable to load action from XML node
ActionSimpleEval.MinValue.Label=Min
ActionSimpleEval.SuccessWhenRegExp.Label=If value valid regex
ActionSimpleEval.MinValue.Tooltip=Min
@@ -59,7 +58,7 @@ ActionSimpleEval.FieldTypeString.Label=String
ActionSimpleEval.SuccessBooleanCondition.Label=Success condition
ActionSimpleEval.Log.ValueToevaluate=Value to evaluate is {0}
ActionSimpleEval.Error.UnparsableNumber=Can not convert value [{0}] to
number\! {1}
-ActionSimpleEval.SuccessCondition.Label=Success condition
+ActionSimpleEval.SuccessCondition.Label=Success condition
ActionSimpleEval.FieldTypeNumber.Label=Number
ActionSimpleEval.Mask.Label=Mask
ActionSimpleEval.SuccessWhenSet.Tooltip=Success when the variable is set
diff --git
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_es_AR.properties
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_es_AR.properties
index a143e1124d..1b9accd5fc 100644
---
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_es_AR.properties
+++
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_es_AR.properties
@@ -17,6 +17,7 @@
#
#
#
+
ActionSimpleEval.Error.VariableMissing=Falta el nombre de la variable.
ActionSimpleEval.SuccessWhenGreaterOrEqualThan.Label=El valor es mayor \u00F3
igual a
ActionSimpleEval.SuccessNumberCondition.Label=Condici\u00F3n de \u00E9xito
@@ -32,7 +33,6 @@ ActionSimpleEval.Log.CompareWithValues=Comparando el valor
entrante [{0}] (min)
ActionSimpleEval.Error.NoRows=El resultado previo est\u00E1 vac\u00EDo.
ActionSimpleEval.ValueType.Label=Evaluar
ActionSimpleEval.SuccessWhenDifferent.Label=El valor es diferente a
-ActionSimple.Error.Exception.UnableLoadXML=Imposible cargar la entrada de
trabajo desde el nodo XML
ActionSimpleEval.CheckingVariable=Verificando la variable [{0}]...
ActionSimpleEval.MinValue.Label=M\u00EDnimo
ActionSimpleEval.SuccessWhenRegExp.Label=Si el valor cumple con la ExpReg
diff --git
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_fr_FR.properties
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_fr_FR.properties
index 6c8a721d10..88dfe8b54a 100644
---
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_fr_FR.properties
+++
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_fr_FR.properties
@@ -35,7 +35,6 @@ ActionSimpleEval.Log.CompareWithValues=Comparaison aves les
bornes [{0}] (inf\u0
ActionSimpleEval.Error.NoRows=Le r\u00E9sultat pr\u00E9c\u00E9dent est
vide\u202F!
ActionSimpleEval.ValueType.Label=Evaluer
ActionSimpleEval.SuccessWhenDifferent.Label=Si la valeur est diff\u00E9rente de
-ActionSimple.Error.Exception.UnableLoadXML=Impossible de charger l''action
depuis le n\u0153ud XML
ActionSimpleEval.MinValue.Label=Borne inf\u00E9rieure
ActionSimpleEval.SuccessWhenRegExp.Label=Si la valeur correspond \u00E0 la
RegExp
ActionSimpleEval.MinValue.Tooltip=Min
diff --git
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_it_IT.properties
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_it_IT.properties
index 167825d571..07dfaf622b 100644
---
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_it_IT.properties
+++
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_it_IT.properties
@@ -34,7 +34,6 @@ ActionSimpleEval.Log.CompareWithValues=Comparazione del
valore entrante [{0}] (m
ActionSimpleEval.Error.NoRows=Il risultato precedente \u00E8 vuoto\!
ActionSimpleEval.ValueType.Label=Valuta
ActionSimpleEval.SuccessWhenDifferent.Label=Se il valore \u00E8 diverso da
-ActionSimple.Error.Exception.UnableLoadXML=Impossibile caricare la action dal
nodo XML
ActionSimpleEval.CheckingVariable=Controllo della variabile [{0}] ...
ActionSimpleEval.MinValue.Label=Min
ActionSimpleEval.SuccessWhenRegExp.Label=Se il valore \u00E8 una regex valida
diff --git
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_ko_KR.properties
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_ko_KR.properties
index 3cb962ece0..20a856aa45 100644
---
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_ko_KR.properties
+++
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_ko_KR.properties
@@ -31,7 +31,6 @@ ActionSimpleEval.Log.CompareWithValues=\uB4E4\uC5B4\uC628
[{0}] (\uCD5C\uC18C\uA
ActionSimpleEval.Error.NoRows=\uC774\uC804 \uACB0\uACFC\uAC00
\uC5C6\uC2B5\uB2C8\uB2E4\!
ActionSimpleEval.ValueType.Label=\uD3C9\uAC00
ActionSimpleEval.SuccessWhenDifferent.Label=\uAC12\uC774 \uB2E4\uB978
\uACBD\uC6B0
-ActionSimple.Error.Exception.UnableLoadXML=XML \uB178\uB4DC\uC5D0\uC11C
Workflow \uC5D4\uD2B8\uB9AC\uB97C \uB85C\uB4DC\uD560 \uC218
\uC5C6\uC2B5\uB2C8\uB2E4
ActionSimpleEval.CheckingVariable=\uBCC0\uC218 [{0}] \uD655\uC778 \uC911...
ActionSimpleEval.MinValue.Label=\uCD5C\uC18C
ActionSimpleEval.SuccessWhenRegExp.Label=\uAC12\uC774 \uC815\uADDC\uC2DD\uC744
\uB9CC\uC871\uD558\uB294 \uACBD\uC6B0
diff --git
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_pt_BR.properties
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_pt_BR.properties
index 8df61eafd9..d718b88cee 100644
---
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_pt_BR.properties
+++
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_pt_BR.properties
@@ -18,7 +18,7 @@
#
#
#Wed Feb 02 22:38:05 PST 2022
-ActionSimple.Error.Exception.UnableLoadXML=N\u00E3o foi poss\u00EDvel carregar
a entrada do n\u00F3 XML
+
ActionSimpleEval.CompareValue.Label=Valor
ActionSimpleEval.CompareValue.Tooltip=Valor
ActionSimpleEval.Description=Avaliar um campo ou uma vari\u00E1vel
diff --git
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_zh_CN.properties
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_zh_CN.properties
index 811e4a2d73..0337f4d259 100644
---
a/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_zh_CN.properties
+++
b/plugins/actions/simpleeval/src/main/resources/org/apache/hop/workflow/actions/simpleeval/messages/messages_zh_CN.properties
@@ -16,7 +16,7 @@
# limitations under the License.
#
#
-ActionSimple.Error.Exception.UnableLoadXML=Unable to load action from XML node
+
ActionSimpleEval.CheckingVariable=Checking variable [{0}] ...
ActionSimpleEval.CompareValue.Label=\u503C
ActionSimpleEval.CompareValue.Tooltip=\u503C
diff --git
a/plugins/actions/simpleeval/src/test/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEvalTest.java
b/plugins/actions/simpleeval/src/test/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEvalTest.java
new file mode 100644
index 0000000000..7c4ce138a8
--- /dev/null
+++
b/plugins/actions/simpleeval/src/test/java/org/apache/hop/workflow/actions/simpleeval/ActionSimpleEvalTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.workflow.actions.simpleeval;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import org.apache.hop.core.HopClientEnvironment;
+import org.apache.hop.core.database.DatabaseMeta;
+import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
+import org.apache.hop.workflow.action.ActionSerializationTestUtil;
+import org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.FieldType;
+import
org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.SuccessBooleanCondition;
+import
org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.SuccessNumberCondition;
+import
org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.SuccessStringCondition;
+import org.apache.hop.workflow.actions.simpleeval.ActionSimpleEval.ValueType;
+import org.junit.Test;
+
+/** Unit tests for Simple Eval action. */
+public class ActionSimpleEvalTest {
+
+ @Test
+ public void testSerialization() throws Exception {
+ HopClientEnvironment.init();
+ DatabaseMeta databaseMeta = new DatabaseMeta();
+ databaseMeta.setName("unit-test-db");
+ databaseMeta.setDatabaseType("NONE");
+ MemoryMetadataProvider provider = new MemoryMetadataProvider();
+ provider.getSerializer(DatabaseMeta.class).save(databaseMeta);
+
+ ActionSimpleEval action =
+ ActionSerializationTestUtil.testSerialization(
+ "/simple-eval-action.xml", ActionSimpleEval.class, provider);
+
+ assertEquals("2020", action.getCompareValue());
+ assertEquals("YEAR", action.getVariableName());
+ assertEquals(ValueType.VARIABLE, action.getValueType());
+ assertEquals(FieldType.NUMBER, action.getFieldType());
+ assertEquals("FieldTest", action.getFieldName());
+ assertEquals(SuccessStringCondition.EQUAL,
action.getSuccessStringCondition());
+ assertEquals(SuccessNumberCondition.BETWEEN,
action.getSuccessNumberCondition());
+ assertEquals(SuccessBooleanCondition.FALSE,
action.getSuccessBooleanCondition());
+
+ assertEquals("100", action.getMinValue());
+ assertEquals("200", action.getMaxValue());
+
+ assertFalse(action.isSuccessWhenVarSet());
+ }
+}
\ No newline at end of file
diff --git
a/plugins/actions/simpleeval/src/test/java/org/apache/hop/workflow/actions/simpleeval/WorkflowActionSimpleEvalLoadSaveTest.java
b/plugins/actions/simpleeval/src/test/java/org/apache/hop/workflow/actions/simpleeval/WorkflowActionSimpleEvalLoadSaveTest.java
deleted file mode 100644
index 30529884e9..0000000000
---
a/plugins/actions/simpleeval/src/test/java/org/apache/hop/workflow/actions/simpleeval/WorkflowActionSimpleEvalLoadSaveTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hop.workflow.actions.simpleeval;
-
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
-import
org.apache.hop.workflow.action.loadsave.WorkflowActionLoadSaveTestSupport;
-import org.junit.ClassRule;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
-public class WorkflowActionSimpleEvalLoadSaveTest
- extends WorkflowActionLoadSaveTestSupport<ActionSimpleEval> {
- @ClassRule public static RestoreHopEngineEnvironment env = new
RestoreHopEngineEnvironment();
-
- @Override
- protected Class<ActionSimpleEval> getActionClass() {
- return ActionSimpleEval.class;
- }
-
- @Override
- protected List<String> listAttributes() {
- return Arrays.asList(
- "name",
- "description",
- "fieldname",
- "variablename",
- "mask",
- "comparevalue",
- "minvalue",
- "maxvalue",
- "successwhenvarset");
- }
-
- @Override
- protected Map<String, String> createGettersMap() {
- return toMap(
- "fieldname", "getFieldName",
- "variablename", "getVariableName",
- "comparevalue", "getCompareValue",
- "minvalue", "getMinValue",
- "maxvalue", "getMaxValue",
- "successwhenvarset", "isSuccessWhenVarSet");
- }
-
- @Override
- protected Map<String, String> createSettersMap() {
- return toMap(
- "fieldname", "setFieldName",
- "variablename", "setVariableName",
- "comparevalue", "setCompareValue",
- "minvalue", "setMinValue",
- "maxvalue", "setMaxValue",
- "successwhenvarset", "setSuccessWhenVarSet");
- }
-}
diff --git
a/plugins/actions/simpleeval/src/test/resources/simple-eval-action.xml
b/plugins/actions/simpleeval/src/test/resources/simple-eval-action.xml
new file mode 100644
index 0000000000..2f5294fbeb
--- /dev/null
+++ b/plugins/actions/simpleeval/src/test/resources/simple-eval-action.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
~
+ this work for additional information regarding copyright ownership. ~
The
+ ASF licenses this file to You under the Apache License, Version 2.0 ~
(the
+ "License"); you may not use this file except in compliance with ~ the
License.
+ You may obtain a copy of the License at ~ ~
http://www.apache.org/licenses/LICENSE-2.0
+ ~ ~ Unless required by applicable law or agreed to in writing, software
~
+ distributed under the License is distributed on an "AS IS" BASIS, ~
WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See
the
+ License for the specific language governing permissions and ~
limitations
+ under the License. ~ -->
+<action>
+ <name>Simple evaluation</name>
+ <description />
+ <type>SIMPLE_EVAL</type>
+ <attributes />
+ <comparevalue>2020</comparevalue>
+ <fieldname>FieldTest</fieldname>
+ <fieldtype>number</fieldtype>
+ <mask />
+ <maxvalue>200</maxvalue>
+ <minvalue>100</minvalue>
+ <successbooleancondition>false</successbooleancondition>
+ <successcondition>equal</successcondition>
+ <successnumbercondition>between</successnumbercondition>
+ <successwhenvarset>N</successwhenvarset>
+ <valuetype>variable</valuetype>
+ <variablename>YEAR</variablename>
+</action>
\ No newline at end of file