Skip to content

Commit

Permalink
XML cleanup, annotation based metadata and overall cleanup. apache#2012
Browse files Browse the repository at this point in the history
  • Loading branch information
bamaer committed Oct 31, 2024
1 parent dfa21f6 commit 9c56e3d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private Object[] getLoggingInfo(IRowMeta inputRowMeta, Object[] inputRowData) th
argument = resolve(argument);
}

switch (meta.getFields().get(i).getFieldType()) {
switch (GetLoggingInfoTypes.getTypeFromString(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 @@ -220,8 +220,7 @@ public void getData() {
TableItem item = wFields.table.getItem(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(2, Const.NVL(input.getFields().get(i).getFieldType(), ""));
item.setText(3, Const.NVL(input.getFields().get(i).getFieldArgument(), ""));
}

Expand Down Expand Up @@ -266,8 +265,7 @@ private void getInfo(GetLoggingInfoMeta in) throws HopException {
TableItem item = wFields.getNonEmpty(i);
GetLoggingInfoField field = new GetLoggingInfoField();
field.setFieldName(item.getText(1));
GetLoggingInfoTypes type = GetLoggingInfoTypes.getTypeFromString(item.getText(2));
field.setFieldType(type);
field.setFieldType(item.getText(2));
field.setFieldArgument(item.getText(3));
in.getFields().add(field);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,17 @@ public class GetLoggingInfoField {

public GetLoggingInfoField() {}

public GetLoggingInfoField(
String fieldName, GetLoggingInfoTypes fieldType, String fieldArgument) {
public GetLoggingInfoField(String fieldName, String 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 = "type", injectionKey = "FIELD_TYPE")
private String fieldType;

@HopMetadataProperty(key = "argument", injectionKey = "FIELD_ARGUMENT")
private String fieldArgument;
Expand All @@ -50,12 +40,4 @@ public boolean equals(Object obj) {
public int hashCode() {
return Objects.hash(fieldName, fieldType, fieldArgument);
}

public GetLoggingInfoTypes getFieldType() {
return fieldType;
}

public void setFieldType(GetLoggingInfoTypes fieldType) {
this.fieldType = fieldType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class GetLoggingInfoMeta extends BaseTransformMeta<GetLoggingInfo, GetLog

public GetLoggingInfoMeta() {
super(); // allocate BaseTransformMeta
fields = new ArrayList<>();
}

@Override
Expand All @@ -78,22 +79,22 @@ public void setDefault() {

GetLoggingInfoField f1 = new GetLoggingInfoField();
f1.setFieldName("startOfPipelineDelta");
f1.setFieldType(GetLoggingInfoTypes.TYPE_SYSTEM_INFO_PIPELINE_DATE_FROM);
f1.setFieldType(GetLoggingInfoTypes.TYPE_SYSTEM_INFO_PIPELINE_DATE_FROM.getCode());
fields.add(f1);

GetLoggingInfoField f2 = new GetLoggingInfoField();
f2.setFieldName("");
f2.setFieldType(GetLoggingInfoTypes.TYPE_SYSTEM_INFO_PIPELINE_DATE_TO);
f2.setFieldName("endOfPipelineDelta");
f2.setFieldType(GetLoggingInfoTypes.TYPE_SYSTEM_INFO_PIPELINE_DATE_TO.getCode());
fields.add(f2);

GetLoggingInfoField f3 = new GetLoggingInfoField();
f3.setFieldName("startOfWorkflowDelta");
f3.setFieldType(GetLoggingInfoTypes.TYPE_SYSTEM_INFO_WORKFLOW_DATE_TO);
f3.setFieldType(GetLoggingInfoTypes.TYPE_SYSTEM_INFO_WORKFLOW_DATE_TO.getCode());
fields.add(f3);

GetLoggingInfoField f4 = new GetLoggingInfoField();
f4.setFieldName("endOfWorkflowDelta");
f4.setFieldType(GetLoggingInfoTypes.TYPE_SYSTEM_INFO_WORKFLOW_DATE_TO);
f4.setFieldType(GetLoggingInfoTypes.TYPE_SYSTEM_INFO_WORKFLOW_DATE_TO.getCode());
fields.add(f4);
}

Expand All @@ -109,7 +110,7 @@ public void getFields(
for (int i = 0; i < fields.size(); i++) {
IValueMeta v;

switch (fields.get(i).getFieldType()) {
switch (GetLoggingInfoTypes.getTypeFromString(fields.get(i).getFieldType())) {
case TYPE_SYSTEM_INFO_PIPELINE_DATE_FROM,
TYPE_SYSTEM_INFO_PIPELINE_DATE_TO,
TYPE_SYSTEM_INFO_WORKFLOW_DATE_FROM,
Expand Down Expand Up @@ -143,7 +144,7 @@ public void check(
// See if we have input streams leading to this transform!
int nrRemarks = remarks.size();
for (int i = 0; i < fields.size(); i++) {
if (fields.get(i).getFieldType().ordinal()
if (GetLoggingInfoTypes.getTypeFromString(fields.get(i).getFieldType()).ordinal()
<= GetLoggingInfoTypes.TYPE_SYSTEM_INFO_NONE.ordinal()) {
CheckResult cr =
new CheckResult(
Expand Down

0 comments on commit 9c56e3d

Please sign in to comment.