Skip to content

Commit

Permalink
Merge pull request #4126 from nadment/4121
Browse files Browse the repository at this point in the history
Table exists action throws an error when added to a workflow #4121
  • Loading branch information
hansva authored Jul 29, 2024
2 parents ab68425 + 32ed327 commit 1963b43
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.hop.core.variables.IVariables;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.metadata.api.HopMetadataProperty;
import org.apache.hop.metadata.api.HopMetadataPropertyType;
import org.apache.hop.metadata.api.IHopMetadataProvider;
import org.apache.hop.resource.ResourceEntry;
import org.apache.hop.resource.ResourceEntry.ResourceType;
Expand All @@ -50,13 +51,19 @@
public class ActionTableExists extends ActionBase implements Cloneable, IAction {
private static final Class<?> PKG = ActionTableExists.class; // For Translator

@HopMetadataProperty(key = "tablename")
@HopMetadataProperty(
key = "tablename",
hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_TABLE)
private String tableName;

@HopMetadataProperty(key = "schemaname")
@HopMetadataProperty(
key = "schemaname",
hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_SCHEMA)
private String schemaName;

@HopMetadataProperty(key = "connection")
@HopMetadataProperty(
key = "connection",
hopMetadataPropertyType = HopMetadataPropertyType.RDBMS_CONNECTION)
private String connection;

public ActionTableExists(String n) {
Expand Down Expand Up @@ -118,8 +125,7 @@ public Result execute(Result previousResult, int nr) {
if (!Utils.isEmpty(connection)) {
DatabaseMeta dbMeta = parentWorkflowMeta.findDatabase(connection, getVariables());
if (dbMeta != null) {
Database db = new Database(this, this, dbMeta);
try {
try (Database db = new Database(this, this, dbMeta)) {
db.connect();
String realTableName = resolve(tableName);
String realSchemaName = resolve(schemaName);
Expand All @@ -140,14 +146,6 @@ public Result execute(Result previousResult, int nr) {
result.setNrErrors(1);
logError(
BaseMessages.getString(PKG, "TableExists.Error.RunningAction", dbe.getMessage()));
} finally {
if (db != null) {
try {
db.disconnect();
} catch (Exception e) {
/* Ignore */
}
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import org.apache.hop.workflow.action.IAction;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
Expand Down Expand Up @@ -97,7 +95,7 @@ public IAction open() {
int middle = props.getMiddlePct();
int margin = PropsUi.getMargin();

// Filename line
// Action name
Label wlName = new Label(shell, SWT.RIGHT);
wlName.setText(BaseMessages.getString(PKG, "ActionTableExists.Name.Label"));
PropsUi.setLook(wlName);
Expand All @@ -116,7 +114,8 @@ public IAction open() {
wName.setLayoutData(fdName);

// Connection line
wConnection = addConnectionLine(shell, wName, action.getConnection(), lsMod);
DatabaseMeta databaseMeta = workflowMeta.findDatabase(action.getConnection(), variables);
wConnection = addConnectionLine(shell, wName, databaseMeta, lsMod);

// Schema name line
Label wlSchemaName = new Label(shell, SWT.RIGHT);
Expand All @@ -135,13 +134,7 @@ public IAction open() {
fdbSchema.top = new FormAttachment(wConnection, 2 * margin);
fdbSchema.right = new FormAttachment(100, 0);
wbSchema.setLayoutData(fdbSchema);
wbSchema.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getSchemaNames();
}
});
wbSchema.addListener(SWT.Selection, e -> getSchemaNames());

wSchemaname = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wSchemaname);
Expand Down Expand Up @@ -169,13 +162,7 @@ public void widgetSelected(SelectionEvent e) {
fdbTable.right = new FormAttachment(100, 0);
fdbTable.top = new FormAttachment(wbSchema, margin);
wbTable.setLayoutData(fdbTable);
wbTable.addSelectionListener(
new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
getTableName();
}
});
wbTable.addListener(SWT.Selection, e -> getTableName());

wTablename = new TextVar(variables, shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
PropsUi.setLook(wTablename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ ActionTableExists.Description=Pr\u00FCft, ob eine Tabelle in einer Datenbank exi
ActionTableExists.keyword=table,exist,tabelle,existiert
ActionTableExists.Name=existiert Tabelle
ActionTableExists.Name.Default=existiert Tabelle
ActionTableExists.Name.Label=Name der Action:
ActionTableExists.Schemaname.Label=Schemaname
ActionTableExists.Tablename.Label=Tabellenname:
ActionTableExists.Name.Label=Name der Action
ActionTableExists.Schemaname.Label=Schemaname
ActionTableExists.Tablename.Label=Tabellenname
ActionTableExists.Title=existiert Tabelle
TableExists.Error.NoConnectionDefined=Keine Datenbankverbindung angegeben.
TableExists.Error.RunningAction=Bei der Transformausf\u00FChrung trat ein Fehler auf: {0}
TableExists.Log.TableExists=Tabelle [{0}] existiert.
TableExists.Log.TableNotExists=Tabelle [{0}] existiert nicht!
TableExists.Meta.UnableLoadXml=Konnte Action 'existiert Tabelle' nicht aus XML laden.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ ActionTableExists.Description=Checks if a table exists on a database connection
ActionTableExists.keyword=table,exist
ActionTableExists.Name=Table exists
ActionTableExists.Name.Default=Table exists
ActionTableExists.Name.Label=Action name\:
ActionTableExists.Schemaname.Label=Schema name\:
ActionTableExists.Tablename.Label=Table name\:
ActionTableExists.Name.Label=Action name
ActionTableExists.Schemaname.Label=Schema name
ActionTableExists.Tablename.Label=Table name
ActionTableExists.Title=Table exists
TableExists.Error.NoConnectionDefined=No database connection is defined.
TableExists.Error.RunningAction=An error occurred executing this transform: {0}
TableExists.Log.TableExists=Table [{0}] exists.
TableExists.Log.TableNotExists=Table [{0}] does not exist!
TableExists.Meta.UnableLoadXml=Unable to load action of type 'table exists' from XML node
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@

ActionTableExists.Name=La tabla existe
ActionTableExists.Name.Default=La tabla existe
ActionTableExists.Name.Label=Nombre de la entrada de trabajo\:
ActionTableExists.Schemaname.Label=Nombre del esquema\:
ActionTableExists.Tablename.Label=Nombre de la tabla\:
ActionTableExists.Name.Label=Nombre de la entrada de trabajo
ActionTableExists.Schemaname.Label=Nombre del esquema
ActionTableExists.Tablename.Label=Nombre de la tabla
ActionTableExists.Title=La tabla existe
TableExists.Error.NoConnectionDefined=No se ha definido una conexi\u00F3n a base de datos.
TableExists.Error.RunningAction=Ha ocurrido un error al ejecutar el paso\: {0}
TableExists.Log.TableExists=La tabla [{0}] existe.
TableExists.Log.TableNotExists=La tabla [{0}] no existe.
TableExists.Meta.UnableLoadXml=Imposible cargar la entrada de trabajo del tipo "Verificar si la tabla existe..." del nodo XML
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ ActionTableExists.Description=V\u00e9rifie si une table existe sur une connexion
ActionTableExists.Name=V\u00e9rification existence table
ActionTableExists.Name.Default=V\u00E9rifier existence table
ActionTableExists.Name.Label=Nom de l''action
ActionTableExists.Schemaname.Label=Nom du Sch\u00E9ma\u00A0:
ActionTableExists.Tablename.Label=Nom de la table :
ActionTableExists.Schemaname.Label=Nom du Sch\u00E9ma
ActionTableExists.Tablename.Label=Nom de la table
ActionTableExists.Title=V\u00e9rification existence table
TableExists.Error.NoConnectionDefined=Connexion non d\u00E9finie.
TableExists.Error.RunningAction=Apache Hop a rencontr\u00E9 une erreur lors de l''ex\u00E9cution de cette action\: {0}
TableExists.Log.TableExists=La table [{0}] existe.
TableExists.Log.TableNotExists=La table [{0}] est introuvable\!
TableExists.Meta.UnableLoadXml=Impossible de charger depuis le fichier XML, les informations de l''action de type 'v\u00E9rification existance table'
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
#

ActionTableExists.Name.Default=Table exists
ActionTableExists.Name.Label=Nome action\:
ActionTableExists.Schemaname.Label=Schema\:
ActionTableExists.Tablename.Label=Tabella\:
ActionTableExists.Name.Label=Nome action
ActionTableExists.Schemaname.Label=Schema
ActionTableExists.Tablename.Label=Tabella
ActionTableExists.Title=Table exists
TableExists.Error.NoConnectionDefined=Non \u00E8 stata definita alcuna connessione al database .
TableExists.Error.NoConnectionDefined=Non \u00E8 stata definita alcuna connessione al database.
TableExists.Error.RunningAction=Si \u00E8 verificato un errore durante l''esecuzione di questa action\: {0}
TableExists.Log.TableExists=La tabella [{0}] esiste.
TableExists.Log.TableNotExists=La tabella [{0}] non esiste\!
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ TableExists.Error.NoConnectionDefined=No database connection is defined.
TableExists.Error.RunningAction=An error occurred executing this transform: {0}
TableExists.Log.TableExists=Table [{0}] exists.
TableExists.Log.TableNotExists=Table [{0}] does not exist!
TableExists.Meta.UnableLoadXml=Unable to load action of type 'table exists' from XML node
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
#

ActionTableExists.Name.Default=Table exists
ActionTableExists.Name.Label=Workflow \uC5D4\uD2B8\uB9AC \uC774\uB984\:
ActionTableExists.Schemaname.Label=\uC2A4\uD0A4\uB9C8 \uC774\uB984\:
ActionTableExists.Tablename.Label=\uD14C\uC774\uBE14 \uC774\uB984\:
ActionTableExists.Name.Label=Workflow \uC5D4\uD2B8\uB9AC \uC774\uB984
ActionTableExists.Schemaname.Label=\uC2A4\uD0A4\uB9C8 \uC774\uB984
ActionTableExists.Tablename.Label=\uD14C\uC774\uBE14 \uC774\uB984
ActionTableExists.Title=Table exists
TableExists.Error.NoConnectionDefined=\uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uC5F0\uACB0\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.
TableExists.Error.RunningAction=\uC774 transform\uC744 \uC2E4\uD589\uD558\uB294 \uB3D9\uC548 \uC624\uB958\uAC00 \uBC1C\uC0DD\uD558\uC600\uC2B5\uB2C8\uB2E4\: {0}
TableExists.Log.TableExists=\uD14C\uC774\uBE14 [{0}]\uC774 \uC874\uC7AC\uD569\uB2C8\uB2E4.
TableExists.Log.TableNotExists=\uD14C\uC774\uBE14 [{0}]\uC774 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4\!
TableExists.Meta.UnableLoadXml=XML \uB178\uB4DC\uC5D0\uC11C Workflow \uC5D4\uD2B8\uB9AC \uD615\uC2DD 'table exists' \uB97C \uB85C\uB4DC\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
#

ActionTableExists.Name.Default=Tabel bestaat
ActionTableExists.Name.Label=Naam van de Action\:
ActionTableExists.Tablename.Label=Tabelnaam\:
ActionTableExists.Name.Label=Naam van de Action
ActionTableExists.Tablename.Label=Tabelnaam
ActionTableExists.Title=Kijk na of een tabel bestaat...
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ ActionTableExists.Description=Checa se uma tabela existe em uma base de dados
ActionTableExists.keyword=tabela,existir
ActionTableExists.Name=Tabela existe
ActionTableExists.Name.Default=Tabela existe
ActionTableExists.Name.Label=Nome da a\u00E7\u00E3o:
ActionTableExists.Name.Label=Nome da a\u00E7\u00E3o
ActionTableExists.Schemaname.Label=Nome de esquema
ActionTableExists.Tablename.Label=nome da tabela:
ActionTableExists.Tablename.Label=nome da tabela
ActionTableExists.Title=Tabela existe
TableExists.Error.NoConnectionDefined=N\u00E3o foi definida a conex\u00E3o com o banco de dados.
TableExists.Error.RunningAction=Ocorreu um erro ao executar esta transforma\u00E7\u00E3o: {0}
TableExists.Log.TableExists=A tabela [{0}] existe.
TableExists.Log.TableNotExists=A tabela [{0}] n\u00E3o existe!
TableExists.Meta.UnableLoadXml=N\u00E3o \u00E9 poss\u00EDvel carregar a a\u00E7\u00E3o do tipo 'tabela existe' do n\u00F3 XML
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ ActionTableExists.Description=\u68C0\u67E5\u662F\u5426\u5728\u67D0\u4E2A\u6570\u
ActionTableExists.keyword=table,exist
ActionTableExists.Name=\u68C0\u67E5\u8868\u662F\u5426\u5B58\u5728
ActionTableExists.Name.Default=\u8868\u5B58\u5728
ActionTableExists.Name.Label=Action \u540D\u79F0\:
ActionTableExists.Schemaname.Label=\u6A21\u5F0F\u540D\u79F0\:
ActionTableExists.Tablename.Label=\u8868\u540D\:
ActionTableExists.Name.Label=Action \u540D\u79F0
ActionTableExists.Schemaname.Label=\u6A21\u5F0F\u540D\u79F0
ActionTableExists.Tablename.Label=\u8868\u540D
ActionTableExists.Title=\u68C0\u67E5\u8868\u662F\u5426\u5B58\u5728
TableExists.Error.NoConnectionDefined=\u6CA1\u6709\u5B9A\u4E49\u6570\u636E\u5E93\u8FDE\u63A5
TableExists.Error.RunningAction=\u5728\u6267\u884C\u8BE5 Transform \u65F6\u51FA\u9519\:{0}
Expand Down

0 comments on commit 1963b43

Please sign in to comment.