Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
import org.apache.hop.core.exception.HopFileException;
import org.apache.hop.core.exception.HopPluginException;
import org.apache.hop.core.exception.HopTransformException;
import org.apache.hop.core.gui.plugin.GuiElementType;
import org.apache.hop.core.gui.plugin.GuiPlugin;
import org.apache.hop.core.gui.plugin.GuiWidgetElement;
import org.apache.hop.core.gui.plugin.GuiWidgetGroupType;
import org.apache.hop.core.gui.plugin.ITypeFilename;
import org.apache.hop.core.row.IRowMeta;
import org.apache.hop.core.row.IValueMeta;
import org.apache.hop.core.row.RowMeta;
Expand Down Expand Up @@ -66,20 +71,69 @@
ActionTransformType.LOOKUP,
ActionTransformType.JOIN
})
@GuiPlugin
public class DatabaseJoinMeta extends BaseTransformMeta<DatabaseJoin, DatabaseJoinData> {

private static final Class<?> PKG = DatabaseJoinMeta.class;

public static final String GUI_PLUGIN_ELEMENT_PARENT_ID = "DATABASE_JOIN_DIALOG_OPTIONS";

public static final String GROUP_CONNECTION = "i18n::DatabaseJoin.Tab.Connection";
public static final String GROUP_CONNECTION_ORDER = "0100";
public static final String GROUP_SQL = "i18n::DatabaseJoin.Tab.Sql";
public static final String GROUP_SQL_ORDER = "0200";
public static final String GROUP_PARAMETERS = "i18n::DatabaseJoin.Tab.Parameters";
public static final String GROUP_PARAMETERS_ORDER = "0300";

public static final String WIDGET_CONNECTION = "connection";
public static final String WIDGET_CACHED = "cached";
public static final String WIDGET_CACHE_SIZE = "cacheSize";
public static final String WIDGET_SQL_FROM_FILE = "sqlFromFile";
public static final String WIDGET_ROW_LIMIT = "rowLimit";
public static final String WIDGET_OUTER_JOIN = "outerJoin";
public static final String WIDGET_REPLACE_VARIABLES = "replaceVariables";

@GuiWidgetElement(
id = WIDGET_CONNECTION,
order = "0100",
type = GuiElementType.METADATA,
metadata = DatabaseMeta.class,
label = "i18n::DatabaseJoinMeta.Connection.Label",
toolTip = "i18n::DatabaseJoinMeta.Connection.Tooltip",
parentId = GUI_PLUGIN_ELEMENT_PARENT_ID,
groupType = GuiWidgetGroupType.TABS,
group = GROUP_CONNECTION,
groupOrder = GROUP_CONNECTION_ORDER)
@HopMetadataProperty(
key = "connection",
injectionKeyDescription = "DatabaseJoinMeta.Injection.Connection",
hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
private String connection;

@GuiWidgetElement(
id = WIDGET_CACHED,
order = "0200",
type = GuiElementType.CHECKBOX,
label = "i18n::DatabaseJoinMeta.Cached.Label",
toolTip = "i18n::DatabaseJoinMeta.Cached.Tooltip",
parentId = GUI_PLUGIN_ELEMENT_PARENT_ID,
groupType = GuiWidgetGroupType.TABS,
group = GROUP_CONNECTION,
groupOrder = GROUP_CONNECTION_ORDER)
@HopMetadataProperty(key = "cache", injectionKeyDescription = "DatabaseJoinMeta.Injection.Cache")
private boolean cached;

/** Limit the cache size to this! */
@GuiWidgetElement(
id = WIDGET_CACHE_SIZE,
order = "0300",
type = GuiElementType.TEXT,
label = "i18n::DatabaseJoinMeta.CacheSize.Label",
toolTip = "i18n::DatabaseJoinMeta.CacheSize.Tooltip",
parentId = GUI_PLUGIN_ELEMENT_PARENT_ID,
groupType = GuiWidgetGroupType.TABS,
group = GROUP_CONNECTION,
groupOrder = GROUP_CONNECTION_ORDER)
@HopMetadataProperty(
key = "cache_size",
injectionKeyDescription = "DatabaseJoinMeta.Injection.CacheSize")
Expand All @@ -95,13 +149,34 @@ public class DatabaseJoinMeta extends BaseTransformMeta<DatabaseJoin, DatabaseJo
/**
* When set, SQL is loaded from this file (VFS path, supports variables). SQL editor is read-only.
*/
@GuiWidgetElement(
id = WIDGET_SQL_FROM_FILE,
order = "0100",
type = GuiElementType.FILENAME,
typeFilename = SqlFilename.class,
label = "i18n::DatabaseJoinMeta.SqlFromFile.Label",
toolTip = "i18n::DatabaseJoinMeta.SqlFromFile.Tooltip",
parentId = GUI_PLUGIN_ELEMENT_PARENT_ID,
groupType = GuiWidgetGroupType.TABS,
group = GROUP_SQL,
groupOrder = GROUP_SQL_ORDER)
@HopMetadataProperty(
key = "sql_from_file",
injectionKey = "SQL_FROM_FILE",
injectionKeyDescription = "DatabaseJoinMeta.Injection.SqlFromFile")
private String sqlFromFile;

/** Number of rows to return (0=ALL) */
@GuiWidgetElement(
id = WIDGET_ROW_LIMIT,
order = "0300",
type = GuiElementType.TEXT,
label = "i18n::DatabaseJoinMeta.RowLimit.Label",
toolTip = "i18n::DatabaseJoinMeta.RowLimit.Tooltip",
parentId = GUI_PLUGIN_ELEMENT_PARENT_ID,
groupType = GuiWidgetGroupType.TABS,
group = GROUP_SQL,
groupOrder = GROUP_SQL_ORDER)
@HopMetadataProperty(
key = "rowlimit",
injectionKeyDescription = "DatabaseJoinMeta.Injection.RowLimit")
Expand All @@ -111,6 +186,16 @@ public class DatabaseJoinMeta extends BaseTransformMeta<DatabaseJoin, DatabaseJo
* false: don't return rows where nothing is found true: at least return one source row, the rest
* is NULL
*/
@GuiWidgetElement(
id = WIDGET_OUTER_JOIN,
order = "0400",
type = GuiElementType.CHECKBOX,
label = "i18n::DatabaseJoinMeta.OuterJoin.Label",
toolTip = "i18n::DatabaseJoinMeta.OuterJoin.Tooltip",
parentId = GUI_PLUGIN_ELEMENT_PARENT_ID,
groupType = GuiWidgetGroupType.TABS,
group = GROUP_SQL,
groupOrder = GROUP_SQL_ORDER)
@HopMetadataProperty(
key = "outer_join",
injectionKeyDescription = "DatabaseJoinMeta.Injection.OuterJoin")
Expand All @@ -125,6 +210,16 @@ public class DatabaseJoinMeta extends BaseTransformMeta<DatabaseJoin, DatabaseJo
private List<ParameterField> parameters = new ArrayList<>();

/** false: don't replace variable in script true: replace variable in script */
@GuiWidgetElement(
id = WIDGET_REPLACE_VARIABLES,
order = "0500",
type = GuiElementType.CHECKBOX,
label = "i18n::DatabaseJoinMeta.ReplaceVariables.Label",
toolTip = "i18n::DatabaseJoinMeta.ReplaceVariables.Tooltip",
parentId = GUI_PLUGIN_ELEMENT_PARENT_ID,
groupType = GuiWidgetGroupType.TABS,
group = GROUP_SQL,
groupOrder = GROUP_SQL_ORDER)
@HopMetadataProperty(
key = "replace_vars",
injectionKeyDescription = "DatabaseJoinMeta.Injection.ReplaceVariables")
Expand Down Expand Up @@ -782,4 +877,26 @@ public void analyseImpact(
public boolean supportsErrorHandling() {
return true;
}

/** Filters for the SQL file field. The widget's own Browse button opens the dialog once. */
public static class SqlFilename implements ITypeFilename {

@Override
public String getDefaultFileExtension() {
return ".sql";
}

@Override
public String[] getFilterExtensions() {
return new String[] {"*.sql", "*"};
}

@Override
public String[] getFilterNames() {
return new String[] {
BaseMessages.getString(PKG, "DatabaseJoinDialog.SqlFiles"),
BaseMessages.getString("System.FileType.AllFiles")
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ DatabaseJoin.Log.LineNumber=linenr
DatabaseJoin.Log.PutoutRow=Put out row\:
DatabaseJoin.Log.SQLStatement=Prepare SQL statement \: {0}
DatabaseJoin.Name=Database join
DatabaseJoin.Tab.Connection=Connection
DatabaseJoin.Tab.Sql=SQL
DatabaseJoin.Tab.Parameters=Parameters
DatabaseJoinDialog.Cache.Label=Enable cache
DatabaseJoinDialog.CacheSize.Label=Cache size in rows (0\: cache everything)
DatabaseJoinDialog.ColumnInfo.ParameterFieldname=Parameter fieldname
Expand Down Expand Up @@ -53,10 +56,25 @@ DatabaseJoinDialog.SQL.Label=SQL
DatabaseJoinDialog.LoadSqlFromFile=Load SQL from file
DatabaseJoinDialog.Browse=Browse...
DatabaseJoinDialog.SqlFiles=SQL files
DatabaseJoinDialog.CouldNotLoadSqlFromFile=Could not load SQL from file: {0}
DatabaseJoinDialog.CouldNotLoadSqlFromFile=Could not load SQL from file\: {0}
DatabaseJoinDialog.CouldNotLoadSqlFromFile.Title=Could not load SQL from file
DatabaseJoinDialog.TransformName.Label=Transform name
DatabaseJoinDialog.useVarsjoin.Label=Replace variables
DatabaseJoinDialog.useVarsjoin.Tooltip=Replace variables in SQL script
DatabaseJoinMeta.Connection.Label=Connection
DatabaseJoinMeta.Connection.Tooltip=The database connection used to run the query
DatabaseJoinMeta.Cached.Label=Enable cache
DatabaseJoinMeta.Cached.Tooltip=Cache the query result so repeated lookups do not hit the database again
DatabaseJoinMeta.CacheSize.Label=Cache size in rows (0\: cache everything)
DatabaseJoinMeta.CacheSize.Tooltip=Maximum number of rows to keep in the cache. Zero caches everything.
DatabaseJoinMeta.SqlFromFile.Label=Load SQL from file
DatabaseJoinMeta.SqlFromFile.Tooltip=Optional VFS path to read the query from. When set, the SQL editor becomes read-only.
DatabaseJoinMeta.RowLimit.Label=Number of rows to return
DatabaseJoinMeta.RowLimit.Tooltip=Maximum number of rows to return. Zero returns all matching rows.
DatabaseJoinMeta.OuterJoin.Label=Outer join
DatabaseJoinMeta.OuterJoin.Tooltip=Return at least the input row and add NULLs for the lookup values
DatabaseJoinMeta.ReplaceVariables.Label=Replace variables
DatabaseJoinMeta.ReplaceVariables.Tooltip=Replace variables in the SQL script
DatabaseJoinMeta.CheckResult.AllFieldsFound=All fields found in the input stream.
DatabaseJoinMeta.CheckResult.CounldNotReadFields=Couldn''t read fields from the previous transform.
DatabaseJoinMeta.CheckResult.DatabaseMetaError=Unable to get a reference to databaseMeta for connection: ''{0}''
Expand Down
Loading
Loading