Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre Processors for Domain Move #2876

Merged
merged 8 commits into from
Mar 13, 2024
Merged

Pre Processors for Domain Move #2876

merged 8 commits into from
Mar 13, 2024

Conversation

PRATHAM2002-DS
Copy link

Change description

Description here

Type of change

  • Bug fix (fixes an issue)
  • New feature (adds functionality)

Related issues

Fix #1

Checklists

Development

  • Lint rules pass locally
  • Application changes have been tested thoroughly
  • Automated tests covering modified code pass

Security

  • Security impact of change has been considered
  • Code follows company security practices and guidelines

Code review

  • Pull request has a descriptive title and context useful to a reviewer. Screenshots or screencasts are attached as necessary
  • "Ready for review" label attached and reviewers assigned
  • Changes have been reviewed by at least one other contributor
  • Pull request linked to task tracker where applicable

@@ -32,6 +32,12 @@ public class PreProcessorUtils {
public static final String GLOSSARY_TERM_REL_TYPE = "AtlasGlossaryTermAnchor";
public static final String GLOSSARY_CATEGORY_REL_TYPE = "AtlasGlossaryCategoryAnchor";

//DataMesh models constants
public static final String DATA_PRODUCT_TYPE = "DataProduct";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think DATA_PRODUCT_TYPE from common/src/main/java/org/apache/atlas/repository/Constants.java can be reused

import static org.apache.atlas.repository.util.AtlasEntityUtils.mapOf;

public class DataProductPreProcessor extends AbstractDomainPreProcessor {
private static final Logger LOG = LoggerFactory.getLogger(DomainPreProcessor.class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataProductPreProcessor.class

public void processAttributes(AtlasStruct entityStruct, EntityMutationContext context,
EntityMutations.EntityOperation operation) throws AtlasBaseException {
//Handle name & qualifiedName
if (operation == EntityMutations.EntityOperation.UPDATE && LOG.isDebugEnabled()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove EntityOperation.UPDATE condition

}


AtlasEntity entity = (AtlasEntity) entityStruct;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap these statements as well inside if (operation == EntityMutations.EntityOperation.UPDATE)

these will no be called when not required

setParent(entity, context);

if (operation == EntityMutations.EntityOperation.UPDATE) {
processUpdateDomain(entity, vertex);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

processUpdateDomain -> processUpdateProduct

String currentDomainQualifiedName = (String) currentDomainHeader.getAttribute(QUALIFIED_NAME);

String newDomainQualifiedName = (String) parentDomain.getAttribute(QUALIFIED_NAME);
String superDomainQualifiedName = (String) parentDomain.getAttribute(SUPER_DOMAIN_QN);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superDomainQualifiedName -> newSuperDomainQualifiedName

isAuthorized(currentDomainHeader, parentDomain);

processMoveDataProductToAnotherDomain(entity, currentDomainQualifiedName, newDomainQualifiedName, vertexQnName, superDomainQualifiedName);
entity.setAttribute(PARENT_DOMAIN_QN, newDomainQualifiedName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line os redundant

boolean exists = false;
try {
List mustClauseList = new ArrayList();
mustClauseList.add(mapOf("term", mapOf("__typeName.keyword", DATA_DOMAIN_ENTITY_TYPE)));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DATA_DOMAIN_ENTITY_TYPE -> I think it should be DATA_PRODUCT_ENTITY_TYPE

public void processAttributes(AtlasStruct entityStruct, EntityMutationContext context,
EntityMutations.EntityOperation operation) throws AtlasBaseException {
//Handle name & qualifiedName
if (operation == EntityMutations.EntityOperation.UPDATE && LOG.isDebugEnabled()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

operation == EntityMutations.EntityOperation.UPDATE -> not needed

entityStruct.getAttribute(QUALIFIED_NAME), operation);
}

this.context = context;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enclose this within if (operation == EntityMutations.EntityOperation.UPDATE) {

@nikhilbonte21 nikhilbonte21 merged commit 2d810e3 into beta Mar 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants