This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new 739019b7c2 Cleanup XML of action Write To File #2003
     new d6b8c1812f Merge pull request #2906 from nadment/2003
739019b7c2 is described below

commit 739019b7c2aff6af5a7c24c060597a14a1d57ac6
Author: Nicolas Adment <[email protected]>
AuthorDate: Sun May 7 00:33:32 2023 +0200

    Cleanup XML of action Write To File #2003
---
 .../actions/writetofile/ActionWriteToFile.java     | 45 ++++------------------
 1 file changed, 7 insertions(+), 38 deletions(-)

diff --git 
a/plugins/actions/writetofile/src/main/java/org/apache/hop/workflow/actions/writetofile/ActionWriteToFile.java
 
b/plugins/actions/writetofile/src/main/java/org/apache/hop/workflow/actions/writetofile/ActionWriteToFile.java
index 2ebb3cdec1..1857420c99 100644
--- 
a/plugins/actions/writetofile/src/main/java/org/apache/hop/workflow/actions/writetofile/ActionWriteToFile.java
+++ 
b/plugins/actions/writetofile/src/main/java/org/apache/hop/workflow/actions/writetofile/ActionWriteToFile.java
@@ -22,12 +22,11 @@ import org.apache.hop.core.ICheckResult;
 import org.apache.hop.core.Result;
 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.IHopMetadataProvider;
 import org.apache.hop.resource.ResourceEntry;
 import org.apache.hop.resource.ResourceEntry.ResourceType;
@@ -37,8 +36,6 @@ import org.apache.hop.workflow.action.ActionBase;
 import org.apache.hop.workflow.action.IAction;
 import org.apache.hop.workflow.action.validator.ActionValidatorUtils;
 import org.apache.hop.workflow.action.validator.AndValidator;
-import org.w3c.dom.Node;
-
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.util.List;
@@ -58,10 +55,15 @@ import java.util.List;
 public class ActionWriteToFile extends ActionBase implements Cloneable, 
IAction {
   private static final Class<?> PKG = ActionWriteToFile.class; // For 
Translator
 
+  @HopMetadataProperty(key = "filename")
   private String filename;
+  @HopMetadataProperty(key = "createParentFolder")
   private boolean createParentFolder;
+  @HopMetadataProperty(key = "appendFile")
   private boolean appendFile;
+  @HopMetadataProperty(key = "content")
   private String content;
+  @HopMetadataProperty(key = "encoding")
   private String encoding;
 
   public ActionWriteToFile(String n) {
@@ -83,38 +85,6 @@ public class ActionWriteToFile extends ActionBase implements 
Cloneable, IAction
     return je;
   }
 
-  @Override
-  public String getXml() {
-    StringBuilder retval = new StringBuilder(100);
-
-    retval.append(super.getXml());
-    retval.append("      ").append(XmlHandler.addTagValue("filename", 
filename));
-    retval
-        .append("      ")
-        .append(XmlHandler.addTagValue("createParentFolder", 
createParentFolder));
-    retval.append("      ").append(XmlHandler.addTagValue("appendFile", 
appendFile));
-    retval.append("      ").append(XmlHandler.addTagValue("content", content));
-    retval.append("      ").append(XmlHandler.addTagValue("encoding", 
encoding));
-
-    return retval.toString();
-  }
-
-  @Override
-  public void loadXml(Node entrynode, IHopMetadataProvider metadataProvider, 
IVariables variables)
-      throws HopXmlException {
-    try {
-      super.loadXml(entrynode);
-      filename = XmlHandler.getTagValue(entrynode, "filename");
-      createParentFolder =
-          "Y".equalsIgnoreCase(XmlHandler.getTagValue(entrynode, 
"createParentFolder"));
-      appendFile = "Y".equalsIgnoreCase(XmlHandler.getTagValue(entrynode, 
"appendFile"));
-      content = XmlHandler.getTagValue(entrynode, "content");
-      encoding = XmlHandler.getTagValue(entrynode, "encoding");
-    } catch (HopXmlException xe) {
-      throw new HopXmlException("Unable to load action of type 'create file' 
from XML node", xe);
-    }
-  }
-
   public void setFilename(String filename) {
     this.filename = filename;
   }
@@ -284,9 +254,8 @@ public class ActionWriteToFile extends ActionBase 
implements Cloneable, IAction
       IVariables variables, WorkflowMeta workflowMeta) {
     List<ResourceReference> references = 
super.getResourceDependencies(variables, workflowMeta);
     if (!Utils.isEmpty(getFilename())) {
-      String realFileName = resolve(getFilename());
       ResourceReference reference = new ResourceReference(this);
-      reference.getEntries().add(new ResourceEntry(realFileName, 
ResourceType.FILE));
+      reference.getEntries().add(new ResourceEntry(getRealFilename(), 
ResourceType.FILE));
       references.add(reference);
     }
     return references;

Reply via email to