Skip to content

Commit

Permalink
initial metadata conversion and XML cleanup. apache#2012
Browse files Browse the repository at this point in the history
  • Loading branch information
bamaer committed Oct 31, 2024
1 parent 0188439 commit dfa21f6
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ private Object[] getLoggingInfo(IRowMeta inputRowMeta, Object[] inputRowData) th
for (int i = 0; i < inputRowMeta.size(); i++) {
row[i] = inputRowData[i]; // no data is changed, clone is not needed here.
}
for (int i = 0, index = inputRowMeta.size(); i < meta.getFieldName().length; i++, index++) {
for (int i = 0, index = inputRowMeta.size(); i < meta.getFields().size(); i++, index++) {
Calendar cal;

int argnr = 0;

String argument = meta.getFieldArgument()[i];
String argument = meta.getFields().get(i).getFieldArgument();
if (StringUtils.isEmpty(argument)) {
argument = getPipeline().getPipelineMeta().getName();
} else {
argument = resolve(argument);
}

switch (meta.getFieldType()[i]) {
switch (meta.getFields().get(i).getFieldType()) {
case TYPE_SYSTEM_INFO_PIPELINE_DATE_FROM:
{
Date previousSuccess = getPreviousPipelineSuccess(argument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class GetLoggingInfoDialog extends BaseTransformDialog {
private static final Class<?> PKG =
GetLoggingInfo.class; // for i18n purposes, needed by Translator2!!

private Text wTransformname;
private Text wTransformName;

private TableView wFields;

Expand Down Expand Up @@ -116,35 +116,35 @@ public void modifyText(ModifyEvent e) {
isReceivingInput = !pipelineMeta.findPreviousTransforms(transformMeta).isEmpty();

// Transform name line
Label wlTransformname = new Label(shell, SWT.RIGHT);
Label wlTransformName = new Label(shell, SWT.RIGHT);
wlTransformName.setText(BaseMessages.getString(PKG, "System.TransformName.Label"));
wlTransformName.setToolTipText(BaseMessages.getString(PKG, "System.TransformName.Tooltip"));
PropsUi.setLook(wlTransformname);
PropsUi.setLook(wlTransformName);
FormData fdlTransformname = new FormData();
fdlTransformname.left = new FormAttachment(0, 0);
fdlTransformname.right = new FormAttachment(middle, -margin);
fdlTransformname.top = new FormAttachment(0, margin);
wlTransformname.setLayoutData(fdlTransformname);
wTransformname = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTransformname.setText(transformName);
PropsUi.setLook(wTransformname);
wTransformname.addModifyListener(lsMod);
wlTransformName.setLayoutData(fdlTransformname);
wTransformName = new Text(shell, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
wTransformName.setText(transformName);
PropsUi.setLook(wTransformName);
wTransformName.addModifyListener(lsMod);
FormData fdTransformname = new FormData();
fdTransformname.left = new FormAttachment(middle, 0);
fdTransformname.top = new FormAttachment(0, margin);
fdTransformname.right = new FormAttachment(100, 0);
wTransformname.setLayoutData(fdTransformname);
wTransformName.setLayoutData(fdTransformname);

Label wlFields = new Label(shell, SWT.NONE);
wlFields.setText(BaseMessages.getString(PKG, "GetLoggingInfoDialog.Fields.Label"));
PropsUi.setLook(wlFields);
FormData fdlFields = new FormData();
fdlFields.left = new FormAttachment(0, 0);
fdlFields.top = new FormAttachment(wTransformname, margin);
fdlFields.top = new FormAttachment(wTransformName, margin);
wlFields.setLayoutData(fdlFields);

final int FieldsCols = 3;
final int FieldsRows = input.getFieldName().length;
final int FieldsRows = input.getFields().size();

final String[] functionDesc = new String[GetLoggingInfoTypes.values().length - 1];
for (int i = 1; i < GetLoggingInfoTypes.values().length; i++) {
Expand Down Expand Up @@ -214,21 +214,22 @@ public void widgetSelected(SelectionEvent e) {

/** Copy information from the meta-data input to the dialog fields. */
public void getData() {
wTransformname.setText(transformName);
wTransformName.setText(transformName);

for (int i = 0; i < input.getFieldName().length; i++) {
for (int i = 0; i < input.getFields().size(); i++) {
TableItem item = wFields.table.getItem(i);

item.setText(1, Const.NVL(input.getFieldName()[i], ""));
item.setText(2, Const.NVL(input.getFieldType()[i].lookupDescription(), ""));
item.setText(3, Const.NVL(input.getFieldArgument()[i], ""));
item.setText(1, Const.NVL(input.getFields().get(i).getFieldName(), ""));
GetLoggingInfoTypes type = input.getFields().get(i).getFieldType();
item.setText(2, Const.NVL(type.getDescription(), ""));
item.setText(3, Const.NVL(input.getFields().get(i).getFieldArgument(), ""));
}

wFields.setRowNums();
wFields.optWidth(true);

wTransformname.selectAll();
wTransformname.setFocus();
wTransformName.selectAll();
wTransformName.setFocus();
}

private void cancel() {
Expand All @@ -238,7 +239,7 @@ private void cancel() {
}

private void ok() {
if (StringUtils.isEmpty(wTransformname.getText())) {
if (StringUtils.isEmpty(wTransformName.getText())) {
return;
}

Expand All @@ -256,15 +257,19 @@ private void ok() {

private void getInfo(GetLoggingInfoMeta in) throws HopException {

transformName = wTransformname.getText(); // return value
transformName = wTransformName.getText(); // return value
int count = wFields.nrNonEmpty();
in.allocate(count);

in.getFields().clear();

for (int i = 0; i < count; i++) {
TableItem item = wFields.getNonEmpty(i);
in.getFieldName()[i] = item.getText(1);
in.getFieldType()[i] = GetLoggingInfoTypes.getTypeFromString(item.getText(2));
in.getFieldArgument()[i] = item.getText(3);
GetLoggingInfoField field = new GetLoggingInfoField();
field.setFieldName(item.getText(1));
GetLoggingInfoTypes type = GetLoggingInfoTypes.getTypeFromString(item.getText(2));
field.setFieldType(type);
field.setFieldArgument(item.getText(3));
in.getFields().add(field);
}
}

Expand All @@ -276,7 +281,7 @@ private void preview() {

PipelineMeta previewMeta =
PipelinePreviewFactory.generatePreviewPipeline(
metadataProvider, oneMeta, wTransformname.getText());
metadataProvider, oneMeta, wTransformName.getText());

EnterNumberDialog numberDialog =
new EnterNumberDialog(
Expand All @@ -292,7 +297,7 @@ private void preview() {
shell,
variables,
previewMeta,
new String[] {wTransformname.getText()},
new String[] {wTransformName.getText()},
new int[] {previewSize});
progressDialog.open();

Expand All @@ -317,9 +322,9 @@ private void preview() {
shell,
variables,
SWT.NONE,
wTransformname.getText(),
progressDialog.getPreviewRowsMeta(wTransformname.getText()),
progressDialog.getPreviewRows(wTransformname.getText()),
wTransformName.getText(),
progressDialog.getPreviewRowsMeta(wTransformName.getText()),
progressDialog.getPreviewRows(wTransformName.getText()),
loggingText);
prd.open();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.apache.hop.neo4j.transforms.loginfo;

import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import org.apache.hop.metadata.api.HopMetadataProperty;

@Getter
@Setter
public class GetLoggingInfoField {

public GetLoggingInfoField() {}

public GetLoggingInfoField(
String fieldName, GetLoggingInfoTypes fieldType, String fieldArgument) {
this.fieldName = fieldName;
this.fieldType = fieldType;
this.fieldArgument = fieldArgument;
}

public GetLoggingInfoField(GetLoggingInfoField f) {
this.fieldName = f.getFieldName();
this.fieldType = f.getFieldType();
this.fieldArgument = f.getFieldArgument();
}

@HopMetadataProperty(key = "name", injectionKey = "FIELD_NAME")
private String fieldName;

@HopMetadataProperty(
key = "type",
injectionKey = "FIELD_TYPE",
injectionConverter = GetLoggingInfoMetaInjectionTypeConverter.class)
private GetLoggingInfoTypes fieldType;

@HopMetadataProperty(key = "argument", injectionKey = "FIELD_ARGUMENT")
private String fieldArgument;

@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
GetLoggingInfoField that = (GetLoggingInfoField) obj;
return fieldType.equals(that.fieldType)
&& fieldName.equals(that.fieldName)
&& fieldArgument.equals(that.fieldArgument);
}

@Override
public int hashCode() {
return Objects.hash(fieldName, fieldType, fieldArgument);
}

public GetLoggingInfoTypes getFieldType() {
return fieldType;
}

public void setFieldType(GetLoggingInfoTypes fieldType) {
this.fieldType = fieldType;
}
}
Loading

0 comments on commit dfa21f6

Please sign in to comment.