Skip to content

Commit

Permalink
[PDI-20078] - Metadata generated from "Automatic Documentation Output…
Browse files Browse the repository at this point in the history
…" step for a transformation/job will contain all the unwanted connections available in the repository (pentaho#9279)
  • Loading branch information
andreramos89 authored Apr 18, 2024
1 parent e3e3794 commit 3880e41
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions core/src/main/java/org/pentaho/di/core/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -1657,6 +1657,11 @@ public static String getShimDriverDeploymentLocation() {
*/
public static final String COMPATIBILITY_SHOW_WARNINGS_EXECUTE_EVERY_INPUT_ROW = "COMPATIBILITY_SHOW_WARNINGS_EXECUTE_EVERY_INPUT_ROW";

/**
Value to Configure if we want to export only the used connections to the XML file
*/
public static final String STRING_ONLY_USED_DB_TO_XML = "STRING_ONLY_USED_DB_TO_XML";

/**
* rounds double f to any number of places after decimal point Does arithmetic using BigDecimal class to avoid integer
* overflow while rounding
Expand Down
10 changes: 9 additions & 1 deletion engine/src/main/java/org/pentaho/di/trans/TransMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -2566,7 +2566,10 @@ public String getXML( boolean includeSteps, boolean includeDatabase, boolean inc
if ( includeDatabase ) {
for ( int i = 0; i < nrDatabases(); i++ ) {
DatabaseMeta dbMeta = getDatabase( i );
if ( props != null && props.areOnlyUsedConnectionsSavedToXML() ) {
//PDI-20078 - If props == null, it means transformation is running on the slave server. For the
// method areOnlyUsedConnectionsSavedToXMLInServer to return false, the "STRING_ONLY_USED_DB_TO_XML"
// needs to have "N" in the server startup script file
if ( props != null && props.areOnlyUsedConnectionsSavedToXML() || props == null && areOnlyUsedConnectionsSavedToXMLInServer() ) {
if ( isDatabaseConnectionUsed( dbMeta ) ) {
retval.append( dbMeta.getXML() );
}
Expand Down Expand Up @@ -2621,6 +2624,11 @@ public String getXML( boolean includeSteps, boolean includeDatabase, boolean inc
return XMLFormatter.format( retval.toString() );
}

public boolean areOnlyUsedConnectionsSavedToXMLInServer() {
String show = System.getProperty( Const.STRING_ONLY_USED_DB_TO_XML, "Y" );
return "Y".equalsIgnoreCase( show ); // Default: save only used connections
}

/**
* Parses a file containing the XML that describes the transformation. No default connections are loaded since no
* repository is available at this time. Since the filename is set, internal variables are being set that relate to
Expand Down
1 change: 0 additions & 1 deletion engine/src/main/resources/kettle-variables.xml
Original file line number Diff line number Diff line change
Expand Up @@ -663,5 +663,4 @@
<variable>COMPATIBILITY_SHOW_WARNINGS_EXECUTE_EVERY_INPUT_ROW</variable>
<default-value>Y</default-value>
</kettle-variable>

</kettle-variables>

0 comments on commit 3880e41

Please sign in to comment.