Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: MetaInject step not correctly imported from Kettle #4384

Closed
nadment opened this issue Oct 2, 2024 · 0 comments · Fixed by #4385
Closed

[Bug]: MetaInject step not correctly imported from Kettle #4384

nadment opened this issue Oct 2, 2024 · 0 comments · Fixed by #4385
Assignees
Labels
Milestone

Comments

@nadment
Copy link
Contributor

nadment commented Oct 2, 2024

Apache Hop version?

2.10.0-SNAPSHOT

Java version?

Java 17

Operating system

Windows

What happened?

MetaInject step file name not correctly imported from Kettle. You need to combine 'directory_path' and 'trans_name' to build the filename.

We also need to set the default Run configuration.

  <step>
    <name>ETL Metadata Injection</name>
    <type>MetaInject</type>
    <trans_name>PIPELINE_NAME</trans_name>
    <filename />
    <directory_path>/PATH_TO_IMPORT</directory_path>

Code to rebuild file name, same logic than MAPPING

      if (entryType == EntryType.METAINJECT && currentNode.getNodeName().equals("transform")) {
        Node filenameNode = null;
        String transName = "";
        String directoryPath = "";
        // get trans name, file name, path, set correct filename when needed.
        for (int j = 0; j < currentNode.getChildNodes().getLength(); j++) {
          if (currentNode.getChildNodes().item(j).getNodeName().equals("directory_path")) {
            directoryPath = currentNode.getChildNodes().item(j).getTextContent();
            currentNode.removeChild(currentNode.getChildNodes().item(j));
          }
          if (currentNode.getChildNodes().item(j).getNodeName().equals("trans_name")) {
            transName = currentNode.getChildNodes().item(j).getTextContent();
            currentNode.removeChild(currentNode.getChildNodes().item(j));
          }
          if (currentNode.getChildNodes().item(j).getNodeName().equals("filename")) {
            filenameNode = currentNode.getChildNodes().item(j);
          }
        }

        // if we have a trans name and directory path, use it to update the pipeline
        // filename.
        if (!StringUtils.isEmpty(transName) && !StringUtils.isEmpty(directoryPath)) {
          filenameNode.setTextContent("${PROJECT_HOME}" + directoryPath + '/' + transName + ".hpl");
        }

        // add the default pipeline run configuration.
        Element runConfigElement = doc.createElement("runConfiguration");
        runConfigElement.appendChild(doc.createTextNode(defaultPipelineRunConfiguration));
        currentNode.appendChild(runConfigElement);
      }

Issue Priority

Priority: 3

Issue Component

Component: Import

@nadment nadment added this to the 2.11 milestone Oct 2, 2024
@nadment nadment self-assigned this Oct 2, 2024
@nadment nadment changed the title [Bug]: MetaInject step correctly imported from Kettle [Bug]: MetaInject step not correctly imported from Kettle Oct 2, 2024
@github-actions github-actions bot added the P3 Nice to have label Oct 2, 2024
nadment added a commit to nadment/hop that referenced this issue Oct 2, 2024
@nadment nadment linked a pull request Oct 2, 2024 that will close this issue
hansva added a commit that referenced this issue Oct 7, 2024
MetaInject step not correctly imported from Kettle #4384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant