diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataProductPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataProductPreProcessor.java index 3331c33ba5..005d580caa 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataProductPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataProductPreProcessor.java @@ -12,7 +12,6 @@ import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.utils.AtlasPerfMetrics; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,8 +23,7 @@ import static org.apache.atlas.repository.util.AtlasEntityUtils.mapOf; public class DataProductPreProcessor extends AbstractDomainPreProcessor { - private static final Logger LOG = LoggerFactory.getLogger(DomainPreProcessor.class); - private AtlasEntityHeader parentDomain; + private static final Logger LOG = LoggerFactory.getLogger(DataProductPreProcessor.class); private EntityMutationContext context; public DataProductPreProcessor(AtlasTypeRegistry typeRegistry, EntityGraphRetriever entityRetriever, AtlasGraph graph, EntityGraphMapper entityGraphMapper) { @@ -36,7 +34,7 @@ public DataProductPreProcessor(AtlasTypeRegistry typeRegistry, EntityGraphRetrie public void processAttributes(AtlasStruct entityStruct, EntityMutationContext context, EntityMutations.EntityOperation operation) throws AtlasBaseException { //Handle name & qualifiedName - if (operation == EntityMutations.EntityOperation.CREATE && LOG.isDebugEnabled()) { + if (LOG.isDebugEnabled()) { LOG.debug("DataProductPreProcessor.processAttributes: pre processing {}, {}", entityStruct.getAttribute(QUALIFIED_NAME), operation); } @@ -73,6 +71,11 @@ private void processUpdateProduct(AtlasEntity entity, AtlasVertex vertex) throws String VertexQName = vertex.getProperty(QUALIFIED_NAME, String.class); String productName = (String) entity.getAttribute(NAME); String parentDomainQualifiedName = (String) entity.getAttribute(PARENT_DOMAIN_QN); + + if (StringUtils.isEmpty(parentDomainQualifiedName)){ + parentDomainQualifiedName = vertex.getProperty(PARENT_DOMAIN_QN, String.class); + } + String productVertexName = vertex.getProperty(NAME, String.class); if (!productVertexName.equals(productName)) { @@ -103,7 +106,7 @@ private void productExists(String productName, String parentDomainQualifiedName) Map bool = new HashMap<>(); - if (parentDomain != null) { + if (StringUtils.isNotEmpty(parentDomainQualifiedName)) { mustClauseList.add(mapOf("term", mapOf("parentDomainQualifiedName", parentDomainQualifiedName))); } else { List mustNotClauseList = new ArrayList(); diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DomainPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DomainPreProcessor.java index 8c1ca3e4f2..d89d698ece 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DomainPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DomainPreProcessor.java @@ -23,7 +23,6 @@ import org.apache.atlas.exception.AtlasBaseException; import org.apache.atlas.model.instance.AtlasEntity; import org.apache.atlas.model.instance.AtlasEntityHeader; -import org.apache.atlas.model.instance.AtlasObjectId; import org.apache.atlas.model.instance.AtlasStruct; import org.apache.atlas.model.instance.EntityMutations; import org.apache.atlas.repository.graphdb.AtlasGraph; @@ -34,7 +33,6 @@ import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.utils.AtlasPerfMetrics; import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,7 +45,6 @@ public class DomainPreProcessor extends AbstractDomainPreProcessor { private static final Logger LOG = LoggerFactory.getLogger(DomainPreProcessor.class); - private AtlasEntityHeader parentDomain; private EntityGraphMapper entityGraphMapper; private EntityMutationContext context; @@ -98,7 +95,7 @@ private static String createQualifiedName(String parentDomainQualifiedName) { if (StringUtils.isNotEmpty(parentDomainQualifiedName)) { return parentDomainQualifiedName + "/domain/" + getUUID(); } else{ - return "default/domain" + "/" + getUUID(); + return "default/domain/" + getUUID(); } } @@ -106,6 +103,11 @@ private void processUpdateDomain(AtlasEntity entity, AtlasVertex vertex) throws AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("processUpdateDomain"); String vertexQName = vertex.getProperty(QUALIFIED_NAME, String.class); String parentDomainQualifiedName = (String) entity.getAttribute(PARENT_DOMAIN_QN); + + if (StringUtils.isEmpty(parentDomainQualifiedName)) { + parentDomainQualifiedName = vertex.getProperty(PARENT_DOMAIN_QN, String.class); + } + String domainName = (String) entity.getAttribute(NAME); String domainVertexName = vertex.getProperty(NAME, String.class);