You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2021/07/14 09:35:56 UTC

[incubator-hop] branch master updated: HOP-3035 - Added attribute to @HopMetadataProperty to exclude specific fields from MDI transform. Added property to TableOutputMeta to manage the exclusion of 2 attributes from MDI.

This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop.git


The following commit(s) were added to refs/heads/master by this push:
     new a65d9d7  HOP-3035 - Added attribute to @HopMetadataProperty to exclude specific fields from MDI transform. Added property to TableOutputMeta to manage the exclusion of 2 attributes from MDI.
     new ba46263  Merge pull request #935 from sramazzina/HOP-3035
a65d9d7 is described below

commit a65d9d7b031e7ccfe26b173aa9b1593caea05cdb
Author: sergio.ramazzina <se...@serasoft.it>
AuthorDate: Tue Jul 13 23:47:30 2021 +0200

    HOP-3035 - Added attribute to @HopMetadataProperty to exclude specific fields from MDI transform.
    Added property to TableOutputMeta to manage the exclusion of 2 attributes from MDI.
---
 .../hop/metadata/api/HopMetadataProperty.java      |  3 ++
 .../hop/core/injection/bean/BeanInjectionInfo.java | 18 ++++++++----
 .../hop/core/injection/bean/BeanLevelInfo.java     |  2 +-
 .../transforms/metainject/MetaInjectDialog.java    | 34 ++++++++++++----------
 .../metainject/messages/messages_it_IT.properties  |  9 ++++--
 .../transforms/tableoutput/TableOutputMeta.java    | 18 +++++++-----
 6 files changed, 53 insertions(+), 31 deletions(-)

