diff --git a/assemblies/plugins/pom.xml b/assemblies/plugins/pom.xml index 60285c928b..5571864db8 100644 --- a/assemblies/plugins/pom.xml +++ b/assemblies/plugins/pom.xml @@ -943,6 +943,12 @@ ${project.version} zip + + org.apache.hop + hop-transform-dbimpact + ${project.version} + zip + org.apache.hop hop-transform-dbproc diff --git a/docs/hop-user-manual/modules/ROOT/nav.adoc b/docs/hop-user-manual/modules/ROOT/nav.adoc index f18b4bf528..364c561658 100644 --- a/docs/hop-user-manual/modules/ROOT/nav.adoc +++ b/docs/hop-user-manual/modules/ROOT/nav.adoc @@ -116,6 +116,7 @@ under the License. *** xref:pipeline/transforms/databaselookup.adoc[Database Lookup] *** xref:pipeline/transforms/datagrid.adoc[Data Grid] *** xref:pipeline/transforms/datasetinput.adoc[Data Set Input] +*** xref:pipeline/transforms/dbimpactinput.adoc[Database Impact Input] *** xref:pipeline/transforms/validator.adoc[Data Validator] *** xref:pipeline/transforms/delay.adoc[Delay row] *** xref:pipeline/transforms/delete.adoc[Delete] diff --git a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms.adoc b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms.adoc index 87336e9a39..daa5fe0eb5 100644 --- a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms.adoc +++ b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms.adoc @@ -75,6 +75,8 @@ The pages nested under this topic contain information on how to use the transfor * xref:pipeline/transforms/databasejoin.adoc[Database Join] * xref:pipeline/transforms/databaselookup.adoc[Database Lookup] * xref:pipeline/transforms/datagrid.adoc[Data Grid] +* xref:pipeline/transforms/datasetinput.adoc[Dataset Input] +* xref:pipeline/transforms/dbimpactinput.adoc[Database Impact Input] * xref:pipeline/transforms/delay.adoc[Delay row] * xref:pipeline/transforms/delete.adoc[Delete] * xref:pipeline/transforms/serialize-de-from-file.adoc[De-Serialize From File] diff --git a/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/dbimpactinput.adoc b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/dbimpactinput.adoc new file mode 100644 index 0000000000..ef435cbb1e --- /dev/null +++ b/docs/hop-user-manual/modules/ROOT/pages/pipeline/transforms/dbimpactinput.adoc @@ -0,0 +1,77 @@ +//// +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +//// +:documentationPath: /pipeline/transforms/ +:language: en_US +:description: Read database impact information from pipelines. + += image:images/icons/database.svg[Database Impact Input, role="image-doc-icon"] Database Impact Input + +[%noheader,cols="3a,1a", role="table-no-borders" ] +|=== +| +== Description + +The Database Impact Input transform allows gives you the impact of a pipeline on a database. +It explains which transforms read, write, update or delete information, in which table, the SQL used, and so on. + +IMPORTANT: This transform supports error handling. You can add an error handling hop to a transform to be informed of the pipelines that throw an error when calculating the database impact. See also: xref:pipeline/errorhandling.adoc[Pipeline error handling]. + +| +== Supported Engines +[%noheader,cols="2,1a",frame=none, role="table-supported-engines"] +!=== +!Hop Engine! image:check_mark.svg[Supported, 24] +!Spark! image:check_mark.svg[Supported, 24] +!Flink! image:check_mark.svg[Supported, 24] +!Dataflow! image:check_mark.svg[Supported, 24] +!=== +|=== + +== Options + +[options="header] +|=== +|Option|Description +|Transform name +|Name of the transform. +This name has to be unique in a single pipeline. + +|File name field +|The name of the field in the transform input which will contain the filenames to analyze the database impact for. + +|=== + +TIP: You can use a xref:pipeline/transforms/getfilenames.adoc[Get File Names] transform as input. To search for your project pipelines specify folder `${PROJECT_HOME}` with wildcard `.*\.hpl$`. + +== Output fields + +[options="header] +|=== +|Fieldname|Type +|Type|String +|PipelineName|String +|PipelineFileName|String +|TransformName|String +|DatabaseName|String +|DatabaseTable|String +|TableField|String +|FieldName|String +|FieldOrigin|String +|SQL|String +|Remark|String + +|=== diff --git a/engine/src/main/java/org/apache/hop/pipeline/PipelineMeta.java b/engine/src/main/java/org/apache/hop/pipeline/PipelineMeta.java index 75ec6ecece..9ac027924c 100644 --- a/engine/src/main/java/org/apache/hop/pipeline/PipelineMeta.java +++ b/engine/src/main/java/org/apache/hop/pipeline/PipelineMeta.java @@ -1087,7 +1087,7 @@ public IRowMeta getTransformFields(IVariables variables, TransformMeta[] transfo for (TransformMeta meta : transformMeta) { IRowMeta flds = getTransformFields(variables, meta); - if (flds != null) { + if (flds != null && meta != null) { fields.mergeRowMeta(flds, meta.getName()); } } @@ -1387,10 +1387,15 @@ public IRowMeta getThisTransformFields( IRowMeta[] infoRowMeta; TransformMeta[] lu = getInfoTransform(transformMeta); if (Utils.isEmpty(lu)) { - infoRowMeta = - new IRowMeta[] { - iTransformMeta.getTableFields(variables), - }; + try { + infoRowMeta = + new IRowMeta[] { + iTransformMeta.getTableFields(variables), + }; + } catch (HopDatabaseException dbe) { + throw new HopTransformException( + "Error getting table fields in transform " + transformMeta.getName(), dbe); + } } else { infoRowMeta = new IRowMeta[lu.length]; for (int i = 0; i < lu.length; i++) { @@ -2632,7 +2637,12 @@ public void analyseImpact( if (lu != null) { infoRowMeta = getTransformFields(variables, lu); } else { - infoRowMeta = iTransformMeta.getTableFields(variables); + try { + infoRowMeta = iTransformMeta.getTableFields(variables); + } catch (HopDatabaseException dbe) { + throw new HopTransformException( + "Error getting table fields from in transform " + transformMeta.getName(), dbe); + } } iTransformMeta.analyseImpact( diff --git a/engine/src/main/java/org/apache/hop/pipeline/transform/BaseTransformMeta.java b/engine/src/main/java/org/apache/hop/pipeline/transform/BaseTransformMeta.java index 410a97b26c..e7e3bcd65b 100644 --- a/engine/src/main/java/org/apache/hop/pipeline/transform/BaseTransformMeta.java +++ b/engine/src/main/java/org/apache/hop/pipeline/transform/BaseTransformMeta.java @@ -242,7 +242,7 @@ public boolean hasChanged() { * @return the table fields * @param variables */ - public IRowMeta getTableFields(IVariables variables) { + public IRowMeta getTableFields(IVariables variables) throws HopDatabaseException { return null; } diff --git a/engine/src/main/java/org/apache/hop/pipeline/transform/ITransformMeta.java b/engine/src/main/java/org/apache/hop/pipeline/transform/ITransformMeta.java index 2b40b8bcdd..5162277c85 100644 --- a/engine/src/main/java/org/apache/hop/pipeline/transform/ITransformMeta.java +++ b/engine/src/main/java/org/apache/hop/pipeline/transform/ITransformMeta.java @@ -251,7 +251,7 @@ void check( * @return The fields used by this transform, this is being used for the Impact analyses. * @param variables */ - IRowMeta getTableFields(IVariables variables); + IRowMeta getTableFields(IVariables variables) throws HopDatabaseException; /** This method is added to exclude certain transforms from layout checking. */ boolean excludeFromRowLayoutVerification(); diff --git a/plugins/transforms/databaselookup/src/main/java/org/apache/hop/pipeline/transforms/databaselookup/DatabaseLookupMeta.java b/plugins/transforms/databaselookup/src/main/java/org/apache/hop/pipeline/transforms/databaselookup/DatabaseLookupMeta.java index 794d3565ac..83dca66a1e 100644 --- a/plugins/transforms/databaselookup/src/main/java/org/apache/hop/pipeline/transforms/databaselookup/DatabaseLookupMeta.java +++ b/plugins/transforms/databaselookup/src/main/java/org/apache/hop/pipeline/transforms/databaselookup/DatabaseLookupMeta.java @@ -361,7 +361,7 @@ public void check( } @Override - public IRowMeta getTableFields(IVariables variables) { + public IRowMeta getTableFields(IVariables variables) throws HopDatabaseException { IRowMeta fields = null; DatabaseMeta databaseMeta = getParentTransformMeta().getParentPipelineMeta().findDatabase(connection, variables); @@ -375,10 +375,11 @@ public IRowMeta getTableFields(IVariables variables) { variables, lookup.getSchemaName(), lookup.getTableName()); fields = db.getTableFields(schemaTable); - } catch (HopDatabaseException dbe) { - logError( + } catch (Throwable dbe) { + throw new HopDatabaseException( BaseMessages.getString(PKG, "DatabaseLookupMeta.ERROR0004.ErrorGettingTableFields") - + dbe.getMessage()); + + dbe.getMessage(), + dbe); } } return fields; @@ -439,7 +440,8 @@ public void analyseImpact( } } catch (HopException e) { throw new HopTransformException( - "Unable to get databaseMeta for connection: " + Const.CR + variables.resolve(connection)); + "Unable to get databaseMeta for connection: " + Const.CR + variables.resolve(connection), + e); } } diff --git a/plugins/transforms/dbimpact/pom.xml b/plugins/transforms/dbimpact/pom.xml new file mode 100644 index 0000000000..c8718728a5 --- /dev/null +++ b/plugins/transforms/dbimpact/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + org.apache.hop + hop-plugins-transforms + 2.18.0-SNAPSHOT + + + hop-transform-dbimpact + jar + Hop Plugins Transforms DB Impact + + diff --git a/plugins/transforms/dbimpact/src/assembly/assembly.xml b/plugins/transforms/dbimpact/src/assembly/assembly.xml new file mode 100644 index 0000000000..b585248a4d --- /dev/null +++ b/plugins/transforms/dbimpact/src/assembly/assembly.xml @@ -0,0 +1,50 @@ + + + + hop-transform-dbimpact + + zip + + . + + + ${project.basedir}/src/main/resources/version.xml + plugins/transforms/dbimpact + true + + + + + + ${project.basedir}/src/main/samples + config/projects/samples/ + + + + + + + org.apache.hop:hop-transform-dbimpact:jar + + plugins/transforms/dbimpact + + + \ No newline at end of file diff --git a/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInput.java b/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInput.java new file mode 100644 index 0000000000..9febe4cce1 --- /dev/null +++ b/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInput.java @@ -0,0 +1,131 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hop.pipeline.transforms.dbimpact.input; + +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.apache.hop.core.Const; +import org.apache.hop.core.exception.HopException; +import org.apache.hop.core.exception.HopTransformException; +import org.apache.hop.core.row.RowDataUtil; +import org.apache.hop.core.row.RowMeta; +import org.apache.hop.pipeline.DatabaseImpact; +import org.apache.hop.pipeline.Pipeline; +import org.apache.hop.pipeline.PipelineMeta; +import org.apache.hop.pipeline.transform.BaseTransform; +import org.apache.hop.pipeline.transform.TransformMeta; +import org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType; +import org.apache.hop.ui.hopgui.file.workflow.HopWorkflowFileType; + +/** Generates a number of (empty or the same) rows */ +public class DbImpactInput extends BaseTransform { + public DbImpactInput( + TransformMeta transformMeta, + DbImpactInputMeta meta, + DbImpactInputData data, + int copyNr, + PipelineMeta pipelineMeta, + Pipeline pipeline) { + super(transformMeta, meta, data, copyNr, pipelineMeta, pipeline); + } + + @Override + public boolean processRow() throws HopException { + Object[] inputRow = getRow(); + if (inputRow == null) { + setOutputDone(); + return false; + } + + if (first) { + first = false; + + // Calculate the output row meta-data + data.outputRowMeta = new RowMeta(); + meta.getFields(data.outputRowMeta, getTransformName(), null, null, this, metadataProvider); + + data.pipelineFileType = new HopPipelineFileType<>(); + data.workflowFileType = new HopWorkflowFileType<>(); + } + String fieldName = resolve(meta.getFileNameField()); + String fileName = getInputRowMeta().getString(inputRow, fieldName, null); + + if (StringUtils.isNotEmpty(fileName)) { + List impacts = new ArrayList<>(); + try { + if (data.pipelineFileType.isHandledBy(fileName, false)) { + extractPipelineLineage(fileName, impacts); + } + if (data.workflowFileType.isHandledBy(fileName, false)) { + extractWorkflowLineage(fileName, impacts); + } + outputDbImpact(fileName, impacts); + } catch (Throwable e) { + if (getTransformMeta().isDoingErrorHandling()) { + putError( + getInputRowMeta(), + inputRow, + 1, + Const.getSimpleStackTrace(e), + fieldName, + "DBImpact001"); + } else { + throw e; + } + } + } + + return true; + } + + private void outputDbImpact(String fileName, List impacts) + throws HopTransformException { + for (DatabaseImpact impact : impacts) { + Object[] row = RowDataUtil.allocateRowData(data.outputRowMeta.size()); + int index = 0; + row[index++] = impact.getTypeDesc(); + row[index++] = impact.getPipelineName(); + row[index++] = fileName; + row[index++] = impact.getTransformName(); + row[index++] = impact.getDatabaseName(); + row[index++] = impact.getTable(); + row[index++] = impact.getField(); + row[index++] = impact.getValue(); + row[index++] = impact.getValueOrigin(); + row[index++] = impact.getSql(); + row[index] = impact.getRemark(); + putRow(data.outputRowMeta, row); + } + } + + private void extractPipelineLineage(String fileName, List impact) + throws HopException { + try { + PipelineMeta pipelineMeta = new PipelineMeta(fileName, metadataProvider, this); + incrementLinesInput(); + pipelineMeta.analyseImpact(this, impact, null); + } catch (Throwable e) { + throw new HopException("Error extracting lineage information from pipeline " + fileName, e); + } + } + + private void extractWorkflowLineage(String fileName, List impact) { + logBasic("DB Impact analyses of workflow '" + fileName + "' is not supported yet."); + } +} diff --git a/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputData.java b/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputData.java new file mode 100644 index 0000000000..33afa3117a --- /dev/null +++ b/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputData.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hop.pipeline.transforms.dbimpact.input; + +import org.apache.hop.core.row.IRowMeta; +import org.apache.hop.pipeline.PipelineMeta; +import org.apache.hop.pipeline.transform.BaseTransformData; +import org.apache.hop.pipeline.transform.ITransformData; +import org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType; +import org.apache.hop.ui.hopgui.file.workflow.HopWorkflowFileType; +import org.apache.hop.workflow.WorkflowMeta; + +public class DbImpactInputData extends BaseTransformData implements ITransformData { + public IRowMeta outputRowMeta; + public HopPipelineFileType pipelineFileType; + public HopWorkflowFileType workflowFileType; + + public DbImpactInputData() { + super(); + } +} diff --git a/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputDialog.java b/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputDialog.java new file mode 100644 index 0000000000..e3532495a4 --- /dev/null +++ b/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputDialog.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hop.pipeline.transforms.dbimpact.input; + +import org.apache.hop.core.Const; +import org.apache.hop.core.util.Utils; +import org.apache.hop.core.variables.IVariables; +import org.apache.hop.i18n.BaseMessages; +import org.apache.hop.pipeline.PipelineMeta; +import org.apache.hop.ui.core.PropsUi; +import org.apache.hop.ui.core.dialog.BaseDialog; +import org.apache.hop.ui.core.dialog.ErrorDialog; +import org.apache.hop.ui.core.widget.LabelComboVar; +import org.apache.hop.ui.pipeline.transform.BaseTransformDialog; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.widgets.Shell; + +public class DbImpactInputDialog extends BaseTransformDialog { + private static final Class PKG = DbImpactInputMeta.class; + + private LabelComboVar wFileNameField; + + private final DbImpactInputMeta input; + + public DbImpactInputDialog( + Shell parent, + IVariables variables, + DbImpactInputMeta transformMeta, + PipelineMeta pipelineMeta) { + super(parent, variables, transformMeta, pipelineMeta); + input = transformMeta; + } + + @Override + public String open() { + createShell(BaseMessages.getString(PKG, "DbImpactInputMeta.Name")); + + buildButtonBar().ok(e -> ok()).cancel(e -> cancel()).build(); + + wFileNameField = + new LabelComboVar( + variables, + shell, + BaseMessages.getString(PKG, "DbImpactInputMeta.FileNameField.Label"), + BaseMessages.getString(PKG, "DbImpactInputDialog.FileNameField.Tooltip")); + PropsUi.setLook(wFileNameField); + FormData fdFileNameField = new FormData(); + fdFileNameField.left = new FormAttachment(0, 0); + fdFileNameField.top = new FormAttachment(wSpacer, margin); + fdFileNameField.bottom = new FormAttachment(wOk, -2 * margin); + fdFileNameField.right = new FormAttachment(100, 0); + wFileNameField.setLayoutData(fdFileNameField); + + getData(); + + focusTransformName(); + BaseDialog.defaultShellHandling(shell, c -> ok(), c -> cancel()); + + return transformName; + } + + /** Copy information from the meta-data input to the dialog fields. */ + public void getData() { + wFileNameField.setText(Const.NVL(input.getFileNameField(), "")); + + try { + String[] fieldNames = + pipelineMeta.getPrevTransformFields(getVariables(), transformName).getFieldNames(); + wFileNameField.setItems(fieldNames); + } catch (Exception e) { + new ErrorDialog(shell, "Error", "Error getting field names from previous transforms", e); + } + } + + private void cancel() { + transformName = null; + input.setChanged(changed); + dispose(); + } + + private void ok() { + if (Utils.isEmpty(wTransformName.getText())) { + return; + } + + transformName = wTransformName.getText(); // return value + + getInfo(input); + + dispose(); + } + + private void getInfo(DbImpactInputMeta meta) { + meta.setFileNameField(wFileNameField.getText()); + } +} diff --git a/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputMeta.java b/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputMeta.java new file mode 100644 index 0000000000..b97d076720 --- /dev/null +++ b/plugins/transforms/dbimpact/src/main/java/org/apache/hop/pipeline/transforms/dbimpact/input/DbImpactInputMeta.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hop.pipeline.transforms.dbimpact.input; + +import lombok.Getter; +import lombok.Setter; +import org.apache.hop.core.annotations.Transform; +import org.apache.hop.core.exception.HopTransformException; +import org.apache.hop.core.row.IRowMeta; +import org.apache.hop.core.row.RowMetaBuilder; +import org.apache.hop.core.variables.IVariables; +import org.apache.hop.metadata.api.HopMetadataProperty; +import org.apache.hop.metadata.api.IHopMetadataProvider; +import org.apache.hop.pipeline.transform.BaseTransformMeta; +import org.apache.hop.pipeline.transform.TransformMeta; + +@Transform( + id = "DbImpactInput", + image = "ui/images/database.svg", + name = "i18n::DbImpactInputMeta.Name", + description = "i18n::DbImpactInputMeta.Description", + categoryDescription = "i18n:org.apache.hop.pipeline.transform:BaseTransform.Category.Input", + keywords = "i18n::DbImpactInputMeta.keyword", + documentationUrl = "/pipeline/transforms/dbimpactinput.html") +@Getter +@Setter +public class DbImpactInputMeta extends BaseTransformMeta { + + @HopMetadataProperty( + key = "filename-field", + injectionKeyDescription = "DbImpactInputMeta.FileNameField.Label") + private String fileNameField; + + public DbImpactInputMeta() {} + + public DbImpactInputMeta(DbImpactInputMeta m) { + this(); + this.fileNameField = m.fileNameField; + } + + @Override + public DbImpactInputMeta clone() { + return new DbImpactInputMeta(this); + } + + @Override + public void getFields( + IRowMeta rowMeta, + String name, + IRowMeta[] info, + TransformMeta nextTransform, + IVariables variables, + IHopMetadataProvider metadataProvider) + throws HopTransformException { + + // Always start with an empty row + // + rowMeta.clear(); + + // Reflect the output from the DatabaseImpact class + // + RowMetaBuilder rowBuilder = new RowMetaBuilder(); + rowBuilder + .addString("Type") + .addString("PipelineName") + .addString("PipelineFileName") + .addString("TransformName") + .addString("DatabaseName") + .addString("DatabaseTable") + .addString("TableField") + .addString("FieldName") + .addString("FieldOrigin") + .addString("SQL") + .addString("Remark"); + rowMeta.addRowMeta(rowBuilder.build()); + } + + @Override + public boolean supportsErrorHandling() { + return true; + } +} diff --git a/plugins/transforms/dbimpact/src/main/resources/org/apache/hop/pipeline/transforms/dbimpact/input/messages/messages_en_US.properties b/plugins/transforms/dbimpact/src/main/resources/org/apache/hop/pipeline/transforms/dbimpact/input/messages/messages_en_US.properties new file mode 100644 index 0000000000..b6ee30cd03 --- /dev/null +++ b/plugins/transforms/dbimpact/src/main/resources/org/apache/hop/pipeline/transforms/dbimpact/input/messages/messages_en_US.properties @@ -0,0 +1,25 @@ +# +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# + +DbImpactInputMeta.Name = Database Impact Input +DbImpactInputMeta.Description = Retrieve database impact analyses from pipelines +DbImpactInputMeta.keyword=Lineage,Impact,Database,DB +DbImpactInputMeta.FileNameField.Label=File name field +DbImpactInputDialog.FileNameField.Tooltip = The name of the field in the transform input which will contain the \ + filenames to analyze the database impact for. diff --git a/plugins/transforms/dbimpact/src/main/resources/version.xml b/plugins/transforms/dbimpact/src/main/resources/version.xml new file mode 100644 index 0000000000..6be576acae --- /dev/null +++ b/plugins/transforms/dbimpact/src/main/resources/version.xml @@ -0,0 +1,20 @@ + + + +${project.version} \ No newline at end of file diff --git a/plugins/transforms/pom.xml b/plugins/transforms/pom.xml index f481695049..2d604730b8 100644 --- a/plugins/transforms/pom.xml +++ b/plugins/transforms/pom.xml @@ -53,6 +53,7 @@ databasejoin databaselookup datagrid + dbimpact dbproc delay delete