Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 b888ade51 -> ebf0aa22d


ATLAS-2871: Import Transforms: Apply entity-specific transforms before 
attribute-specific.

Signed-off-by: Ashutosh Mestry <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/ebf0aa22
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/ebf0aa22
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/ebf0aa22

Branch: refs/heads/branch-0.8
Commit: ebf0aa22d8674a9838bad8ed3ff511086d035634
Parents: b888ade
Author: Ashutosh Mestry <[email protected]>
Authored: Wed Sep 12 21:54:40 2018 -0700
Committer: Ashutosh Mestry <[email protected]>
Committed: Wed Sep 12 21:56:37 2018 -0700

----------------------------------------------------------------------
 .../repository/impexp/ImportTransforms.java     | 30 ++++++++++++--------
 1 file changed, 18 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/ebf0aa22/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
 
b/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
index 24c5d7b..72b684b 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/impexp/ImportTransforms.java
@@ -96,31 +96,37 @@ public class ImportTransforms {
             return entity;
         }
 
+        applyEntitySpecific(entity, entityTransforms);
+
+        applyAttributeSpecific(entity, entityTransforms);
+
+        return entity;
+    }
+
+    private void applyAttributeSpecific(AtlasEntity entity, Map<String, 
List<ImportTransformer>> entityTransforms) throws AtlasBaseException {
         for (Map.Entry<String, List<ImportTransformer>> entry : 
entityTransforms.entrySet()) {
             String                   attributeName  = entry.getKey();
             List<ImportTransformer> attrTransforms = entry.getValue();
 
-            if(attributeName.equals(ALL_ATTRIBUTES)) {
-                for (ImportTransformer attrTransform : attrTransforms) {
-                    attrTransform.apply(entity);
-                }
-
-                continue;
-            }
-
             if (!entity.hasAttribute(attributeName)) {
                 continue;
             }
 
-            Object transformedValue = entity.getAttribute(attributeName);
+            Object attributeValue = entity.getAttribute(attributeName);
             for (ImportTransformer attrTransform : attrTransforms) {
-                transformedValue = attrTransform.apply(transformedValue);
+                attributeValue = attrTransform.apply(attributeValue);
             }
 
-            entity.setAttribute(attributeName, transformedValue);
+            entity.setAttribute(attributeName, attributeValue);
         }
+    }
 
-        return entity;
+    private void applyEntitySpecific(AtlasEntity entity, Map<String, 
List<ImportTransformer>> entityTransforms) throws AtlasBaseException {
+        if(entityTransforms.containsKey(ALL_ATTRIBUTES)) {
+            for (ImportTransformer attrTransform : 
entityTransforms.get(ALL_ATTRIBUTES)) {
+                attrTransform.apply(entity);
+            }
+        }
     }
 
     private ImportTransforms() {

Reply via email to