You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2021/01/22 18:02:02 UTC

[incubator-hop] branch master updated: HOP-2446 Workflow and Action code cleanup

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/incubator-hop.git


The following commit(s) were added to refs/heads/master by this push:
     new 8a39b67  HOP-2446 Workflow and Action code cleanup
     new ef1496d  Merge pull request #578 from nadment/HOP-2446
8a39b67 is described below

commit 8a39b6799016a14ededfde859f13b93d6a3f7c44
Author: nadment <na...@gmail.com>
AuthorDate: Fri Jan 22 17:28:25 2021 +0100

    HOP-2446 Workflow and Action code cleanup
    
    Very small cleaning
---
 .../apache/hop/core/plugins/ActionPluginType.java  |  3 ++-
 .../transforms/missing/MissingTransform.java       |  2 --
 .../org/apache/hop/workflow/action/ActionBase.java | 26 ++++++++++------------
 .../hop/workflow/actions/start/ActionStart.java    | 20 ++++++++---------
 .../workflow/actions/workflow/ActionWorkflow.java  |  8 +++----
 5 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/engine/src/main/java/org/apache/hop/core/plugins/ActionPluginType.java b/engine/src/main/java/org/apache/hop/core/plugins/ActionPluginType.java
index 535e96d..39b2393 100644
--- a/engine/src/main/java/org/apache/hop/core/plugins/ActionPluginType.java
+++ b/engine/src/main/java/org/apache/hop/core/plugins/ActionPluginType.java
@@ -35,12 +35,13 @@ import java.util.Map;
 public class ActionPluginType extends BasePluginType<Action> implements IPluginType<Action> {
   private static final Class<?> PKG = WorkflowMeta.class; // For Translator
 
+  public static final String ID = "ACTION";
   public static final String GENERAL_CATEGORY = BaseMessages.getString( PKG, "ActionCategory.Category.General" );
 
   private static ActionPluginType pluginType;
 
   private ActionPluginType() {
-    super( Action.class, "ACTION", "Action" );
+    super( Action.class, ID, "Action" );
     populateFolders( "actions" );
   }
 
diff --git a/engine/src/main/java/org/apache/hop/pipeline/transforms/missing/MissingTransform.java b/engine/src/main/java/org/apache/hop/pipeline/transforms/missing/MissingTransform.java
index b514bf5..3196116 100644
--- a/engine/src/main/java/org/apache/hop/pipeline/transforms/missing/MissingTransform.java
+++ b/engine/src/main/java/org/apache/hop/pipeline/transforms/missing/MissingTransform.java
@@ -20,9 +20,7 @@ package org.apache.hop.pipeline.transforms.missing;
 import org.apache.hop.i18n.BaseMessages;
 import org.apache.hop.pipeline.Pipeline;
 import org.apache.hop.pipeline.PipelineMeta;
-import org.apache.hop.pipeline.transform.ITransformData;
 import org.apache.hop.pipeline.transform.TransformMeta;
-import org.apache.hop.pipeline.transform.ITransformMeta;
 import org.apache.hop.pipeline.transforms.dummy.Dummy;
 import org.apache.hop.pipeline.transforms.dummy.DummyData;
 import org.apache.hop.pipeline.transforms.dummy.DummyMeta;
diff --git a/engine/src/main/java/org/apache/hop/workflow/action/ActionBase.java b/engine/src/main/java/org/apache/hop/workflow/action/ActionBase.java
index 3a81511..333b6d1 100644
--- a/engine/src/main/java/org/apache/hop/workflow/action/ActionBase.java
+++ b/engine/src/main/java/org/apache/hop/workflow/action/ActionBase.java
@@ -132,7 +132,7 @@ public abstract class ActionBase implements IAction, Cloneable, ILoggingObject,
   /**
    * Instantiates a new action base object.
    */
-  public ActionBase() {
+  protected ActionBase() {
     name = null;
     description = null;
     log = new LogChannel( this );
@@ -146,7 +146,7 @@ public abstract class ActionBase implements IAction, Cloneable, ILoggingObject,
    * @param name        the name of the action
    * @param description the description of the action
    */
-  public ActionBase( String name, String description ) {
+  protected ActionBase( String name, String description ) {
     setName( name );
     setDescription( description );
     log = new LogChannel( this );
@@ -220,8 +220,8 @@ public abstract class ActionBase implements IAction, Cloneable, ILoggingObject,
    *
    * @param Description the new description
    */
-  public void setDescription( String Description ) {
-    this.description = Description;
+  public void setDescription( String description ) {
+    this.description = description;
   }
 
   /**
@@ -235,7 +235,7 @@ public abstract class ActionBase implements IAction, Cloneable, ILoggingObject,
   }
 
   @Override public String getTypeId() {
-    return "ACTION";
+    return ActionPluginType.ID;
   }
 
   /**
@@ -292,10 +292,8 @@ public abstract class ActionBase implements IAction, Cloneable, ILoggingObject,
     return "PIPELINE".equals( pluginId );
   }
 
-  // Add here for the new types?
-
   /**
-   * This method is called by PDI whenever a action needs to serialize its settings to XML. It is called when saving
+   * This method is called by Hop whenever a action needs to serialize its settings to XML. It is called when saving
    * a workflow in HopGui. The method returns an XML string, containing the serialized settings. The string contains a series
    * of XML tags, typically one tag per setting. The helper class org.apache.hop.core.xml.XmlHandler is typically used
    * to construct the XML string.
@@ -314,21 +312,21 @@ public abstract class ActionBase implements IAction, Cloneable, ILoggingObject,
   }
 
   /**
-   * This method is called by PDI whenever a action needs to read its settings from XML. The XML node containing the
+   * This method is called by Hop whenever a action needs to read its settings from XML. The XML node containing the
    * action's settings is passed in as an argument. Again, the helper class org.apache.hop.core.xml.XmlHandler is
    * typically used to conveniently read the settings from the XML node.
    *
-   * @param entrynode the top-level XML node
+   * @param node the top-level XML node
    * @throws HopXmlException if any errors occur during the loading of the XML
    */
-  public void loadXml( Node entrynode ) throws HopXmlException {
+  public void loadXml( Node node ) throws HopXmlException {
     try {
-      setName( XmlHandler.getTagValue( entrynode, "name" ) );
-      setDescription( XmlHandler.getTagValue( entrynode, "description" ) );
+      setName( XmlHandler.getTagValue( node, "name" ) );
+      setDescription( XmlHandler.getTagValue( node, "description" ) );
 
       // Load the attribute groups map
       //
-      attributesMap = AttributesUtil.loadAttributes( XmlHandler.getSubNode( entrynode, AttributesUtil.XML_TAG ) );
+      attributesMap = AttributesUtil.loadAttributes( XmlHandler.getSubNode( node, AttributesUtil.XML_TAG ) );
 
     } catch ( Exception e ) {
       throw new HopXmlException( "Unable to load base info for action", e );
diff --git a/engine/src/main/java/org/apache/hop/workflow/actions/start/ActionStart.java b/engine/src/main/java/org/apache/hop/workflow/actions/start/ActionStart.java
index c8c43b2..29288a3 100644
--- a/engine/src/main/java/org/apache/hop/workflow/actions/start/ActionStart.java
+++ b/engine/src/main/java/org/apache/hop/workflow/actions/start/ActionStart.java
@@ -92,19 +92,19 @@ public class ActionStart extends ActionBase implements Cloneable, IAction {
     return retval.toString();
   }
 
-  public void loadXml(Node entrynode, IHopMetadataProvider metadataProvider, IVariables variables)
+  public void loadXml(Node actionNode, IHopMetadataProvider metadataProvider, IVariables variables)
       throws HopXmlException {
     try {
-      super.loadXml(entrynode);
-      repeat = "Y".equalsIgnoreCase(XmlHandler.getTagValue(entrynode, "repeat"));
+      super.loadXml(actionNode);
+      repeat = "Y".equalsIgnoreCase(XmlHandler.getTagValue(actionNode, "repeat"));
       setSchedulerType(
-          Const.toInt(XmlHandler.getTagValue(entrynode, "schedulerType"), NOSCHEDULING));
-      setIntervalSeconds(Const.toInt(XmlHandler.getTagValue(entrynode, "intervalSeconds"), 0));
-      setIntervalMinutes(Const.toInt(XmlHandler.getTagValue(entrynode, "intervalMinutes"), 0));
-      setHour(Const.toInt(XmlHandler.getTagValue(entrynode, "hour"), 0));
-      setMinutes(Const.toInt(XmlHandler.getTagValue(entrynode, "minutes"), 0));
-      setWeekDay(Const.toInt(XmlHandler.getTagValue(entrynode, "weekDay"), 0));
-      setDayOfMonth(Const.toInt(XmlHandler.getTagValue(entrynode, "dayOfMonth"), 0));
+          Const.toInt(XmlHandler.getTagValue(actionNode, "schedulerType"), NOSCHEDULING));
+      setIntervalSeconds(Const.toInt(XmlHandler.getTagValue(actionNode, "intervalSeconds"), 0));
+      setIntervalMinutes(Const.toInt(XmlHandler.getTagValue(actionNode, "intervalMinutes"), 0));
+      setHour(Const.toInt(XmlHandler.getTagValue(actionNode, "hour"), 0));
+      setMinutes(Const.toInt(XmlHandler.getTagValue(actionNode, "minutes"), 0));
+      setWeekDay(Const.toInt(XmlHandler.getTagValue(actionNode, "weekDay"), 0));
+      setDayOfMonth(Const.toInt(XmlHandler.getTagValue(actionNode, "dayOfMonth"), 0));
     } catch (HopException e) {
       throw new HopXmlException("Unable to load action of type 'special' from XML node", e);
     }
diff --git a/engine/src/main/java/org/apache/hop/workflow/actions/workflow/ActionWorkflow.java b/engine/src/main/java/org/apache/hop/workflow/actions/workflow/ActionWorkflow.java
index 8c34715..285d85e 100644
--- a/engine/src/main/java/org/apache/hop/workflow/actions/workflow/ActionWorkflow.java
+++ b/engine/src/main/java/org/apache/hop/workflow/actions/workflow/ActionWorkflow.java
@@ -581,18 +581,18 @@ public class ActionWorkflow extends ActionBase implements Cloneable, IAction {
         workflow.getWorkflowTracker().setParentWorkflowTracker(parentWorkflow.getWorkflowTracker());
 
         ActionWorkflowRunner runner = new ActionWorkflowRunner(workflow, result, nr, log);
-        Thread jobRunnerThread = new Thread(runner);
+        Thread workflowRunnerThread = new Thread(runner);
         // PDI-6518
-        // added UUID to thread name, otherwise threads do share names if workflows entries are
+        // added UUID to thread name, otherwise threads do share names if workflows actions are
         // executed in parallel in a
         // parent workflow
         // if that happens, contained pipelines start closing each other's connections
-        jobRunnerThread.setName(
+        workflowRunnerThread.setName(
             Const.NVL(
                     workflow.getWorkflowMeta().getName(), workflow.getWorkflowMeta().getFilename())
                 + " UUID: "
                 + UUID.randomUUID().toString());
-        jobRunnerThread.start();
+        workflowRunnerThread.start();
 
         // Keep running until we're done.
         //