diff --git a/core/src/main/java/org/apache/hop/metadata/api/HopMetadataProperty.java b/core/src/main/java/org/apache/hop/metadata/api/HopMetadataProperty.java
index fd7774e..9c6343a 100644
--- a/core/src/main/java/org/apache/hop/metadata/api/HopMetadataProperty.java
+++ b/core/src/main/java/org/apache/hop/metadata/api/HopMetadataProperty.java
@@ -64,6 +64,9 @@ public @interface HopMetadataProperty {
   /** @return The default value to return for a non-existing boolean value */
   boolean defaultBoolean() default false;
 
+  /** @return Prevents the item to be considered in injection. Default value: false  */
+  boolean isExcludedFromInjection() default false;
+
   /**
    * @return The metadata key for this property. Don't specify any key if you want this to be the
    *     same as key();
diff --git a/engine/src/main/java/org/apache/hop/core/injection/bean/BeanInjectionInfo.java b/engine/src/main/java/org/apache/hop/core/injection/bean/BeanInjectionInfo.java
index 5df2126..5f67dcb 100644
--- a/engine/src/main/java/org/apache/hop/core/injection/bean/BeanInjectionInfo.java
+++ b/engine/src/main/java/org/apache/hop/core/injection/bean/BeanInjectionInfo.java
@@ -199,7 +199,7 @@ public class BeanInjectionInfo<Meta extends Object> {
           List<BeanLevelInfo> path = new ArrayList<>(parentPath);
           path.add(fieldLevelInfo);
           path.add(childLevelInfo);
-          Property p = new Property(injectionKey, injectionKeyDescription, injectionGroupKey, path);
+          Property p = new Property(injectionKey, injectionKeyDescription, injectionGroupKey, path, property.isExcludedFromInjection());
           group.properties.add(p);
           properties.put(injectionKey, p);
         } else {
@@ -229,7 +229,7 @@ public class BeanInjectionInfo<Meta extends Object> {
               if (isChildlessClass(childFieldType, childProperty)) {
                 Property p =
                     new Property(
-                        childInjectionKey, childInjectionKeyDescription, injectionGroupKey, path);
+                        childInjectionKey, childInjectionKeyDescription, injectionGroupKey, path, property.isExcludedFromInjection());
                 group.properties.add(p);
                 properties.put(childInjectionKey, p);
               } else {
@@ -248,7 +248,7 @@ public class BeanInjectionInfo<Meta extends Object> {
           //
           List<BeanLevelInfo> path = new ArrayList<>(parentPath);
           path.add(fieldLevelInfo);
-          Property p = new Property(injectionKey, injectionKeyDescription, "", path);
+          Property p = new Property(injectionKey, injectionKeyDescription, "", path, property.isExcludedFromInjection());
           rootGroup.properties.add(p);
           properties.put(injectionKey, p);
         } else {
@@ -430,7 +430,7 @@ public class BeanInjectionInfo<Meta extends Object> {
 
     Property prop =
         new Property(
-            propertyName, injectionKeyDescription, metaInj.group(), leaf.createCallStack());
+            propertyName, injectionKeyDescription, metaInj.group(), leaf.createCallStack(), false);
     properties.put(prop.key, prop);
     Group gr = groupsMap.get(metaInj.group());
     if (gr == null) {
@@ -487,12 +487,16 @@ public class BeanInjectionInfo<Meta extends Object> {
     private final String groupKey;
     protected final List<BeanLevelInfo> path;
     public final int pathArraysCount;
+    private final boolean isExcludedFromInjection;
+
+    public Property(String key, String description, String groupKey, List<BeanLevelInfo> path, boolean isExcludedFromInjection) {
 
-    public Property(String key, String description, String groupKey, List<BeanLevelInfo> path) {
       this.key = key;
       this.description = description;
       this.groupKey = groupKey;
       this.path = path;
+      this.isExcludedFromInjection = isExcludedFromInjection;
+
       int ac = 0;
       for (BeanLevelInfo level : path) {
         if (level.dim != BeanLevelInfo.DIMENSION.NONE) {
@@ -527,6 +531,10 @@ public class BeanInjectionInfo<Meta extends Object> {
       return path.get(path.size() - 1).leafClass;
     }
 
+    public boolean isExcludedFromInjection() {
+      return isExcludedFromInjection;
+    }
+
     public boolean hasMatch(String filterString) {
       if (StringUtils.isEmpty(filterString)) {
         return true;
diff --git a/engine/src/main/java/org/apache/hop/core/injection/bean/BeanLevelInfo.java b/engine/src/main/java/org/apache/hop/core/injection/bean/BeanLevelInfo.java
index bb0db5e..8d115ed 100644
--- a/engine/src/main/java/org/apache/hop/core/injection/bean/BeanLevelInfo.java
+++ b/engine/src/main/java/org/apache/hop/core/injection/bean/BeanLevelInfo.java
@@ -140,7 +140,7 @@ public class BeanLevelInfo<Meta extends Object> {
       }
       if (f.isSynthetic() || f.isEnumConstant() || Modifier.isStatic(f.getModifiers())) {
         // fields can't contain real data with such modifier
-        throw new RuntimeException("Wrong modifier for anotated field " + f);
+        throw new RuntimeException("Wrong modifier for annotated field " + f);
       }
       BeanLevelInfo leaf = new BeanLevelInfo();
       leaf.parent = this;
diff --git a/plugins/transforms/metainject/src/main/java/org/apache/hop/pipeline/transforms/metainject/MetaInjectDialog.java b/plugins/transforms/metainject/src/main/java/org/apache/hop/pipeline/transforms/metainject/MetaInjectDialog.java
index 61eb331..2a8e17d 100644
--- a/plugins/transforms/metainject/src/main/java/org/apache/hop/pipeline/transforms/metainject/MetaInjectDialog.java
+++ b/plugins/transforms/metainject/src/main/java/org/apache/hop/pipeline/transforms/metainject/MetaInjectDialog.java
@@ -926,26 +926,30 @@ public class MetaInjectDialog extends BaseTransformDialog implements ITransformD
       }
 
       List<BeanInjectionInfo.Property> propertyList = gr.getProperties();
+
       for (BeanInjectionInfo.Property property : propertyList) {
         if (!property.hasMatch(filterString)) {
           continue;
         }
 
-        TreeItem treeItem = new TreeItem(rootGroup ? transformItem : groupItem, SWT.NONE);
-        treeItem.setText(Const.NVL(property.getTranslatedDescription(), property.getKey()));
-
-        TargetTransformAttribute target =
-            new TargetTransformAttribute(transformMeta.getName(), property.getKey(), !rootGroup);
-        treeItemTargetMap.put(treeItem, target);
-
-        SourceTransformField source = targetSourceMapping.get(target);
-        if (source != null) {
-          hasUsedKeys = true;
-          treeItem.setText(
-              1,
-              Const.NVL(
-                  source.getTransformName() == null ? CONST_VALUE : source.getTransformName(), ""));
-          treeItem.setText(2, Const.NVL(source.getField(), ""));
+        if (!property.isExcludedFromInjection()) {
+          TreeItem treeItem = new TreeItem(rootGroup ? transformItem : groupItem, SWT.NONE);
+          treeItem.setText(Const.NVL(property.getTranslatedDescription(), property.getKey()));
+
+          TargetTransformAttribute target =
+              new TargetTransformAttribute(transformMeta.getName(), property.getKey(), !rootGroup);
+          treeItemTargetMap.put(treeItem, target);
+
+          SourceTransformField source = targetSourceMapping.get(target);
+          if (source != null) {
+            hasUsedKeys = true;
+            treeItem.setText(
+                1,
+                Const.NVL(
+                    source.getTransformName() == null ? CONST_VALUE : source.getTransformName(),
+                    ""));
+            treeItem.setText(2, Const.NVL(source.getField(), ""));
+          }
         }
       }
     }
diff --git a/plugins/transforms/metainject/src/main/resources/org/apache/hop/pipeline/transforms/metainject/messages/messages_it_IT.properties b/plugins/transforms/metainject/src/main/resources/org/apache/hop/pipeline/transforms/metainject/messages/messages_it_IT.properties
index 988d0b0..60e9dd6 100644
--- a/plugins/transforms/metainject/src/main/resources/org/apache/hop/pipeline/transforms/metainject/messages/messages_it_IT.properties
+++ b/plugins/transforms/metainject/src/main/resources/org/apache/hop/pipeline/transforms/metainject/messages/messages_it_IT.properties
@@ -22,7 +22,7 @@ MetaInjectDialog.ErrorLoadingPipeline.DialogMessage=Errore durante il caricament
 MetaInjectDialog.Edit.Button=Modifica
 MetaInjectMeta.ReferencedObject.Description=Modello della pipeline
 MetaInjectDialog.RadioRepByReference.Tooltip=Specifica la pipeline per riferimento, consentendo alla pipeline del repository di esserespostata e rinominata senza conseguenza.
-MetaInjectDialog.Shell.Title=Iniezione dei metadati ETL
+MetaInjectDialog.Shell.Title=ETL metadata injection
 MetaInjectDialog.Select.Button=Seleziona
 MetaInjectDialog.TransformName.Label=Nome del transform
 MetaInjectDialog.TargetFile.Label=File di destinazione opzionale (ktr dopo l''iniezione)
@@ -64,4 +64,9 @@ MetaInjectDialog.SourceTransform.Label=Transform sorgente da cui leggere (opzion
 MetaInjectDialog.Button.EnterMapping=Inserisci mappatura
 MetaInjectDialog.InjectTab.TabTitle=Metadati da Iniettare
 MetaInjectDialog.OptionsTab.TabTitle=Opzioni
-MetaInjectDialog.InjectTab.CLickTree.Label=Seleziona un elemento sotto per dichiarare una sorgente da iniettare: 
\ No newline at end of file
+MetaInjectDialog.InjectTab.CLickTree.Label=Seleziona un elemento per dichiarare una sorgente da iniettare:
+MetaInjectDialog.InjectTab.FilterString.Label=Filtro:
+MetaInjectDialog.InjectTab.FilterString.ExpandAll=Espandi tutti i transforms
+MetaInjectDialog.InjectTab.FilterString.CollapseAll=Collassa tutti i transforms
+MetaInjectDialog.SourceFieldDialog.Title=Campi sorgente
+MetaInjectDialog.SourceFieldDialog.Label=Campo:
diff --git a/plugins/transforms/tableoutput/src/main/java/org/apache/hop/pipeline/transforms/tableoutput/TableOutputMeta.java b/plugins/transforms/tableoutput/src/main/java/org/apache/hop/pipeline/transforms/tableoutput/TableOutputMeta.java
index 3a4eb99..84c91fd 100644
--- a/plugins/transforms/tableoutput/src/main/java/org/apache/hop/pipeline/transforms/tableoutput/TableOutputMeta.java
+++ b/plugins/transforms/tableoutput/src/main/java/org/apache/hop/pipeline/transforms/tableoutput/TableOutputMeta.java
@@ -111,11 +111,13 @@ public class TableOutputMeta extends BaseTransformMeta
       injectionKeyDescription = "TableOutputMeta.Injection.PartitioningField.Field")
   private String partitioningField;
 
-  @HopMetadataProperty(key = "partitioning_daily")
-  private Boolean partitioningDaily;
+  @HopMetadataProperty(key = "partitioning_daily",
+          isExcludedFromInjection = true)
+  private boolean partitioningDaily;
 
-  @HopMetadataProperty(key = "partitioning_monthly")
-  private Boolean partitioningMonthly;
+  @HopMetadataProperty(key = "partitioning_monthly",
+          isExcludedFromInjection = true)
+  private boolean partitioningMonthly;
 
   @HopMetadataProperty(
       injectionKey = "PARTITION_DATA_PER",
@@ -229,22 +231,22 @@ public class TableOutputMeta extends BaseTransformMeta
   }
 
   /** @return Returns the partitioningDaily. */
-  public Boolean isPartitioningDaily() {
+  public boolean isPartitioningDaily() {
     return partitioningDaily;
   }
 
   /** @param partitioningDaily The partitioningDaily to set. */
-  public void setPartitioningDaily(Boolean partitioningDaily) {
+  public void setPartitioningDaily(boolean partitioningDaily) {
     this.partitioningDaily = partitioningDaily;
   }
 
   /** @return Returns the partitioningMontly. */
-  public Boolean isPartitioningMonthly() {
+  public boolean isPartitioningMonthly() {
     return partitioningMonthly;
   }
 
   /** @param partitioningMontly The partitioningMontly to set. */
-  public void setPartitioningMonthly(Boolean partitioningMontly) {
+  public void setPartitioningMonthly(boolean partitioningMontly) {
     this.partitioningMonthly = partitioningMontly;
   }