This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new a7924467b1 Issue #1968 (Evaluate File Metrics action code cleanup and
IT) (#6932)
a7924467b1 is described below
commit a7924467b13378b09855486e7848f159c02f1d9f
Author: Matt Casters <[email protected]>
AuthorDate: Thu Apr 2 14:23:47 2026 +0200
Issue #1968 (Evaluate File Metrics action code cleanup and IT) (#6932)
---
integration-tests/actions/files-0013/10-bytes.txt | 1 +
integration-tests/actions/files-0013/empty.txt | 0
.../actions/main-0013-evaluate-files-metrics.hwf | 261 ++++++
.../evalfilesmetrics/ActionEvalFilesMetrics.java | 937 +++++++--------------
.../ActionEvalFilesMetricsDialog.java | 571 ++++++-------
.../ActionEvalFilesMetricsTest.java | 69 ++
...WorkflowActionEvalFilesMetricsLoadSaveTest.java | 89 --
.../resources/action-evaluate-file-metrics.xml | 48 ++
8 files changed, 936 insertions(+), 1040 deletions(-)
diff --git a/integration-tests/actions/files-0013/10-bytes.txt
b/integration-tests/actions/files-0013/10-bytes.txt
new file mode 100644
index 0000000000..28d14454c3
--- /dev/null
+++ b/integration-tests/actions/files-0013/10-bytes.txt
@@ -0,0 +1 @@
+123456789
diff --git a/integration-tests/actions/files-0013/empty.txt
b/integration-tests/actions/files-0013/empty.txt
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/integration-tests/actions/main-0013-evaluate-files-metrics.hwf
b/integration-tests/actions/main-0013-evaluate-files-metrics.hwf
new file mode 100644
index 0000000000..f4f30878af
--- /dev/null
+++ b/integration-tests/actions/main-0013-evaluate-files-metrics.hwf
@@ -0,0 +1,261 @@
+<?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.
+
+-->
+<workflow>
+ <name>main-0013-evaluate-files-metrics</name>
+ <name_sync_with_filename>Y</name_sync_with_filename>
+ <description/>
+ <extended_description/>
+ <workflow_version/>
+ <created_user>-</created_user>
+ <created_date>2026/04/02 11:58:48.230</created_date>
+ <modified_user>-</modified_user>
+ <modified_date>2026/04/02 11:58:48.230</modified_date>
+ <parameters>
+ </parameters>
+ <actions>
+ <action>
+ <name>Start</name>
+ <description/>
+ <type>SPECIAL</type>
+ <attributes/>
+ <repeat>N</repeat>
+ <schedulerType>0</schedulerType>
+ <intervalSeconds>0</intervalSeconds>
+ <intervalMinutes>60</intervalMinutes>
+ <DayOfMonth>1</DayOfMonth>
+ <weekDay>1</weekDay>
+ <minutes>0</minutes>
+ <hour>12</hour>
+ <doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
+ <parallel>N</parallel>
+ <xloc>80</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>empty?</name>
+ <description/>
+ <type>EVAL_FILES_METRICS</type>
+ <attributes/>
+ <result_filenames_wildcard/>
+ <Result_field_file/>
+ <Result_field_wildcard/>
+ <Result_field_includesubfolders/>
+ <fields>
+ <field>
+
<source_filefolder>${PROJECT_HOME}/files-0013/empty.txt</source_filefolder>
+ <wildcard/>
+ <include_subFolders>N</include_subFolders>
+ </field>
+ </fields>
+ <comparevalue>0</comparevalue>
+ <minvalue/>
+ <maxvalue/>
+ <successnumbercondition>equal</successnumbercondition>
+ <source_files>files</source_files>
+ <evaluation_type>size</evaluation_type>
+ <scale>bytes</scale>
+ <parallel>N</parallel>
+ <xloc>208</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>10 bytes</name>
+ <description/>
+ <type>EVAL_FILES_METRICS</type>
+ <attributes/>
+ <result_filenames_wildcard/>
+ <Result_field_file/>
+ <Result_field_wildcard/>
+ <Result_field_includesubfolders/>
+ <fields>
+ </fields>
+ <comparevalue>10</comparevalue>
+ <minvalue/>
+ <maxvalue/>
+ <successnumbercondition>equal</successnumbercondition>
+ <source_files>filenamesresult</source_files>
+ <evaluation_type>size</evaluation_type>
+ <scale>bytes</scale>
+ <parallel>N</parallel>
+ <xloc>208</xloc>
+ <yloc>144</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>add 10-bytes.txt</name>
+ <description/>
+ <type>ADD_RESULT_FILENAMES</type>
+ <attributes/>
+ <arg_from_previous>N</arg_from_previous>
+ <delete_all_before>N</delete_all_before>
+ <include_subfolders>N</include_subfolders>
+ <fields>
+ <field>
+ <name>${PROJECT_HOME}/files-0013</name>
+ <filemask>10-bytes.txt</filemask>
+ </field>
+ </fields>
+ <parallel>N</parallel>
+ <xloc>320</xloc>
+ <yloc>64</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>> 5 bytes</name>
+ <description/>
+ <type>EVAL_FILES_METRICS</type>
+ <attributes/>
+ <result_filenames_wildcard/>
+ <Result_field_file/>
+ <Result_field_wildcard/>
+ <Result_field_includesubfolders/>
+ <fields>
+ </fields>
+ <comparevalue>5</comparevalue>
+ <minvalue/>
+ <maxvalue/>
+ <successnumbercondition>greater</successnumbercondition>
+ <source_files>filenamesresult</source_files>
+ <evaluation_type>size</evaluation_type>
+ <scale>bytes</scale>
+ <parallel>N</parallel>
+ <xloc>320</xloc>
+ <yloc>144</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>< 2 kbytes</name>
+ <description/>
+ <type>EVAL_FILES_METRICS</type>
+ <attributes/>
+ <result_filenames_wildcard/>
+ <Result_field_file/>
+ <Result_field_wildcard/>
+ <Result_field_includesubfolders/>
+ <fields>
+ </fields>
+ <comparevalue>2</comparevalue>
+ <minvalue/>
+ <maxvalue/>
+ <successnumbercondition>smaller</successnumbercondition>
+ <source_files>filenamesresult</source_files>
+ <evaluation_type>size</evaluation_type>
+ <scale>kbytes</scale>
+ <parallel>N</parallel>
+ <xloc>416</xloc>
+ <yloc>144</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>Success</name>
+ <description/>
+ <type>SUCCESS</type>
+ <attributes/>
+ <parallel>N</parallel>
+ <xloc>416</xloc>
+ <yloc>224</yloc>
+ <attributes_hac/>
+ </action>
+ <action>
+ <name>2 files</name>
+ <description/>
+ <type>EVAL_FILES_METRICS</type>
+ <attributes/>
+ <result_filenames_wildcard/>
+ <Result_field_file/>
+ <Result_field_wildcard/>
+ <Result_field_includesubfolders/>
+ <fields>
+ <field>
+ <source_filefolder>${PROJECT_HOME}/files-0013/</source_filefolder>
+ <wildcard>.*\.txt</wildcard>
+ <include_subFolders>N</include_subFolders>
+ </field>
+ </fields>
+ <comparevalue>2</comparevalue>
+ <minvalue/>
+ <maxvalue/>
+ <successnumbercondition>equal</successnumbercondition>
+ <source_files>files</source_files>
+ <evaluation_type>count</evaluation_type>
+ <scale>kbytes</scale>
+ <parallel>N</parallel>
+ <xloc>208</xloc>
+ <yloc>224</yloc>
+ <attributes_hac/>
+ </action>
+ </actions>
+ <hops>
+ <hop>
+ <from>Start</from>
+ <to>empty?</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>empty?</from>
+ <to>add 10-bytes.txt</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>add 10-bytes.txt</from>
+ <to>10 bytes</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>Y</unconditional>
+ </hop>
+ <hop>
+ <from>10 bytes</from>
+ <to>> 5 bytes</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>> 5 bytes</from>
+ <to>< 2 kbytes</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>< 2 kbytes</from>
+ <to>2 files</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ <hop>
+ <from>2 files</from>
+ <to>Success</to>
+ <enabled>Y</enabled>
+ <evaluation>Y</evaluation>
+ <unconditional>N</unconditional>
+ </hop>
+ </hops>
+ <notepads>
+ </notepads>
+ <attributes/>
+</workflow>
diff --git
a/plugins/actions/evalfilesmetrics/src/main/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetrics.java
b/plugins/actions/evalfilesmetrics/src/main/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetrics.java
index 1439eb8585..b6473fc90d 100644
---
a/plugins/actions/evalfilesmetrics/src/main/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetrics.java
+++
b/plugins/actions/evalfilesmetrics/src/main/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetrics.java
@@ -19,27 +19,30 @@ package org.apache.hop.workflow.actions.evalfilesmetrics;
import java.io.IOException;
import java.math.BigDecimal;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.AllFileSelector;
import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSelectInfo;
import org.apache.commons.vfs2.FileType;
-import org.apache.hop.core.Const;
import org.apache.hop.core.ICheckResult;
import org.apache.hop.core.Result;
import org.apache.hop.core.ResultFile;
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.util.Utils;
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.core.vfs.HopVfs;
-import org.apache.hop.core.xml.XmlHandler;
import org.apache.hop.i18n.BaseMessages;
+import org.apache.hop.metadata.api.HopMetadataProperty;
+import org.apache.hop.metadata.api.IEnumHasCodeAndDescription;
import org.apache.hop.metadata.api.IHopMetadataProvider;
import org.apache.hop.workflow.WorkflowMeta;
import org.apache.hop.workflow.action.ActionBase;
@@ -49,7 +52,6 @@ import
org.apache.hop.workflow.action.validator.ActionValidatorUtils;
import org.apache.hop.workflow.action.validator.AndValidator;
import org.apache.hop.workflow.action.validator.ValidatorContext;
import org.apache.hop.workflow.engine.IWorkflowEngine;
-import org.w3c.dom.Node;
/** This defines a 'evaluate files metrics' action. */
@Action(
@@ -60,295 +62,119 @@ import org.w3c.dom.Node;
categoryDescription =
"i18n:org.apache.hop.workflow:ActionCategory.Category.Conditions",
keywords = "i18n::ActionEvalFilesMetrics.keyword",
documentationUrl = "/workflow/actions/evalfilesmetrics.html")
+@Getter
+@Setter
@SuppressWarnings("java:S1104")
public class ActionEvalFilesMetrics extends ActionBase implements Cloneable,
IAction {
private static final Class<?> PKG = ActionEvalFilesMetrics.class;
- 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;
- private static final String CONST_SPACE = " ";
- private static final String CONST_SPACE_SHORT = " ";
+ public static final BigDecimal ONE = new BigDecimal(1);
+
private static final String CONST_CAN_NOT_FIND_FIELD =
"ActionEvalFilesMetrics.Error.CanNotFindField";
private static final String CONST_COMPARE_WITH_VALUE =
"ActionEvalFilesMetrics.Log.CompareWithValue";
- public static final String[] successNumberConditionCode =
- new String[] {
- "equal",
- "different",
- "smaller",
- "smallequal",
- "greater",
- "greaterequal",
- "between",
- "inlist",
- "notinlist"
- };
-
- public static final String[] successNumberConditionDesc =
- new String[] {
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenEqual.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenDifferent.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenSmallThan.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenSmallOrEqualThan.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenGreaterThan.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenGreaterOrEqualThan.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessBetween.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenInList.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenNotInList.Label"),
- };
-
- public static final BigDecimal ONE = new BigDecimal(1);
+ public static final String YES = "Y";
+ public static final String NO = "N";
- public static final String[] IncludeSubFoldersDesc =
+ public static final String[] NO_YES =
new String[] {
BaseMessages.getString(PKG, "System.Combo.No"),
BaseMessages.getString(PKG, "System.Combo.Yes")
};
- public static final String[] IncludeSubFoldersCodes = new String[] {"N",
"Y"};
- private static final String YES = "Y";
- private static final String NO = "N";
- public static final String[] scaleDesc =
- new String[] {
- BaseMessages.getString(PKG, "ActionEvalFilesMetrics.Bytes.Label"),
- BaseMessages.getString(PKG, "ActionEvalFilesMetrics.KBytes.Label"),
- BaseMessages.getString(PKG, "ActionEvalFilesMetrics.MBytes.Label"),
- BaseMessages.getString(PKG, "ActionEvalFilesMetrics.GBytes.Label")
- };
- public static final String[] scaleCodes = new String[] {"bytes", "kbytes",
"mbytes", "gbytes"};
- public static final int SCALE_BYTES = 0;
- public static final int SCALE_KBYTES = 1;
- public static final int SCALE_MBYTES = 2;
- public static final int SCALE_GBYTES = 3;
+ @HopMetadataProperty(key = "scale", storeWithCode = true)
+ private Scale scale;
- public int scale;
+ @HopMetadataProperty(key = "source_files", storeWithCode = true)
+ private SourceFilesType sourceFilesType;
- public static final String[] SourceFilesDesc =
- new String[] {
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SourceFiles.Files.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SourceFiles.FilenamesResult.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SourceFiles.PreviousResult.Label"),
- };
- public static final String[] SourceFilesCodes =
- new String[] {"files", "filenamesresult", "previousresult"};
- public static final int SOURCE_FILES_FILES = 0;
- public static final int SOURCE_FILES_FILENAMES_RESULT = 1;
- public static final int SOURCE_FILES_PREVIOUS_RESULT = 2;
+ @HopMetadataProperty(key = "evaluation_type", storeWithCode = true)
+ private EvaluationType evaluationType;
- public int sourceFiles;
+ @HopMetadataProperty(key = "comparevalue")
+ private String compareValue;
- public static final String[] EvaluationTypeDesc =
- new String[] {
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.EvaluationType.Size.Label"),
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.EvaluationType.Count.Label"),
- };
- public static final String[] EvaluationTypeCodes =
- new String[] {
- "size", "count",
- };
- public static final int EVALUATE_TYPE_SIZE = 0;
- public static final int EVALUATE_TYPE_COUNT = 1;
+ @HopMetadataProperty(key = "minvalue")
+ private String minValue;
- public int evaluationType;
+ @HopMetadataProperty(key = "maxvalue")
+ private String maxValue;
- private String comparevalue;
- private String minvalue;
- private String maxvalue;
- private int successConditionType;
+ @HopMetadataProperty(key = "successnumbercondition", storeWithCode = true)
+ private SuccesConditionType successConditionType;
+ @HopMetadataProperty(key = "result_filenames_wildcard")
private String resultFilenamesWildcard;
- public boolean argFromPrevious;
-
- private String[] sourceFileFolder;
- private String[] sourceWildcard;
- private String[] sourceIncludeSubfolders;
-
- private BigDecimal evaluationValue;
- private BigDecimal filesCount;
- private long nrErrors;
+ @HopMetadataProperty(key = "field", groupKey = "fields")
+ private List<SourceFile> sourceFiles;
+ @HopMetadataProperty(key = "Result_field_file")
private String resultFieldFile;
+
+ @HopMetadataProperty(key = "Result_field_wildcard")
private String resultFieldWildcard;
- private String resultFieldIncludesubFolders;
- private BigDecimal compareValue;
- private BigDecimal minValue;
- private BigDecimal maxValue;
+ @HopMetadataProperty(key = "Result_field_includesubfolders")
+ private String resultFieldIncludeSubFolders;
+
+ private BigDecimal realCompareValue;
+ private BigDecimal realMinValue;
+ private BigDecimal realMaxValue;
+ private BigDecimal realEvaluationValue;
+ private BigDecimal realFilesCount;
+ private long nrErrors;
public ActionEvalFilesMetrics(String n) {
super(n, "");
- sourceFileFolder = null;
- sourceWildcard = null;
- sourceIncludeSubfolders = null;
- scale = SCALE_BYTES;
- sourceFiles = SOURCE_FILES_FILES;
- evaluationType = EVALUATE_TYPE_SIZE;
- successConditionType = SUCCESS_NUMBER_CONDITION_GREATER;
- resultFilenamesWildcard = null;
- resultFieldFile = null;
- resultFieldWildcard = null;
- resultFieldIncludesubFolders = null;
+ scale = Scale.BYTES;
+ sourceFilesType = SourceFilesType.FILES;
+ evaluationType = EvaluationType.SIZE;
+ successConditionType = SuccesConditionType.GREATER;
}
public ActionEvalFilesMetrics() {
this("");
- }
-
- public void allocate(int nrFields) {
- sourceFileFolder = new String[nrFields];
- sourceWildcard = new String[nrFields];
- sourceIncludeSubfolders = new String[nrFields];
+ sourceFiles = new ArrayList<>();
+ }
+
+ public ActionEvalFilesMetrics(ActionEvalFilesMetrics a) {
+ super(a);
+ this.scale = a.scale;
+ this.sourceFilesType = a.sourceFilesType;
+ this.evaluationType = a.evaluationType;
+ this.compareValue = a.compareValue;
+ this.minValue = a.minValue;
+ this.maxValue = a.maxValue;
+ this.successConditionType = a.successConditionType;
+ this.resultFilenamesWildcard = a.resultFilenamesWildcard;
+ this.resultFieldFile = a.resultFieldFile;
+ this.resultFieldWildcard = a.resultFieldWildcard;
+ this.resultFieldIncludeSubFolders = a.resultFieldIncludeSubFolders;
+ this.realCompareValue = a.realCompareValue;
+ this.realMinValue = a.realMinValue;
+ this.realMaxValue = a.realMaxValue;
+ this.realEvaluationValue = a.realEvaluationValue;
+ this.realFilesCount = a.realFilesCount;
+ this.nrErrors = a.nrErrors;
+ this.sourceFiles = new ArrayList<>();
+ a.sourceFiles.forEach(f -> this.sourceFiles.add(new SourceFile(f)));
}
@Override
public Object clone() {
- ActionEvalFilesMetrics je = (ActionEvalFilesMetrics) super.clone();
- if (sourceFileFolder != null) {
- int nrFields = sourceFileFolder.length;
- je.allocate(nrFields);
- System.arraycopy(sourceFileFolder, 0, je.sourceFileFolder, 0, nrFields);
- System.arraycopy(sourceWildcard, 0, je.sourceWildcard, 0, nrFields);
- System.arraycopy(sourceIncludeSubfolders, 0, je.sourceIncludeSubfolders,
0, nrFields);
- }
- return je;
- }
-
- @Override
- public String getXml() {
- StringBuilder retval = new StringBuilder(300);
-
- retval.append(super.getXml());
- retval
- .append(CONST_SPACE_SHORT)
- .append(XmlHandler.addTagValue("result_filenames_wildcard",
resultFilenamesWildcard));
- retval
- .append(CONST_SPACE_SHORT)
- .append(XmlHandler.addTagValue("Result_field_file", resultFieldFile));
- retval
- .append(CONST_SPACE_SHORT)
- .append(XmlHandler.addTagValue("Result_field_wildcard",
resultFieldWildcard));
- retval
- .append(CONST_SPACE_SHORT)
- .append(
- XmlHandler.addTagValue("Result_field_includesubfolders",
resultFieldIncludesubFolders));
-
- retval.append(" <fields>").append(Const.CR);
- if (sourceFileFolder != null) {
- for (int i = 0; i < sourceFileFolder.length; i++) {
- retval.append(" <field>").append(Const.CR);
- retval
- .append(CONST_SPACE)
- .append(XmlHandler.addTagValue("source_filefolder",
sourceFileFolder[i]));
- retval.append(CONST_SPACE).append(XmlHandler.addTagValue("wildcard",
sourceWildcard[i]));
- retval
- .append(CONST_SPACE)
- .append(XmlHandler.addTagValue("include_subFolders",
sourceIncludeSubfolders[i]));
- retval.append(" </field>").append(Const.CR);
- }
- }
- retval.append(" </fields>").append(Const.CR);
-
retval.append(CONST_SPACE_SHORT).append(XmlHandler.addTagValue("comparevalue",
comparevalue));
- retval.append(CONST_SPACE_SHORT).append(XmlHandler.addTagValue("minvalue",
minvalue));
- retval.append(CONST_SPACE_SHORT).append(XmlHandler.addTagValue("maxvalue",
maxvalue));
- retval
- .append(CONST_SPACE_SHORT)
- .append(
- XmlHandler.addTagValue(
- "successnumbercondition",
getSuccessNumberConditionCode(successConditionType)));
- retval
- .append(CONST_SPACE_SHORT)
- .append(XmlHandler.addTagValue("source_files",
getSourceFilesCode(sourceFiles)));
- retval
- .append(CONST_SPACE_SHORT)
- .append(XmlHandler.addTagValue("evaluation_type",
getEvaluationTypeCode(evaluationType)));
- retval.append(CONST_SPACE_SHORT).append(XmlHandler.addTagValue("scale",
getScaleCode(scale)));
- return retval.toString();
- }
-
- public static String getIncludeSubFolders(String tt) {
- if (tt == null) {
- return IncludeSubFoldersCodes[0];
- }
- if (tt.equals(IncludeSubFoldersDesc[1])) {
- return IncludeSubFoldersCodes[1];
- } else {
- return IncludeSubFoldersCodes[0];
- }
- }
-
- public static String getIncludeSubFoldersDesc(String tt) {
- if (tt == null) {
- return IncludeSubFoldersDesc[0];
- }
- if (tt.equals(IncludeSubFoldersCodes[1])) {
- return IncludeSubFoldersDesc[1];
- } else {
- return IncludeSubFoldersDesc[0];
- }
- }
-
- @Override
- public void loadXml(Node entrynode, IHopMetadataProvider metadataProvider,
IVariables variables)
- throws HopXmlException {
- try {
- super.loadXml(entrynode);
-
- Node fields = XmlHandler.getSubNode(entrynode, "fields");
-
- // How many field arguments?
- int nrFields = XmlHandler.countNodes(fields, "field");
- allocate(nrFields);
-
- // Read them all...
- for (int i = 0; i < nrFields; i++) {
- Node fnode = XmlHandler.getSubNodeByNr(fields, "field", i);
-
- sourceFileFolder[i] = XmlHandler.getTagValue(fnode,
"source_filefolder");
- sourceWildcard[i] = XmlHandler.getTagValue(fnode, "wildcard");
- sourceIncludeSubfolders[i] = XmlHandler.getTagValue(fnode,
"include_subFolders");
- }
-
- resultFilenamesWildcard = XmlHandler.getTagValue(entrynode,
"result_filenames_wildcard");
- resultFieldFile = XmlHandler.getTagValue(entrynode, "result_field_file");
- resultFieldWildcard = XmlHandler.getTagValue(entrynode,
"result_field_wildcard");
- resultFieldIncludesubFolders =
- XmlHandler.getTagValue(entrynode, "result_field_includesubfolders");
- comparevalue = XmlHandler.getTagValue(entrynode, "comparevalue");
- minvalue = XmlHandler.getTagValue(entrynode, "minvalue");
- maxvalue = XmlHandler.getTagValue(entrynode, "maxvalue");
- successConditionType =
- getSuccessNumberConditionByCode(
- Const.NVL(XmlHandler.getTagValue(entrynode,
"successnumbercondition"), ""));
- sourceFiles =
- getSourceFilesByCode(Const.NVL(XmlHandler.getTagValue(entrynode,
"source_files"), ""));
- evaluationType =
- getEvaluationTypeByCode(
- Const.NVL(XmlHandler.getTagValue(entrynode, "evaluation_type"),
""));
- scale = getScaleByCode(Const.NVL(XmlHandler.getTagValue(entrynode,
"scale"), ""));
- } catch (HopXmlException xe) {
- throw new HopXmlException(
- BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Error.Exception.UnableLoadXML"), xe);
- }
+ return new ActionEvalFilesMetrics(this);
}
@Override
- public Result execute(Result previousResult, int nr) throws HopException {
- Result result = previousResult;
+ public Result execute(Result result, int nr) throws HopException {
result.setNrErrors(1);
result.setResult(false);
List<RowMetaAndData> rows = result.getRows();
- RowMetaAndData resultRow = null;
+ RowMetaAndData resultRow;
try {
initMetrics();
@@ -358,19 +184,18 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
}
// Get source and destination files, also wildcard
- String[] vSourceFileFolder = sourceFileFolder;
- String[] vwildcard = sourceWildcard;
- String[] vincludeSubFolders = sourceIncludeSubfolders;
+ List<SourceFile> vSourceFiles = new ArrayList<>();
+ sourceFiles.forEach(f -> vSourceFiles.add(new SourceFile(f)));
- switch (getSourceFiles()) {
- case SOURCE_FILES_PREVIOUS_RESULT:
+ switch (getSourceFilesType()) {
+ case PREVIOUS_RESULT:
// Filenames are retrieved from previous result rows
-
+ //
String realResultFieldFile = resolve(getResultFieldFile());
String realResultFieldWildcard = resolve(getResultFieldWildcard());
- String realResultFieldIncluseSubfolders =
resolve(getResultFieldIncludeSubfolders());
+ String realResultFieldIncludeSubfolders =
resolve(getResultFieldIncludeSubFolders());
- int indexOfResultFieldFile = -1;
+ int indexOfResultFieldFile;
if (Utils.isEmpty(realResultFieldFile)) {
logError(
BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Error.ResultFieldsFileMissing"));
@@ -389,15 +214,15 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
(rows != null ? rows.size() : 0) + ""));
}
- if (!Utils.isEmpty(rows)) {
+ if (rows != null && !rows.isEmpty()) {
// We get rows
- RowMetaAndData firstRow = rows.get(0);
+ RowMetaAndData firstRow = rows.getFirst();
indexOfResultFieldFile =
firstRow.getRowMeta().indexOfValue(realResultFieldFile);
if (indexOfResultFieldFile == -1) {
logError(BaseMessages.getString(PKG, CONST_CAN_NOT_FIND_FIELD,
realResultFieldFile));
return result;
}
- if (!Utils.isEmpty(realResultFieldWildcard)) {
+ if (StringUtils.isNotEmpty(realResultFieldWildcard)) {
indexOfResultFieldWildcard =
firstRow.getRowMeta().indexOfValue(realResultFieldWildcard);
if (indexOfResultFieldWildcard == -1) {
@@ -406,13 +231,13 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
return result;
}
}
- if (!Utils.isEmpty(realResultFieldIncluseSubfolders)) {
+ if (StringUtils.isNotEmpty(realResultFieldIncludeSubfolders)) {
indexOfResultFieldIncludeSubfolders =
-
firstRow.getRowMeta().indexOfValue(realResultFieldIncluseSubfolders);
+
firstRow.getRowMeta().indexOfValue(realResultFieldIncludeSubfolders);
if (indexOfResultFieldIncludeSubfolders == -1) {
logError(
BaseMessages.getString(
- PKG, CONST_CAN_NOT_FIND_FIELD,
realResultFieldIncluseSubfolders));
+ PKG, CONST_CAN_NOT_FIND_FIELD,
realResultFieldIncludeSubfolders));
return result;
}
}
@@ -448,13 +273,12 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
vSourceFileFolderPrevious,
vWildcardPrevious,
vincludeSubFoldersPrevious,
- parentWorkflow,
- result);
+ parentWorkflow);
}
}
break;
- case SOURCE_FILES_FILENAMES_RESULT:
+ case FILENAMES_RESULT:
List<ResultFile> resultFiles = result.getResultFilesList();
if (isDetailed()) {
logDetailed(
@@ -484,7 +308,7 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
getIt = matcher.matches();
}
if (getIt) {
- getFileSize(file, result, parentWorkflow);
+ getFileSize(file);
}
}
} catch (Exception e) {
@@ -510,20 +334,22 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
default:
// static files/folders
// from grid entered by user
- if (vSourceFileFolder != null && vSourceFileFolder.length > 0) {
- for (int i = 0; i < vSourceFileFolder.length &&
!parentWorkflow.isStopped(); i++) {
-
+ if (!vSourceFiles.isEmpty()) {
+ for (SourceFile vSourceFile : vSourceFiles) {
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG,
"ActionEvalFilesMetrics.Log.ProcessingRow",
- vSourceFileFolder[i],
- vwildcard[i]));
+ vSourceFile.getSourceFileFolder(),
+ vSourceFile.getSourceWildcard()));
}
processFileFolder(
- vSourceFileFolder[i], vwildcard[i], vincludeSubFolders[i],
parentWorkflow, result);
+ vSourceFile.getSourceFileFolder(),
+ vSourceFile.getSourceWildcard(),
+ vSourceFile.getSourceIncludeSubfolders(),
+ parentWorkflow);
}
} else {
logError(BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Error.FilesGridEmpty"));
@@ -533,7 +359,7 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
}
result.setResult(isSuccess());
- result.setNrErrors(getNrError());
+ result.setNrErrors(getNrErrors());
displayResults();
return result;
@@ -544,124 +370,106 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
logDetailed("=======================================");
logDetailed(
BaseMessages.getString(
- PKG, "ActionEvalFilesMetrics.Log.Info.FilesCount",
String.valueOf(getFilesCount())));
- if (evaluationType == EVALUATE_TYPE_SIZE) {
+ PKG,
+ "ActionEvalFilesMetrics.Log.Info.FilesCount",
+ String.valueOf(getRealFilesCount())));
+ if (evaluationType == EvaluationType.SIZE) {
logDetailed(
BaseMessages.getString(
PKG,
"ActionEvalFilesMetrics.Log.Info.FilesSize",
- String.valueOf(getEvaluationValue())));
+ String.valueOf(getRealEvaluationValue())));
}
logDetailed(
BaseMessages.getString(
- PKG, "ActionEvalFilesMetrics.Log.Info.NrErrors",
String.valueOf(getNrError())));
+ PKG, "ActionEvalFilesMetrics.Log.Info.NrErrors",
String.valueOf(getNrErrors())));
logDetailed("=======================================");
}
}
- private long getNrError() {
- return this.nrErrors;
- }
-
- private BigDecimal getEvaluationValue() {
- return this.evaluationValue;
- }
-
- private BigDecimal getFilesCount() {
- return this.filesCount;
- }
-
- public int getSuccessConditionType() {
- return successConditionType;
- }
-
- public void setSuccessConditionType(int successConditionType) {
- this.successConditionType = successConditionType;
- }
-
private boolean isSuccess() {
boolean retval = false;
switch (successConditionType) {
- case SUCCESS_NUMBER_CONDITION_EQUAL: // equal
+ case EQUAL: // equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
CONST_COMPARE_WITH_VALUE,
- String.valueOf(evaluationValue),
- String.valueOf(compareValue)));
+ String.valueOf(realEvaluationValue),
+ String.valueOf(realCompareValue)));
}
- retval = (getEvaluationValue().compareTo(compareValue) == 0);
+ retval = (getRealEvaluationValue().compareTo(realCompareValue) == 0);
break;
- case SUCCESS_NUMBER_CONDITION_DIFFERENT: // different
+ case DIFFERENT: // different
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
CONST_COMPARE_WITH_VALUE,
- String.valueOf(evaluationValue),
- String.valueOf(compareValue)));
+ String.valueOf(realEvaluationValue),
+ String.valueOf(realCompareValue)));
}
- retval = (getEvaluationValue().compareTo(compareValue) != 0);
+ retval = (getRealEvaluationValue().compareTo(realCompareValue) != 0);
break;
- case SUCCESS_NUMBER_CONDITION_SMALLER: // smaller
+ case SMALLER: // smaller
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
CONST_COMPARE_WITH_VALUE,
- String.valueOf(evaluationValue),
- String.valueOf(compareValue)));
+ String.valueOf(realEvaluationValue),
+ String.valueOf(realCompareValue)));
}
- retval = (getEvaluationValue().compareTo(compareValue) < 0);
+ retval = (getRealEvaluationValue().compareTo(realCompareValue) < 0);
break;
- case SUCCESS_NUMBER_CONDITION_SMALLER_EQUAL: // smaller or equal
+ case SMALLER_EQUAL: // smaller or equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
CONST_COMPARE_WITH_VALUE,
- String.valueOf(evaluationValue),
- String.valueOf(compareValue)));
+ String.valueOf(realEvaluationValue),
+ String.valueOf(realCompareValue)));
}
- retval = (getEvaluationValue().compareTo(compareValue) <= 0);
+ retval = (getRealEvaluationValue().compareTo(realCompareValue) <= 0);
break;
- case SUCCESS_NUMBER_CONDITION_GREATER: // greater
+ case GREATER: // greater
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
CONST_COMPARE_WITH_VALUE,
- String.valueOf(evaluationValue),
- String.valueOf(compareValue)));
+ String.valueOf(realEvaluationValue),
+ String.valueOf(realCompareValue)));
}
- retval = (getEvaluationValue().compareTo(compareValue) > 0);
+ retval = (getRealEvaluationValue().compareTo(realCompareValue) > 0);
break;
- case SUCCESS_NUMBER_CONDITION_GREATER_EQUAL: // greater or equal
+ case GREATER_EQUAL: // greater or equal
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
CONST_COMPARE_WITH_VALUE,
- String.valueOf(evaluationValue),
- String.valueOf(compareValue)));
+ String.valueOf(realEvaluationValue),
+ String.valueOf(realCompareValue)));
}
- retval = (getEvaluationValue().compareTo(compareValue) >= 0);
+ retval = (getRealEvaluationValue().compareTo(realCompareValue) >= 0);
break;
- case SUCCESS_NUMBER_CONDITION_BETWEEN: // between min and max
+ case BETWEEN: // between min and max
if (isDebug()) {
logDebug(
BaseMessages.getString(
PKG,
"ActionEvalFilesMetrics.Log.CompareWithValues",
- String.valueOf(evaluationValue),
- String.valueOf(minValue),
- String.valueOf(maxValue)));
+ String.valueOf(realEvaluationValue),
+ String.valueOf(realMinValue),
+ String.valueOf(realMaxValue)));
}
retval =
- (getEvaluationValue().compareTo(minValue) >= 0
- && getEvaluationValue().compareTo(maxValue) <= 0);
+ (getRealEvaluationValue().compareTo(realMinValue) >= 0
+ && getRealEvaluationValue().compareTo(realMaxValue) <= 0);
break;
default:
break;
@@ -671,113 +479,51 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
}
private void initMetrics() {
- evaluationValue = new BigDecimal(0);
- filesCount = new BigDecimal(0);
+ realEvaluationValue = new BigDecimal(0);
+ realFilesCount = new BigDecimal(0);
nrErrors = 0;
- if (successConditionType == SUCCESS_NUMBER_CONDITION_BETWEEN) {
- minValue = new BigDecimal(resolve(getMinValue()));
- maxValue = new BigDecimal(resolve(getMaxValue()));
+ if (successConditionType == SuccesConditionType.BETWEEN) {
+ realMinValue = new BigDecimal(resolve(getMinValue()));
+ realMaxValue = new BigDecimal(resolve(getMaxValue()));
} else {
- compareValue = new BigDecimal(resolve(getCompareValue()));
+ realCompareValue = new BigDecimal(resolve(getCompareValue()));
}
- if (evaluationType == EVALUATE_TYPE_SIZE) {
+ if (evaluationType == EvaluationType.SIZE) {
int multyply = 1;
switch (getScale()) {
- case SCALE_KBYTES:
+ case KBYTES:
multyply = 1024;
break;
- case SCALE_MBYTES:
+ case MBYTES:
multyply = 1048576;
break;
- case SCALE_GBYTES:
+ case GBYTES:
multyply = 1073741824;
break;
default:
break;
}
- if (successConditionType == SUCCESS_NUMBER_CONDITION_BETWEEN) {
- minValue = minValue.multiply(BigDecimal.valueOf(multyply));
- maxValue = maxValue.multiply(BigDecimal.valueOf(multyply));
+ if (successConditionType == SuccesConditionType.BETWEEN) {
+ realMinValue = realMinValue.multiply(BigDecimal.valueOf(multyply));
+ realMaxValue = realMaxValue.multiply(BigDecimal.valueOf(multyply));
} else {
- compareValue = compareValue.multiply(BigDecimal.valueOf(multyply));
+ realCompareValue =
realCompareValue.multiply(BigDecimal.valueOf(multyply));
}
}
- argFromPrevious = (getSourceFiles() == SOURCE_FILES_PREVIOUS_RESULT);
}
private void incrementErrors() {
nrErrors++;
}
- public int getSourceFiles() {
- return this.sourceFiles;
- }
-
- private void incrementFilesCount() {
- filesCount = filesCount.add(ONE);
- }
-
- public String[] getSourceFileFolder() {
- return sourceFileFolder;
- }
-
- public void setSourceFileFolder(String[] sourceFileFolder) {
- this.sourceFileFolder = sourceFileFolder;
- }
-
- public String[] getSourceWildcard() {
- return sourceWildcard;
- }
-
- public void setSourceWildcard(String[] sourceWildcard) {
- this.sourceWildcard = sourceWildcard;
- }
-
- public String[] getSourceIncludeSubfolders() {
- return sourceIncludeSubfolders;
- }
-
- public void setSourceIncludeSubfolders(String[] sourceIncludeSubfolders) {
- this.sourceIncludeSubfolders = sourceIncludeSubfolders;
- }
-
- public void setSourceFiles(int sourceFiles) {
- this.sourceFiles = sourceFiles;
- }
-
- public String getResultFieldFile() {
- return this.resultFieldFile;
- }
-
- public void setResultFieldFile(String field) {
- this.resultFieldFile = field;
- }
-
- public String getResultFieldWildcard() {
- return this.resultFieldWildcard;
- }
-
- public void setResultFieldWildcard(String field) {
- this.resultFieldWildcard = field;
- }
-
- public String getResultFieldIncludeSubfolders() {
- return this.resultFieldIncludesubFolders;
- }
-
- public void setResultFieldIncludeSubfolders(String field) {
- this.resultFieldIncludesubFolders = field;
- }
-
private void processFileFolder(
String sourcefilefoldername,
String wildcard,
String includeSubfolders,
- IWorkflowEngine<WorkflowMeta> parentWorkflow,
- Result result) {
+ IWorkflowEngine<WorkflowMeta> parentWorkflow) {
FileObject sourcefilefolder = null;
FileObject currentFile = null;
@@ -807,7 +553,7 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
if (sourcefilefolder.getType() == FileType.FILE) {
// We deals here with a file
// let's get file size
- getFileSize(sourcefilefolder, result, parentWorkflow);
+ getFileSize(sourcefilefolder);
} else if (sourcefilefolder.getType() == FileType.FOLDER) {
// We have a folder
@@ -855,12 +601,12 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
// Not in the Base Folder..Only if include sub folders
if (includeSubFolders
&& getFileWildcard(currentFile.getName().getBaseName(),
realWildcard)) {
- getFileSize(currentFile, result, parentWorkflow);
+ getFileSize(currentFile);
}
} else {
// In the base folder
if (getFileWildcard(currentFile.getName().getBaseName(),
realWildcard)) {
- getFileSize(currentFile, result, parentWorkflow);
+ getFileSize(currentFile);
}
}
}
@@ -906,35 +652,29 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
}
}
- private void getFileSize(
- FileObject file, Result result, IWorkflowEngine<WorkflowMeta>
parentWorkflow) {
+ private void getFileSize(FileObject file) {
try {
-
- incrementFilesCount();
if (isDetailed()) {
logDetailed(
BaseMessages.getString(
PKG,
"ActionEvalFilesMetrics.Log.GetFile",
file.toString(),
- String.valueOf(getFilesCount())));
+ String.valueOf(getRealFilesCount())));
}
- switch (evaluationType) {
- case EVALUATE_TYPE_SIZE:
- BigDecimal fileSize =
BigDecimal.valueOf(file.getContent().getSize());
- evaluationValue = evaluationValue.add(fileSize);
- if (isDebug()) {
- logDebug(
- BaseMessages.getString(
- PKG,
- "ActionEvalFilesMetrics.Log.AddedFileSize",
- String.valueOf(fileSize),
- file.toString()));
- }
- break;
- default:
- evaluationValue = evaluationValue.add(ONE);
- break;
+ if (evaluationType == EvaluationType.SIZE) {
+ BigDecimal fileSize = BigDecimal.valueOf(file.getContent().getSize());
+ realEvaluationValue = realEvaluationValue.add(fileSize);
+ if (isDebug()) {
+ logDebug(
+ BaseMessages.getString(
+ PKG,
+ "ActionEvalFilesMetrics.Log.AddedFileSize",
+ String.valueOf(fileSize),
+ file.toString()));
+ }
+ } else {
+ realEvaluationValue = realEvaluationValue.add(ONE);
}
} catch (Exception e) {
incrementErrors();
@@ -945,273 +685,192 @@ public class ActionEvalFilesMetrics extends ActionBase
implements Cloneable, IAc
}
/**
- * @param selectedfile
- * @param wildcard
- * @return True if the selectedfile matches the wildcard
+ * @param selectedFile The selected file
+ * @param wildcard The wildcard
+ * @return True if the selected file matches the wildcard
*/
- private boolean getFileWildcard(String selectedfile, String wildcard) {
- Pattern pattern = null;
+ private boolean getFileWildcard(String selectedFile, String wildcard) {
+ Pattern pattern;
boolean getIt = true;
if (!Utils.isEmpty(wildcard)) {
pattern = Pattern.compile(wildcard);
// First see if the file matches the regular expression!
- if (pattern != null) {
- Matcher matcher = pattern.matcher(selectedfile);
- getIt = matcher.matches();
- }
+ Matcher matcher = pattern.matcher(selectedFile);
+ getIt = matcher.matches();
}
-
return getIt;
}
- public void setMinValue(String minvalue) {
- this.minvalue = minvalue;
- }
-
- public String getMinValue() {
- return minvalue;
- }
-
- public void setCompareValue(String comparevalue) {
- this.comparevalue = comparevalue;
- }
-
- public String getCompareValue() {
- return comparevalue;
- }
-
- public void setResultFilenamesWildcard(String resultwildcard) {
- this.resultFilenamesWildcard = resultwildcard;
- }
-
- public String getResultFilenamesWildcard() {
- return this.resultFilenamesWildcard;
- }
-
- public void setMaxValue(String maxvalue) {
- this.maxvalue = maxvalue;
- }
-
- public String getMaxValue() {
- return maxvalue;
- }
-
- public static String getSuccessNumberConditionCode(int i) {
- if (i < 0 || i >= successNumberConditionCode.length) {
- return successNumberConditionCode[0];
- }
- return successNumberConditionCode[i];
- }
-
- public static int getSuccessNumberConditionByCode(String tt) {
- if (tt == null) {
- return 0;
- }
-
- for (int i = 0; i < successNumberConditionCode.length; i++) {
- if (successNumberConditionCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
- }
- return 0;
- }
-
- public static String getSuccessNumberConditionDesc(int i) {
- if (i < 0 || i >= successNumberConditionDesc.length) {
- return successNumberConditionDesc[0];
- }
- return successNumberConditionDesc[i];
- }
-
- public static int getSuccessNumberConditionByDesc(String tt) {
- if (tt == null) {
- return 0;
- }
+ @Override
+ public void check(
+ List<ICheckResult> remarks,
+ WorkflowMeta workflowMeta,
+ IVariables variables,
+ IHopMetadataProvider metadataProvider) {
+ boolean res =
+ ActionValidatorUtils.andValidator()
+ .validate(
+ this,
+ "arguments",
+ remarks,
+
AndValidator.putValidators(ActionValidatorUtils.notNullValidator()));
- for (int i = 0; i < successNumberConditionDesc.length; i++) {
- if (successNumberConditionDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ if (!res) {
+ return;
}
- // If this fails, try to match using the code.
- return getSuccessNumberByCode(tt);
- }
-
- private static int getSuccessNumberByCode(String tt) {
- if (tt == null) {
- return 0;
- }
+ ValidatorContext ctx = new ValidatorContext();
+ AbstractFileValidator.putVariableSpace(ctx, getVariables());
+ AndValidator.putValidators(
+ ctx, ActionValidatorUtils.notNullValidator(),
ActionValidatorUtils.fileExistsValidator());
- for (int i = 0; i < successNumberConditionCode.length; i++) {
- if (successNumberConditionCode[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ for (int i = 0; i < sourceFiles.size(); i++) {
+ ActionValidatorUtils.andValidator().validate(this, "arguments[" + (i++)
+ "]", remarks, ctx);
}
- return 0;
}
- public static int getScaleByDesc(String tt) {
- if (tt == null) {
- return 0;
- }
-
- for (int i = 0; i < scaleDesc.length; i++) {
- if (scaleDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
- }
-
- // If this fails, try to match using the code.
- return getScaleByCode(tt);
+ @Override
+ public boolean isEvaluation() {
+ return true;
}
- public static int getSourceFilesByDesc(String tt) {
- if (tt == null) {
- return 0;
- }
+ @Getter
+ public enum Scale implements IEnumHasCodeAndDescription {
+ BYTES("bytes", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Bytes.Label")),
+ KBYTES("kbytes", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.KBytes.Label")),
+ MBYTES("mbytes", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.MBytes.Label")),
+ GBYTES("gbytes", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.GBytes.Label")),
+ ;
+ final String code;
+ final String description;
- for (int i = 0; i < SourceFilesDesc.length; i++) {
- if (SourceFilesDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ Scale(String code, String description) {
+ this.code = code;
+ this.description = description;
}
- // If this fails, try to match using the code.
- return getSourceFilesByCode(tt);
- }
-
- public static int getEvaluationTypeByDesc(String tt) {
- if (tt == null) {
- return 0;
+ public static String[] getDescriptions() {
+ return IEnumHasCodeAndDescription.getDescriptions(Scale.class);
}
- for (int i = 0; i < EvaluationTypeDesc.length; i++) {
- if (EvaluationTypeDesc[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ public static Scale lookupDescription(String description) {
+ return IEnumHasCodeAndDescription.lookupDescription(Scale.class,
description, BYTES);
}
-
- // If this fails, try to match using the code.
- return getEvaluationTypeByCode(tt);
}
- private static int getScaleByCode(String tt) {
- if (tt == null) {
- return 0;
- }
+ @Getter
+ public enum SuccesConditionType implements IEnumHasCodeAndDescription {
+ EQUAL("equal", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenEqual.Label")),
+ DIFFERENT(
+ "different",
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenDifferent.Label")),
+ SMALLER(
+ "smaller",
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenSmallThan.Label")),
+ SMALLER_EQUAL(
+ "smallequal",
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenSmallOrEqualThan.Label")),
+ GREATER(
+ "greater",
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenGreaterThan.Label")),
+ GREATER_EQUAL(
+ "greaterequal",
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenGreaterOrEqualThan.Label")),
+ BETWEEN("between", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessBetween.Label")),
+ IN_LIST(
+ "inlist", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenInList.Label")),
+ NOT_IN_LIST(
+ "notinlist",
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessWhenNotInList.Label")),
+ ;
+ final String code;
+ final String description;
- for (int i = 0; i < scaleCodes.length; i++) {
- if (scaleCodes[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ SuccesConditionType(String code, String description) {
+ this.code = code;
+ this.description = description;
}
- return 0;
- }
- private static int getSourceFilesByCode(String tt) {
- if (tt == null) {
- return 0;
+ public static String[] getDescriptions() {
+ return
IEnumHasCodeAndDescription.getDescriptions(SuccesConditionType.class);
}
- for (int i = 0; i < SourceFilesCodes.length; i++) {
- if (SourceFilesCodes[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ public static SuccesConditionType lookupDescription(String description) {
+ return IEnumHasCodeAndDescription.lookupDescription(
+ SuccesConditionType.class, description, EQUAL);
}
- return 0;
}
- private static int getEvaluationTypeByCode(String tt) {
- if (tt == null) {
- return 0;
- }
+ @Getter
+ public enum EvaluationType implements IEnumHasCodeAndDescription {
+ SIZE("size", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.EvaluationType.Size.Label")),
+ COUNT(
+ "count", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.EvaluationType.Count.Label"));
+ final String code;
+ final String description;
- for (int i = 0; i < EvaluationTypeCodes.length; i++) {
- if (EvaluationTypeCodes[i].equalsIgnoreCase(tt)) {
- return i;
- }
+ EvaluationType(String code, String description) {
+ this.code = code;
+ this.description = description;
}
- return 0;
- }
- public static String getScaleDesc(int i) {
- if (i < 0 || i >= scaleDesc.length) {
- return scaleDesc[0];
+ public static String[] getDescriptions() {
+ return IEnumHasCodeAndDescription.getDescriptions(EvaluationType.class);
}
- return scaleDesc[i];
- }
- public static String getEvaluationTypeDesc(int i) {
- if (i < 0 || i >= EvaluationTypeDesc.length) {
- return EvaluationTypeDesc[0];
+ public static EvaluationType lookupDescription(String description) {
+ return
IEnumHasCodeAndDescription.lookupDescription(EvaluationType.class, description,
SIZE);
}
- return EvaluationTypeDesc[i];
}
- public static String getSourceFilesDesc(int i) {
- if (i < 0 || i >= SourceFilesDesc.length) {
- return SourceFilesDesc[0];
- }
- return SourceFilesDesc[i];
- }
+ @Getter
+ public enum SourceFilesType implements IEnumHasCodeAndDescription {
+ FILES("files", BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SourceFiles.Files.Label")),
+ FILENAMES_RESULT(
+ "filenamesresult",
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SourceFiles.FilenamesResult.Label")),
+ PREVIOUS_RESULT(
+ "previousresult",
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SourceFiles.PreviousResult.Label")),
+ ;
+ final String code;
+ final String description;
- public static String getScaleCode(int i) {
- if (i < 0 || i >= scaleCodes.length) {
- return scaleCodes[0];
+ SourceFilesType(String code, String description) {
+ this.code = code;
+ this.description = description;
}
- return scaleCodes[i];
- }
- public static String getSourceFilesCode(int i) {
- if (i < 0 || i >= SourceFilesCodes.length) {
- return SourceFilesCodes[0];
+ public static String[] getDescriptions() {
+ return IEnumHasCodeAndDescription.getDescriptions(SourceFilesType.class);
}
- return SourceFilesCodes[i];
- }
- public static String getEvaluationTypeCode(int i) {
- if (i < 0 || i >= EvaluationTypeCodes.length) {
- return EvaluationTypeCodes[0];
+ public static SourceFilesType lookupDescriptions(String description) {
+ return IEnumHasCodeAndDescription.lookupDescription(
+ SourceFilesType.class, description, FILES);
}
- return EvaluationTypeCodes[i];
}
- public int getScale() {
- return this.scale;
- }
+ @Getter
+ @Setter
+ public static final class SourceFile {
+ @HopMetadataProperty(key = "source_filefolder")
+ private String sourceFileFolder;
- @Override
- public void check(
- List<ICheckResult> remarks,
- WorkflowMeta workflowMeta,
- IVariables variables,
- IHopMetadataProvider metadataProvider) {
- boolean res =
- ActionValidatorUtils.andValidator()
- .validate(
- this,
- "arguments",
- remarks,
-
AndValidator.putValidators(ActionValidatorUtils.notNullValidator()));
+ @HopMetadataProperty(key = "wildcard")
+ private String sourceWildcard;
- if (!res) {
- return;
- }
+ @HopMetadataProperty(key = "include_subFolders")
+ private String sourceIncludeSubfolders;
- ValidatorContext ctx = new ValidatorContext();
- AbstractFileValidator.putVariableSpace(ctx, getVariables());
- AndValidator.putValidators(
- ctx, ActionValidatorUtils.notNullValidator(),
ActionValidatorUtils.fileExistsValidator());
+ public SourceFile() {}
- for (int i = 0; i < sourceFileFolder.length; i++) {
- ActionValidatorUtils.andValidator().validate(this, "arguments[" + i +
"]", remarks, ctx);
+ public SourceFile(SourceFile f) {
+ this();
+ this.sourceFileFolder = f.sourceFileFolder;
+ this.sourceWildcard = f.sourceWildcard;
+ this.sourceIncludeSubfolders = f.sourceIncludeSubfolders;
}
}
-
- @Override
- public boolean isEvaluation() {
- return true;
- }
}
diff --git
a/plugins/actions/evalfilesmetrics/src/main/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetricsDialog.java
b/plugins/actions/evalfilesmetrics/src/main/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetricsDialog.java
index c5c18663ff..67e6b16e5e 100644
---
a/plugins/actions/evalfilesmetrics/src/main/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetricsDialog.java
+++
b/plugins/actions/evalfilesmetrics/src/main/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetricsDialog.java
@@ -130,10 +130,209 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
CTabFolder wTabFolder = new CTabFolder(shell, SWT.BORDER);
PropsUi.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
+ addGeneralTab(wTabFolder, lsMod);
+ addAdvancedTab(wTabFolder, lsMod);
+
+ FormData fdTabFolder = new FormData();
+ fdTabFolder.left = new FormAttachment(0, 0);
+ fdTabFolder.top = new FormAttachment(wSpacer, margin);
+ fdTabFolder.right = new FormAttachment(100, 0);
+ fdTabFolder.bottom = new FormAttachment(wCancel, -margin);
+ wTabFolder.setLayoutData(fdTabFolder);
+
+ getData();
+ refresh();
+ refreshSize();
+ refreshSourceFiles();
+ wTabFolder.setSelection(0);
+ focusActionName();
+ BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
+
+ return action;
+ }
+
+ private void addAdvancedTab(CTabFolder wTabFolder, ModifyListener lsMod) {
+ CTabItem wAdvancedTab = new CTabItem(wTabFolder, SWT.NONE);
+ wAdvancedTab.setFont(GuiResource.getInstance().getFontDefault());
+ wAdvancedTab.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Tab.Advanced.Label"));
+
+ FormLayout contentLayout = new FormLayout();
+ contentLayout.marginWidth = 3;
+ contentLayout.marginHeight = 3;
+
+ Composite wAdvancedComp = new Composite(wTabFolder, SWT.NONE);
+ PropsUi.setLook(wAdvancedComp);
+ wAdvancedComp.setLayout(contentLayout);
+
// ////////////////////////
- // START OF GENERAL TAB ///
- // ////////////////////////
+ // START OF SUCCESS ON GROUP///
+ // /
+ Group wSuccessOn = new Group(wAdvancedComp, SWT.SHADOW_NONE);
+ PropsUi.setLook(wSuccessOn);
+ wSuccessOn.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessOn.Group.Label"));
+
+ FormLayout successongroupLayout = new FormLayout();
+ successongroupLayout.marginWidth = 10;
+ successongroupLayout.marginHeight = 10;
+
+ wSuccessOn.setLayout(successongroupLayout);
+
+ // Scale
+ wlScale = new Label(wSuccessOn, SWT.RIGHT);
+ wlScale.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.Scale.Label"));
+ PropsUi.setLook(wlScale);
+ FormData fdlScale = new FormData();
+ fdlScale.left = new FormAttachment(0, 0);
+ fdlScale.right = new FormAttachment(middle, -margin);
+ fdlScale.top = new FormAttachment(0, margin);
+ wlScale.setLayoutData(fdlScale);
+
+ wScale = new CCombo(wSuccessOn, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
+ wScale.setItems(ActionEvalFilesMetrics.Scale.getDescriptions());
+ wScale.select(0); // +1: starts at -1
+
+ PropsUi.setLook(wScale);
+ FormData fdScale = new FormData();
+ fdScale.left = new FormAttachment(middle, 0);
+ fdScale.top = new FormAttachment(0, margin);
+ fdScale.right = new FormAttachment(100, 0);
+ wScale.setLayoutData(fdScale);
+ wScale.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ action.setChanged();
+ }
+ });
+
+ // Success number Condition
+ Label wlSuccessNumberCondition = new Label(wSuccessOn, SWT.RIGHT);
+ wlSuccessNumberCondition.setText(
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.SuccessCondition.Label"));
+ PropsUi.setLook(wlSuccessNumberCondition);
+ FormData fdlSuccessNumberCondition = new FormData();
+ fdlSuccessNumberCondition.left = new FormAttachment(0, 0);
+ fdlSuccessNumberCondition.right = new FormAttachment(middle, -margin);
+ fdlSuccessNumberCondition.top = new FormAttachment(wScale, margin);
+ wlSuccessNumberCondition.setLayoutData(fdlSuccessNumberCondition);
+
+ wSuccessNumberCondition = new CCombo(wSuccessOn, SWT.SINGLE |
SWT.READ_ONLY | SWT.BORDER);
+
wSuccessNumberCondition.setItems(ActionEvalFilesMetrics.SuccesConditionType.getDescriptions());
+ wSuccessNumberCondition.select(0); // +1: starts at -1
+
+ PropsUi.setLook(wSuccessNumberCondition);
+ FormData fdSuccessNumberCondition = new FormData();
+ fdSuccessNumberCondition.left = new FormAttachment(middle, 0);
+ fdSuccessNumberCondition.top = new FormAttachment(wScale, margin);
+ fdSuccessNumberCondition.right = new FormAttachment(100, 0);
+ wSuccessNumberCondition.setLayoutData(fdSuccessNumberCondition);
+ wSuccessNumberCondition.addSelectionListener(
+ new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ refresh();
+ action.setChanged();
+ }
+ });
+
+ // Compare with value
+ wlCompareValue = new Label(wSuccessOn, SWT.RIGHT);
+ wlCompareValue.setText(
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.CompareValue.Label"));
+ PropsUi.setLook(wlCompareValue);
+ FormData fdlCompareValue = new FormData();
+ fdlCompareValue.left = new FormAttachment(0, 0);
+ fdlCompareValue.top = new FormAttachment(wSuccessNumberCondition, margin);
+ fdlCompareValue.right = new FormAttachment(middle, -margin);
+ wlCompareValue.setLayoutData(fdlCompareValue);
+
+ wCompareValue =
+ new TextVar(
+ variables,
+ wSuccessOn,
+ SWT.SINGLE | SWT.LEFT | SWT.BORDER,
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.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);
+ // Min value
+ wlMinValue = new Label(wSuccessOn, SWT.RIGHT);
+ wlMinValue.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.MinValue.Label"));
+ PropsUi.setLook(wlMinValue);
+ FormData fdlMinValue = new FormData();
+ fdlMinValue.left = new FormAttachment(0, 0);
+ fdlMinValue.top = new FormAttachment(wSuccessNumberCondition, margin);
+ fdlMinValue.right = new FormAttachment(middle, -margin);
+ wlMinValue.setLayoutData(fdlMinValue);
+
+ wMinValue =
+ new TextVar(
+ variables,
+ wSuccessOn,
+ SWT.SINGLE | SWT.LEFT | SWT.BORDER,
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.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);
+
+ // Maximum value
+ wlMaxValue = new Label(wSuccessOn, SWT.RIGHT);
+ wlMaxValue.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.MaxValue.Label"));
+ PropsUi.setLook(wlMaxValue);
+ FormData fdlMaxValue = new FormData();
+ fdlMaxValue.left = new FormAttachment(0, 0);
+ fdlMaxValue.top = new FormAttachment(wMinValue, margin);
+ fdlMaxValue.right = new FormAttachment(middle, -margin);
+ wlMaxValue.setLayoutData(fdlMaxValue);
+
+ wMaxValue =
+ new TextVar(
+ variables,
+ wSuccessOn,
+ SWT.SINGLE | SWT.LEFT | SWT.BORDER,
+ BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.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);
+
+ FormData fdSuccessOn = new FormData();
+ fdSuccessOn.left = new FormAttachment(0, margin);
+ fdSuccessOn.top = new FormAttachment(0, margin);
+ fdSuccessOn.right = new FormAttachment(100, -margin);
+ wSuccessOn.setLayoutData(fdSuccessOn);
+ // ///////////////////////////////////////////////////////////
+ // / END OF Success ON GROUP
+ // ///////////////////////////////////////////////////////////
+
+ FormData fdAdvancedComp = new FormData();
+ fdAdvancedComp.left = new FormAttachment(0, 0);
+ fdAdvancedComp.top = new FormAttachment(0, 0);
+ fdAdvancedComp.right = new FormAttachment(100, 0);
+ fdAdvancedComp.bottom = new FormAttachment(100, 0);
+ wAdvancedComp.setLayoutData(fdAdvancedComp);
+
+ wAdvancedComp.layout();
+ wAdvancedTab.setControl(wAdvancedComp);
+
+ // ///////////////////////////////////////////////////////////
+ // / END OF ADVANCED TAB
+ // ///////////////////////////////////////////////////////////
+ }
+
+ private void addGeneralTab(CTabFolder wTabFolder, ModifyListener lsMod) {
CTabItem wGeneralTab = new CTabItem(wTabFolder, SWT.NONE);
wGeneralTab.setFont(GuiResource.getInstance().getFontDefault());
wGeneralTab.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Tab.General.Label"));
@@ -146,7 +345,6 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
generalLayout.marginHeight = 3;
wGeneralComp.setLayout(generalLayout);
- // SETTINGS grouping?
// ////////////////////////
// START OF SETTINGS GROUP
//
@@ -172,7 +370,7 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
wlSourceFiles.setLayoutData(fdlSourceFiles);
wSourceFiles = new CCombo(wSettings, SWT.SINGLE | SWT.READ_ONLY |
SWT.BORDER);
- wSourceFiles.setItems(ActionEvalFilesMetrics.SourceFilesDesc);
+
wSourceFiles.setItems(ActionEvalFilesMetrics.SourceFilesType.getDescriptions());
wSourceFiles.select(0); // +1: starts at -1
PropsUi.setLook(wSourceFiles);
@@ -294,7 +492,7 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
wlEvaluationType.setLayoutData(fdlEvaluationType);
wEvaluationType = new CCombo(wSettings, SWT.SINGLE | SWT.READ_ONLY |
SWT.BORDER);
- wEvaluationType.setItems(ActionEvalFilesMetrics.EvaluationTypeDesc);
+
wEvaluationType.setItems(ActionEvalFilesMetrics.EvaluationType.getDescriptions());
wEvaluationType.select(0); // +1: starts at -1
PropsUi.setLook(wEvaluationType);
@@ -440,13 +638,7 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
fdbeSourceFileFolder.top = new FormAttachment(wbdSourceFileFolder, margin);
wbeSourceFileFolder.setLayoutData(fdbeSourceFileFolder);
- int rows =
- action.getSourceFileFolder() == null
- ? 1
- : (action.getSourceFileFolder().length == 0 ? 0 :
action.getSourceFileFolder().length);
- final int FieldsRows = rows;
-
- ColumnInfo[] colinf =
+ ColumnInfo[] columnInfos =
new ColumnInfo[] {
new ColumnInfo(
BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Fields.SourceFileFolder.Label"),
@@ -459,14 +651,14 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
new ColumnInfo(
BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Fields.IncludeSubDirs.Label"),
ColumnInfo.COLUMN_TYPE_CCOMBO,
- ActionEvalFilesMetrics.IncludeSubFoldersDesc)
+ ActionEvalFilesMetrics.NO_YES)
};
- colinf[0].setUsingVariables(true);
- colinf[0].setToolTip(
+ columnInfos[0].setUsingVariables(true);
+ columnInfos[0].setToolTip(
BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Fields.SourceFileFolder.Tooltip"));
- colinf[1].setUsingVariables(true);
- colinf[1].setToolTip(
+ columnInfos[1].setUsingVariables(true);
+ columnInfos[1].setToolTip(
BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Fields.Wildcard.Tooltip"));
wFields =
@@ -474,8 +666,8 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
variables,
wGeneralComp,
SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI,
- colinf,
- FieldsRows,
+ columnInfos,
+ 1,
lsMod,
props);
@@ -542,217 +734,12 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
wGeneralComp.layout();
wGeneralTab.setControl(wGeneralComp);
PropsUi.setLook(wGeneralComp);
-
- // ///////////////////////////////////////////////////////////
- // / END OF GENERAL TAB
- // ///////////////////////////////////////////////////////////
-
- // ////////////////////////////////////
- // START OF ADVANCED TAB ///
- // ///////////////////////////////////
-
- CTabItem wAdvancedTab = new CTabItem(wTabFolder, SWT.NONE);
- wAdvancedTab.setFont(GuiResource.getInstance().getFontDefault());
- wAdvancedTab.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.Tab.Advanced.Label"));
-
- FormLayout contentLayout = new FormLayout();
- contentLayout.marginWidth = 3;
- contentLayout.marginHeight = 3;
-
- Composite wAdvancedComp = new Composite(wTabFolder, SWT.NONE);
- PropsUi.setLook(wAdvancedComp);
- wAdvancedComp.setLayout(contentLayout);
-
- // SuccessOngrouping?
- // ////////////////////////
- // START OF SUCCESS ON GROUP///
- // /
- Group wSuccessOn = new Group(wAdvancedComp, SWT.SHADOW_NONE);
- PropsUi.setLook(wSuccessOn);
- wSuccessOn.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetrics.SuccessOn.Group.Label"));
-
- FormLayout successongroupLayout = new FormLayout();
- successongroupLayout.marginWidth = 10;
- successongroupLayout.marginHeight = 10;
-
- wSuccessOn.setLayout(successongroupLayout);
-
- // Scale
- wlScale = new Label(wSuccessOn, SWT.RIGHT);
- wlScale.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.Scale.Label"));
- PropsUi.setLook(wlScale);
- FormData fdlScale = new FormData();
- fdlScale.left = new FormAttachment(0, 0);
- fdlScale.right = new FormAttachment(middle, -margin);
- fdlScale.top = new FormAttachment(0, margin);
- wlScale.setLayoutData(fdlScale);
-
- wScale = new CCombo(wSuccessOn, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
- wScale.setItems(ActionEvalFilesMetrics.scaleDesc);
- wScale.select(0); // +1: starts at -1
-
- PropsUi.setLook(wScale);
- FormData fdScale = new FormData();
- fdScale.left = new FormAttachment(middle, 0);
- fdScale.top = new FormAttachment(0, margin);
- fdScale.right = new FormAttachment(100, 0);
- wScale.setLayoutData(fdScale);
- wScale.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- action.setChanged();
- }
- });
-
- // Success number Condition
- Label wlSuccessNumberCondition = new Label(wSuccessOn, SWT.RIGHT);
- wlSuccessNumberCondition.setText(
- BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.SuccessCondition.Label"));
- PropsUi.setLook(wlSuccessNumberCondition);
- FormData fdlSuccessNumberCondition = new FormData();
- fdlSuccessNumberCondition.left = new FormAttachment(0, 0);
- fdlSuccessNumberCondition.right = new FormAttachment(middle, -margin);
- fdlSuccessNumberCondition.top = new FormAttachment(wScale, margin);
- wlSuccessNumberCondition.setLayoutData(fdlSuccessNumberCondition);
-
- wSuccessNumberCondition = new CCombo(wSuccessOn, SWT.SINGLE |
SWT.READ_ONLY | SWT.BORDER);
-
wSuccessNumberCondition.setItems(ActionEvalFilesMetrics.successNumberConditionDesc);
- wSuccessNumberCondition.select(0); // +1: starts at -1
-
- PropsUi.setLook(wSuccessNumberCondition);
- FormData fdSuccessNumberCondition = new FormData();
- fdSuccessNumberCondition.left = new FormAttachment(middle, 0);
- fdSuccessNumberCondition.top = new FormAttachment(wScale, margin);
- fdSuccessNumberCondition.right = new FormAttachment(100, 0);
- wSuccessNumberCondition.setLayoutData(fdSuccessNumberCondition);
- wSuccessNumberCondition.addSelectionListener(
- new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- refresh();
- action.setChanged();
- }
- });
-
- // Compare with value
- wlCompareValue = new Label(wSuccessOn, SWT.RIGHT);
- wlCompareValue.setText(
- BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.CompareValue.Label"));
- PropsUi.setLook(wlCompareValue);
- FormData fdlCompareValue = new FormData();
- fdlCompareValue.left = new FormAttachment(0, 0);
- fdlCompareValue.top = new FormAttachment(wSuccessNumberCondition, margin);
- fdlCompareValue.right = new FormAttachment(middle, -margin);
- wlCompareValue.setLayoutData(fdlCompareValue);
-
- wCompareValue =
- new TextVar(
- variables,
- wSuccessOn,
- SWT.SINGLE | SWT.LEFT | SWT.BORDER,
- BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.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);
-
- // Min value
- wlMinValue = new Label(wSuccessOn, SWT.RIGHT);
- wlMinValue.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.MinValue.Label"));
- PropsUi.setLook(wlMinValue);
- FormData fdlMinValue = new FormData();
- fdlMinValue.left = new FormAttachment(0, 0);
- fdlMinValue.top = new FormAttachment(wSuccessNumberCondition, margin);
- fdlMinValue.right = new FormAttachment(middle, -margin);
- wlMinValue.setLayoutData(fdlMinValue);
-
- wMinValue =
- new TextVar(
- variables,
- wSuccessOn,
- SWT.SINGLE | SWT.LEFT | SWT.BORDER,
- BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.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);
-
- // Maximum value
- wlMaxValue = new Label(wSuccessOn, SWT.RIGHT);
- wlMaxValue.setText(BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.MaxValue.Label"));
- PropsUi.setLook(wlMaxValue);
- FormData fdlMaxValue = new FormData();
- fdlMaxValue.left = new FormAttachment(0, 0);
- fdlMaxValue.top = new FormAttachment(wMinValue, margin);
- fdlMaxValue.right = new FormAttachment(middle, -margin);
- wlMaxValue.setLayoutData(fdlMaxValue);
-
- wMaxValue =
- new TextVar(
- variables,
- wSuccessOn,
- SWT.SINGLE | SWT.LEFT | SWT.BORDER,
- BaseMessages.getString(PKG,
"ActionEvalFilesMetricsDialog.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);
-
- FormData fdSuccessOn = new FormData();
- fdSuccessOn.left = new FormAttachment(0, margin);
- fdSuccessOn.top = new FormAttachment(0, margin);
- fdSuccessOn.right = new FormAttachment(100, -margin);
- wSuccessOn.setLayoutData(fdSuccessOn);
- // ///////////////////////////////////////////////////////////
- // / END OF Success ON GROUP
- // ///////////////////////////////////////////////////////////
-
- FormData fdAdvancedComp = new FormData();
- fdAdvancedComp.left = new FormAttachment(0, 0);
- fdAdvancedComp.top = new FormAttachment(0, 0);
- fdAdvancedComp.right = new FormAttachment(100, 0);
- fdAdvancedComp.bottom = new FormAttachment(100, 0);
- wAdvancedComp.setLayoutData(wAdvancedComp);
-
- wAdvancedComp.layout();
- wAdvancedTab.setControl(wAdvancedComp);
-
- // ///////////////////////////////////////////////////////////
- // / END OF ADVANCED TAB
- // ///////////////////////////////////////////////////////////
-
- FormData fdTabFolder = new FormData();
- fdTabFolder.left = new FormAttachment(0, 0);
- fdTabFolder.top = new FormAttachment(wSpacer, margin);
- fdTabFolder.right = new FormAttachment(100, 0);
- fdTabFolder.bottom = new FormAttachment(wCancel, -margin);
- wTabFolder.setLayoutData(fdTabFolder);
-
- getData();
- refresh();
- refreshSize();
- refreshSourceFiles();
- wTabFolder.setSelection(0);
- focusActionName();
- BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel());
-
- return action;
}
private void refreshSourceFiles() {
boolean useStaticFiles =
- (ActionEvalFilesMetrics.getSourceFilesByDesc(wSourceFiles.getText())
- == ActionEvalFilesMetrics.SOURCE_FILES_FILES);
+
(ActionEvalFilesMetrics.SourceFilesType.lookupDescriptions(wSourceFiles.getText())
+ == ActionEvalFilesMetrics.SourceFilesType.FILES);
wlFields.setEnabled(useStaticFiles);
wFields.setEnabled(useStaticFiles);
wbdSourceFileFolder.setEnabled(useStaticFiles);
@@ -767,14 +754,14 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
wbSourceDirectory.setEnabled(useStaticFiles);
boolean setResultWildcard =
- (ActionEvalFilesMetrics.getSourceFilesByDesc(wSourceFiles.getText())
- == ActionEvalFilesMetrics.SOURCE_FILES_FILENAMES_RESULT);
+
(ActionEvalFilesMetrics.SourceFilesType.lookupDescriptions(wSourceFiles.getText())
+ == ActionEvalFilesMetrics.SourceFilesType.FILENAMES_RESULT);
wlResultFilenamesWildcard.setEnabled(setResultWildcard);
wResultFilenamesWildcard.setEnabled(setResultWildcard);
boolean setResultFields =
- (ActionEvalFilesMetrics.getSourceFilesByDesc(wSourceFiles.getText())
- == ActionEvalFilesMetrics.SOURCE_FILES_PREVIOUS_RESULT);
+
(ActionEvalFilesMetrics.SourceFilesType.lookupDescriptions(wSourceFiles.getText())
+ == ActionEvalFilesMetrics.SourceFilesType.PREVIOUS_RESULT);
wlResultFieldIncludeSubFolders.setEnabled(setResultFields);
wResultFieldIncludeSubFolders.setEnabled(setResultFields);
wlResultFieldFile.setEnabled(setResultFields);
@@ -785,8 +772,8 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
private void refreshSize() {
boolean useSize =
-
(ActionEvalFilesMetrics.getEvaluationTypeByDesc(wEvaluationType.getText())
- == ActionEvalFilesMetrics.EVALUATE_TYPE_SIZE);
+
(ActionEvalFilesMetrics.EvaluationType.lookupDescription(wEvaluationType.getText())
+ == ActionEvalFilesMetrics.EvaluationType.SIZE);
wlScale.setVisible(useSize);
wScale.setVisible(useSize);
}
@@ -795,53 +782,27 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
public void getData() {
wName.setText(Const.NVL(action.getName(), ""));
- if (action.getSourceFileFolder() != null) {
- for (int i = 0; i < action.getSourceFileFolder().length; i++) {
- TableItem ti = wFields.table.getItem(i);
- if (action.getSourceFileFolder()[i] != null) {
- ti.setText(1, action.getSourceFileFolder()[i]);
- }
-
- if (action.getSourceWildcard()[i] != null) {
- ti.setText(2, action.getSourceWildcard()[i]);
- }
-
- if (action.getSourceIncludeSubfolders()[i] != null) {
- ti.setText(
- 3,
- ActionEvalFilesMetrics.getIncludeSubFoldersDesc(
- action.getSourceIncludeSubfolders()[i]));
- }
- }
- wFields.setRowNums();
- wFields.optWidth(true);
- }
- if (action.getResultFilenamesWildcard() != null) {
- wResultFilenamesWildcard.setText(action.getResultFilenamesWildcard());
- }
- if (action.getResultFieldFile() != null) {
- wResultFieldFile.setText(action.getResultFieldFile());
- }
- if (action.getResultFieldWildcard() != null) {
- wResultFieldWildcard.setText(action.getResultFieldWildcard());
- }
- if (action.getResultFieldIncludeSubfolders() != null) {
-
wResultFieldIncludeSubFolders.setText(action.getResultFieldIncludeSubfolders());
- }
-
wSourceFiles.setText(ActionEvalFilesMetrics.getSourceFilesDesc(action.sourceFiles));
-
wEvaluationType.setText(ActionEvalFilesMetrics.getEvaluationTypeDesc(action.evaluationType));
- wScale.setText(ActionEvalFilesMetrics.getScaleDesc(action.scale));
- wSuccessNumberCondition.setText(
-
ActionEvalFilesMetrics.getSuccessNumberConditionDesc(action.getSuccessConditionType()));
- if (action.getCompareValue() != null) {
- wCompareValue.setText(action.getCompareValue());
- }
- if (action.getMinValue() != null) {
- wMinValue.setText(action.getMinValue());
- }
- if (action.getMaxValue() != null) {
- wMaxValue.setText(action.getMaxValue());
+ for (ActionEvalFilesMetrics.SourceFile sourceFile :
action.getSourceFiles()) {
+ TableItem ti = new TableItem(wFields.table, SWT.NONE);
+
+ ti.setText(1, Const.NVL(sourceFile.getSourceFileFolder(), ""));
+ ti.setText(2, Const.NVL(sourceFile.getSourceWildcard(), ""));
+ ti.setText(3, Const.NVL(sourceFile.getSourceIncludeSubfolders(), ""));
}
+ wFields.optimizeTableView();
+
+
wResultFilenamesWildcard.setText(Const.NVL(action.getResultFilenamesWildcard(),
""));
+ wResultFieldFile.setText(Const.NVL(action.getResultFieldFile(), ""));
+ wResultFieldWildcard.setText(Const.NVL(action.getResultFieldWildcard(),
""));
+
wResultFieldIncludeSubFolders.setText(Const.NVL(action.getResultFieldIncludeSubFolders(),
""));
+
+ wSourceFiles.setText(action.getSourceFilesType().getDescription());
+ wEvaluationType.setText(action.getEvaluationType().getDescription());
+ wScale.setText(action.getScale().getDescription());
+
wSuccessNumberCondition.setText(action.getSuccessConditionType().getDescription());
+ wCompareValue.setText(Const.NVL(action.getCompareValue(), ""));
+ wMinValue.setText(Const.NVL(action.getMinValue(), ""));
+ wMaxValue.setText(Const.NVL(action.getMaxValue(), ""));
}
@Override
@@ -867,50 +828,36 @@ public class ActionEvalFilesMetricsDialog extends
ActionDialog {
action.setResultFilenamesWildcard(wResultFilenamesWildcard.getText());
action.setResultFieldFile(wResultFieldFile.getText());
action.setResultFieldWildcard(wResultFieldWildcard.getText());
-
action.setResultFieldIncludeSubfolders(wResultFieldIncludeSubFolders.getText());
- action.sourceFiles =
ActionEvalFilesMetrics.getSourceFilesByDesc(wSourceFiles.getText());
- action.evaluationType =
-
ActionEvalFilesMetrics.getEvaluationTypeByDesc(wEvaluationType.getText());
- action.scale = ActionEvalFilesMetrics.getScaleByDesc(wScale.getText());
+
action.setResultFieldIncludeSubFolders(wResultFieldIncludeSubFolders.getText());
+ action.setSourceFilesType(
+
ActionEvalFilesMetrics.SourceFilesType.lookupDescriptions(wSourceFiles.getText()));
+ action.setEvaluationType(
+
ActionEvalFilesMetrics.EvaluationType.lookupDescription(wEvaluationType.getText()));
+
action.setScale(ActionEvalFilesMetrics.Scale.lookupDescription(wScale.getText()));
action.setSuccessConditionType(
-
ActionEvalFilesMetrics.getSuccessNumberConditionByDesc(wSuccessNumberCondition.getText()));
+ ActionEvalFilesMetrics.SuccesConditionType.lookupDescription(
+ wSuccessNumberCondition.getText()));
action.setCompareValue(wCompareValue.getText());
action.setMinValue(wMinValue.getText());
action.setMaxValue(wMaxValue.getText());
- int nrItems = wFields.nrNonEmpty();
- int nr = 0;
- for (int i = 0; i < nrItems; i++) {
- String arg = wFields.getNonEmpty(i).getText(1);
- if (!Utils.isEmpty(arg)) {
- nr++;
- }
- }
- String[] sourceFileFolder = new String[nr];
- String[] sourceWildcard = new String[nr];
- String[] sourceIncludeSubfolders = new String[nr];
- nr = 0;
- for (int i = 0; i < nrItems; i++) {
- String source = wFields.getNonEmpty(i).getText(1);
- String wild = wFields.getNonEmpty(i).getText(2);
- String includeSubFolders = wFields.getNonEmpty(i).getText(3);
- if (!Utils.isEmpty(source)) {
- sourceFileFolder[nr] = source;
- sourceWildcard[nr] = wild;
- sourceIncludeSubfolders[nr] =
- ActionEvalFilesMetrics.getIncludeSubFolders(includeSubFolders);
- nr++;
- }
+
+ action.getSourceFiles().clear();
+ for (TableItem item : wFields.getNonEmptyItems()) {
+ ActionEvalFilesMetrics.SourceFile sourceFile = new
ActionEvalFilesMetrics.SourceFile();
+ action.getSourceFiles().add(sourceFile);
+
+ sourceFile.setSourceFileFolder(item.getText(1));
+ sourceFile.setSourceWildcard(item.getText(2));
+ sourceFile.setSourceIncludeSubfolders(item.getText(3));
}
- action.setSourceFileFolder(sourceFileFolder);
- action.setSourceWildcard(sourceWildcard);
- action.setSourceIncludeSubfolders(sourceIncludeSubfolders);
dispose();
}
private void refresh() {
boolean compareValue =
-
(ActionEvalFilesMetrics.getSuccessNumberConditionByDesc(wSuccessNumberCondition.getText())
- != ActionEvalFilesMetrics.SUCCESS_NUMBER_CONDITION_BETWEEN);
+ (ActionEvalFilesMetrics.SuccesConditionType.lookupDescription(
+ wSuccessNumberCondition.getText())
+ != ActionEvalFilesMetrics.SuccesConditionType.BETWEEN);
wlCompareValue.setVisible(compareValue);
wCompareValue.setVisible(compareValue);
wlMinValue.setVisible(!compareValue);
diff --git
a/plugins/actions/evalfilesmetrics/src/test/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetricsTest.java
b/plugins/actions/evalfilesmetrics/src/test/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetricsTest.java
new file mode 100644
index 0000000000..113242524c
--- /dev/null
+++
b/plugins/actions/evalfilesmetrics/src/test/java/org/apache/hop/workflow/actions/evalfilesmetrics/ActionEvalFilesMetricsTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.evalfilesmetrics;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.apache.hop.core.HopClientEnvironment;
+import org.apache.hop.workflow.action.ActionSerializationTestUtil;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class ActionEvalFilesMetricsTest {
+ @BeforeEach
+ void setUp() throws Exception {
+ HopClientEnvironment.init();
+ }
+
+ @Test
+ void testSerializationRoundTrip() throws Exception {
+ ActionEvalFilesMetrics action =
+ ActionSerializationTestUtil.testSerialization(
+ "/action-evaluate-file-metrics.xml", ActionEvalFilesMetrics.class);
+
+ assertEquals("wildcard", action.getResultFilenamesWildcard());
+ assertEquals("file-result-field", action.getResultFieldFile());
+ assertEquals("wildcard-result-field", action.getResultFieldWildcard());
+ assertEquals("include-result-field",
action.getResultFieldIncludeSubFolders());
+ assertEquals("12345", action.getCompareValue());
+ assertEquals("1000", action.getMinValue());
+ assertEquals("9999", action.getMaxValue());
+ assertEquals(
+ ActionEvalFilesMetrics.SuccesConditionType.GREATER_EQUAL,
action.getSuccessConditionType());
+ assertEquals(
+ ActionEvalFilesMetrics.SourceFilesType.PREVIOUS_RESULT,
action.getSourceFilesType());
+ assertEquals(ActionEvalFilesMetrics.EvaluationType.SIZE,
action.getEvaluationType());
+ assertEquals(ActionEvalFilesMetrics.Scale.BYTES, action.getScale());
+
+ assertEquals(3, action.getSourceFiles().size());
+ ActionEvalFilesMetrics.SourceFile f = action.getSourceFiles().getFirst();
+ assertEquals("folder1", f.getSourceFileFolder());
+ assertEquals("wildcard1", f.getSourceWildcard());
+ assertEquals("Y", f.getSourceIncludeSubfolders());
+
+ f = action.getSourceFiles().get(1);
+ assertEquals("folder2", f.getSourceFileFolder());
+ assertEquals("wildcard2", f.getSourceWildcard());
+ assertEquals("N", f.getSourceIncludeSubfolders());
+
+ f = action.getSourceFiles().getLast();
+ assertEquals("folder3", f.getSourceFileFolder());
+ assertEquals("wildcard3", f.getSourceWildcard());
+ assertEquals("Y", f.getSourceIncludeSubfolders());
+ }
+}
diff --git
a/plugins/actions/evalfilesmetrics/src/test/java/org/apache/hop/workflow/actions/evalfilesmetrics/WorkflowActionEvalFilesMetricsLoadSaveTest.java
b/plugins/actions/evalfilesmetrics/src/test/java/org/apache/hop/workflow/actions/evalfilesmetrics/WorkflowActionEvalFilesMetricsLoadSaveTest.java
deleted file mode 100644
index e9b5f2b21a..0000000000
---
a/plugins/actions/evalfilesmetrics/src/test/java/org/apache/hop/workflow/actions/evalfilesmetrics/WorkflowActionEvalFilesMetricsLoadSaveTest.java
+++ /dev/null
@@ -1,89 +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.evalfilesmetrics;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import org.apache.hop.junit.rules.RestoreHopEngineEnvironmentExtension;
-import
org.apache.hop.pipeline.transforms.loadsave.validator.ArrayLoadSaveValidator;
-import
org.apache.hop.pipeline.transforms.loadsave.validator.IFieldLoadSaveValidator;
-import
org.apache.hop.pipeline.transforms.loadsave.validator.IntLoadSaveValidator;
-import
org.apache.hop.pipeline.transforms.loadsave.validator.StringLoadSaveValidator;
-import
org.apache.hop.workflow.action.loadsave.WorkflowActionLoadSaveTestSupport;
-import org.junit.jupiter.api.extension.RegisterExtension;
-
-class WorkflowActionEvalFilesMetricsLoadSaveTest
- extends WorkflowActionLoadSaveTestSupport<ActionEvalFilesMetrics> {
- @RegisterExtension
- static RestoreHopEngineEnvironmentExtension env = new
RestoreHopEngineEnvironmentExtension();
-
- @Override
- protected Class<ActionEvalFilesMetrics> getActionClass() {
- return ActionEvalFilesMetrics.class;
- }
-
- @Override
- protected List<String> listAttributes() {
- return Arrays.asList(
- new String[] {
- "resultFilenamesWildcard",
- "resultFieldFile",
- "resultFieldWildcard",
- "resultFieldIncludeSubfolders",
- "sourceFileFolder",
- "sourceWildcard",
- "sourceIncludeSubfolders",
- "compareValue",
- "minValue",
- "maxValue",
- "successConditionType",
- "sourceFiles",
- "evaluationType",
- "scale"
- });
- }
-
- @Override
- protected Map<String, IFieldLoadSaveValidator<?>>
createAttributeValidatorsMap() {
- Map<String, IFieldLoadSaveValidator<?>> validators = new HashMap<>();
- int sourceFileCount = new Random().nextInt(50) + 1;
- validators.put(
- "sourceFileFolder",
- new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(),
sourceFileCount));
- validators.put(
- "sourceWildcard",
- new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(),
sourceFileCount));
- validators.put(
- "sourceIncludeSubfolders",
- new ArrayLoadSaveValidator<>(new StringLoadSaveValidator(),
sourceFileCount));
- validators.put(
- "successConditionType",
- new
IntLoadSaveValidator(ActionEvalFilesMetrics.successNumberConditionCode.length));
- validators.put(
- "sourceFiles", new
IntLoadSaveValidator(ActionEvalFilesMetrics.SourceFilesCodes.length));
- validators.put(
- "evaluationType",
- new
IntLoadSaveValidator(ActionEvalFilesMetrics.EvaluationTypeCodes.length));
- validators.put("scale", new
IntLoadSaveValidator(ActionEvalFilesMetrics.scaleCodes.length));
-
- return validators;
- }
-}
diff --git
a/plugins/actions/evalfilesmetrics/src/test/resources/action-evaluate-file-metrics.xml
b/plugins/actions/evalfilesmetrics/src/test/resources/action-evaluate-file-metrics.xml
new file mode 100644
index 0000000000..b3bdccc034
--- /dev/null
+++
b/plugins/actions/evalfilesmetrics/src/test/resources/action-evaluate-file-metrics.xml
@@ -0,0 +1,48 @@
+<?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>
+ <result_filenames_wildcard>wildcard</result_filenames_wildcard>
+ <Result_field_file>file-result-field</Result_field_file>
+ <Result_field_wildcard>wildcard-result-field</Result_field_wildcard>
+
<Result_field_includesubfolders>include-result-field</Result_field_includesubfolders>
+ <fields>
+ <field>
+ <source_filefolder>folder1</source_filefolder>
+ <wildcard>wildcard1</wildcard>
+ <include_subFolders>Y</include_subFolders>
+ </field>
+ <field>
+ <source_filefolder>folder2</source_filefolder>
+ <wildcard>wildcard2</wildcard>
+ <include_subFolders>N</include_subFolders>
+ </field>
+ <field>
+ <source_filefolder>folder3</source_filefolder>
+ <wildcard>wildcard3</wildcard>
+ <include_subFolders>Y</include_subFolders>
+ </field>
+ </fields>
+ <comparevalue>12345</comparevalue>
+ <minvalue>1000</minvalue>
+ <maxvalue>9999</maxvalue>
+ <successnumbercondition>greaterequal</successnumbercondition>
+ <source_files>previousresult</source_files>
+ <evaluation_type>size</evaluation_type>
+ <scale>bytes</scale>
+</action>
+