From 8185bfe0ad29e6b6831159220f56cb1d7a50a7a1 Mon Sep 17 00:00:00 2001 From: Bichitra Kumar Sahoo <32828151+bichitra95@users.noreply.github.com> Date: Wed, 24 Apr 2024 12:33:11 +0530 Subject: [PATCH] Add asset guid in DataContract asset and minor fixes --- .../v2/preprocessor/contract/ContractPreProcessor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/contract/ContractPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/contract/ContractPreProcessor.java index b1c2474d41..e86c38514b 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/contract/ContractPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/contract/ContractPreProcessor.java @@ -33,7 +33,8 @@ public class ContractPreProcessor extends AbstractContractPreProcessor { private static final Logger LOG = LoggerFactory.getLogger(ContractPreProcessor.class); public static final String ATTR_VERSION = "dataContractVersion"; - public static final String REL_ATTR_GOVERNED_ASSET = "dataContractAsset"; + public static final String ATTR_ASSET_GUID = "dataContractAssetGuid"; + public static final String REL_ATTR_GOVERNED_ASSET = "dataContractAssetLatest"; public static final String REL_ATTR_GOVERNED_ASSET_CERTIFIED = "dataContractAssetCertified"; public static final String REL_ATTR_PREVIOUS_VERSION = "dataContractPreviousVersion"; public static final String ASSET_ATTR_HAS_CONTRACT = "hasContract"; @@ -127,7 +128,7 @@ private void processCreateContract(AtlasEntity entity, EntityMutationContext con } else if (isEqualContract(contractString, (String) currentVersionEntity.getAttribute(ATTR_CONTRACT))) { // No change in contract, metadata changed updateExistingVersion(context, entity, currentVersionEntity); - return; + newVersionNumber = currentVersionNumber; } else { // contract changed (metadata might/not changed). Create new version. newVersionNumber = currentVersionNumber + 1; @@ -142,6 +143,7 @@ private void processCreateContract(AtlasEntity entity, EntityMutationContext con } entity.setAttribute(QUALIFIED_NAME, String.format("%s/V%s", contractQName, newVersionNumber)); entity.setAttribute(ATTR_VERSION, newVersionNumber); + entity.setAttribute(ATTR_ASSET_GUID, associatedAsset.getEntity().getGuid()); entity.setRelationshipAttribute(REL_ATTR_GOVERNED_ASSET, getAtlasObjectId(associatedAsset.getEntity())); if (Objects.equals(entity.getAttribute(ATTR_CERTIFICATE_STATUS), DataContract.STATUS.VERIFIED.name()) ) { entity.setRelationshipAttribute(REL_ATTR_GOVERNED_ASSET_CERTIFIED, getAtlasObjectId(associatedAsset.getEntity()));