Skip to content

Commit

Permalink
resolved PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PRATHAM2002-DS committed Apr 24, 2024
1 parent 2b74979 commit b055d62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -103,7 +106,7 @@ private void productExists(String productName, String parentDomainQualifiedName)


Map<String, Object> bool = new HashMap<>();
if (parentDomain != null) {
if (StringUtils.isNotEmpty(parentDomainQualifiedName)) {
mustClauseList.add(mapOf("term", mapOf("parentDomainQualifiedName", parentDomainQualifiedName)));
} else {
List mustNotClauseList = new ArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -98,14 +95,19 @@ private static String createQualifiedName(String parentDomainQualifiedName) {
if (StringUtils.isNotEmpty(parentDomainQualifiedName)) {
return parentDomainQualifiedName + "/domain/" + getUUID();
} else{
return "default/domain" + "/" + getUUID();
return "default/domain/" + getUUID();
}
}

private void processUpdateDomain(AtlasEntity entity, AtlasVertex vertex) throws AtlasBaseException {
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);

Expand Down

0 comments on commit b055d62

Please sign in to comment.