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

CJ-157 | Phase 2| Handle CUD operation for DMEntity and DMAttributes #3526

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
917e2cf
Move methods in util class
aarshi0301 Sep 11, 2024
70360ac
expose model atttributes
aarshi0301 Sep 13, 2024
b1ba720
Expose attribute and entity prepocessors
aarshi0301 Sep 13, 2024
70ee325
Add DMEntity Preprocessor
aarshi0301 Sep 13, 2024
b048c7b
remove updated entities from context
aarshi0301 Sep 13, 2024
6d988f2
Update removeContext util
aarshi0301 Sep 15, 2024
2514116
Base class for ModelPreprocessors
aarshi0301 Sep 15, 2024
608b508
Error code declaration
aarshi0301 Sep 16, 2024
6168274
Expose helpers in abstarct class
aarshi0301 Sep 16, 2024
3a80492
Data model error codes
aarshi0301 Sep 16, 2024
5cdd751
Updates for Entity and attribute
aarshi0301 Sep 16, 2024
dd288c7
Merge branch 'master' into task/CJ-157
aarshi0301 Sep 16, 2024
91a405a
expose preprocessors
aarshi0301 Sep 16, 2024
46c51d3
Add constants for data model atttributes
aarshi0301 Sep 18, 2024
746fb12
add data model error codes
aarshi0301 Sep 18, 2024
6fefc02
add util to fetch latet entity/attribute from prefix
aarshi0301 Sep 18, 2024
aee983a
graph util to fetch latest entity/attribute
aarshi0301 Sep 18, 2024
08b5215
unset expired dates
aarshi0301 Sep 18, 2024
c32dc1f
Expose constats and errors for data model
aarshi0301 Sep 19, 2024
9834366
update discovery flow for data models
aarshi0301 Sep 19, 2024
59f7c44
Update entity/attribute discover method
aarshi0301 Sep 19, 2024
9365f32
Format dm constants
aarshi0301 Sep 19, 2024
bf54b02
fix names in utils
aarshi0301 Sep 19, 2024
d7891e1
update preprocessors for update entity/attribute flow
aarshi0301 Sep 19, 2024
d5e696c
fix qualifiedName nomenclature
aarshi0301 Sep 19, 2024
9a1153e
update constants
aarshi0301 Sep 19, 2024
6f76993
update DM entity flow
aarshi0301 Sep 19, 2024
f24168e
Update create logic for dmEntity and dmAttribute
aarshi0301 Sep 19, 2024
4b3b692
Fix conditions
aarshi0301 Sep 20, 2024
01ba178
CU flow for entity. attribute
aarshi0301 Sep 22, 2024
fceac96
Merge branch 'master' into task/CJ-157
aarshi0301 Sep 22, 2024
5db6ebd
fix date formattings
aarshi0301 Sep 23, 2024
90751fb
set allowed relationships for entity and attributes
aarshi0301 Sep 23, 2024
2054ede
Handle mapping for relationshipAttributes
aarshi0301 Sep 23, 2024
5b5ef42
remove relation
aarshi0301 Sep 24, 2024
14cb2bb
append/Remove mappings
aarshi0301 Sep 24, 2024
a347851
Handle mapping updates
aarshi0301 Sep 24, 2024
98da136
update DM constants
aarshi0301 Sep 24, 2024
126da8e
associations for entity and attribute
aarshi0301 Sep 24, 2024
d79cc0d
expose association preprocessors
aarshi0301 Sep 24, 2024
bc9ce34
add nam property while entity is created
aarshi0301 Sep 24, 2024
2c2c283
add name attributes in preprocessors
aarshi0301 Sep 24, 2024
5b252bf
fix preprocessor name
aarshi0301 Sep 24, 2024
fea4ce4
Remove name mappings
aarshi0301 Sep 25, 2024
227bc87
Remove from context
aarshi0301 Sep 25, 2024
f22e1bd
Add utils
aarshi0301 Sep 25, 2024
f24a0ac
remove from context
aarshi0301 Sep 25, 2024
ca1188b
update entity name
aarshi0301 Sep 25, 2024
17c3a6e
Improve formatting
aarshi0301 Sep 26, 2024
8a4a1cb
Add atlas code
aarshi0301 Sep 26, 2024
9317350
Update abstarctModel Preprocessor
aarshi0301 Sep 26, 2024
3bb6e19
fix name
aarshi0301 Sep 26, 2024
05667f0
Update name
aarshi0301 Sep 26, 2024
7edfbfa
ModelResponse API
aarshi0301 Sep 26, 2024
ba43684
update method signaure
aarshi0301 Sep 27, 2024
d345c49
Expose REST API for models
aarshi0301 Sep 27, 2024
467a647
add safe check
aarshi0301 Sep 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions common/src/main/java/org/apache/atlas/repository/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,28 @@ public final class Constants {

public static String[] PROCESS_EDGE_LABELS = {PROCESS_OUTPUTS, PROCESS_INPUTS};

/***
* DataModel
*/

public static final String ATLAS_DM_ENTITY_TYPE = "DMEntity";

public static final String ATLAS_DM_ATTRIBUTE_TYPE = "DMAttribute";
public static final String ATLAS_DM_DATA_MODEL = "DMDataModel";

public static final String ATLAS_DM_VERSION_TYPE = "DMVersion";

public static final String ATLAS_DM_ENTITY_ASSOCIATION_TYPE= "DMEntityAssociation";
public static final String ATLAS_DM_ATTRIBUTE_ASSOCIATION_TYPE= "DMAttributeAssociation";

public static final String ATLAS_DM_QUALIFIED_NAME_PREFIX = "dMQualifiedNamePrefix";
public static final String ATLAS_DM_NAMESPACE = "dMDataModelNamespace";
public static final String ATLAS_DM_EXPIRED_AT_SYSTEM_DATE = "dMDataModelExpiredAtSystemDate";
public static final String ATLAS_DM_EXPIRED_AT_BUSINESS_DATE = "dMDataModelExpiredAtBusinessDate";
public static final String ATLAS_DM_SYSTEM_DATE = "dMDataModelSystemDate";
public static final String ATLAS_DM_BUSINESS_DATE = "dMDataModelBusinessDate";


/**
* The homeId field is used when saving into Atlas a copy of an object that is being imported from another
* repository. The homeId will be set to a String that identifies the other repository. The specific format
Expand Down Expand Up @@ -374,6 +396,8 @@ public final class Constants {
public static final String ASSET_POLICY_GUIDS = "assetPolicyGUIDs";
public static final String ASSET_POLICIES_COUNT = "assetPoliciesCount";



/*
* All supported file-format extensions for Bulk Imports through file upload
*/
Expand Down
11 changes: 9 additions & 2 deletions intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,15 @@ public enum AtlasErrorCode {
TASK_TYPE_NOT_SUPPORTED(400, "ATLAS-400-00-112", "Task type {0} is not supported"),

PERSONA_POLICY_ASSETS_LIMIT_EXCEEDED(400, "ATLAS-400-00-113", "Exceeded limit of maximum allowed assets across policies for a Persona: Limit: {0}, assets: {1}"),
ADMIN_LIST_SHOULD_NOT_BE_EMPTY(400, "ATLAS-400-00-114", "Admin list should not be empty for type {0}");

ADMIN_LIST_SHOULD_NOT_BE_EMPTY(400, "ATLAS-400-00-114", "Admin list should not be empty for type {0}"),
DATA_MODEL_VERSION_NOT_EXIST(400, "ATLAS-400-00-115", "Model version {0} does not exist"),
DATA_ENTITY_NOT_EXIST(400, "ATLAS-400-00-116", "DataEntity {0} does not exist"),
DATA_MODEL_NOT_EXIST(400, "ATLAS-400-00-117", "DataModel {0} does not exist"),
QUALIFIED_NAME_PREFIX_NOT_EXIST(400, "ATLAS-400-00-118", "dMQualifiedNamePrefix is mandatory for DMEntity/DMAttribute"),
NO_TYPE_EXISTS_FOR_QUALIFIED_NAME_PREFIX (400,"ATLAS-400-00-119", "No DMEntity/DMAttribute exists for dMQualifiedNamePrefix : {0}"),
NAME_NAMESPACE_NOT_EXIST (400, "ATLAS-400-00-120", "name/namespace are mandatory for DMEntity/DMAttribute"),
QUALIFIED_NAME_PREFIX_OR_TYPE_NOT_FOUND(400, "ATLAS-400-00-121", "qualifiedName/entityType are mandatory"),
INVALID_ENTITY_TYPE(400, "ATLAS-400-00-122", "Invalid entity type");
private String errorCode;
private String errorMessage;
private Response.Status httpCode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import org.apache.atlas.model.instance.AtlasEntity;
import org.apache.atlas.model.instance.AtlasObjectId;
import org.apache.atlas.model.instance.AtlasStruct;
import org.apache.atlas.repository.Constants;
import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.EntityGraphDiscovery;
import org.apache.atlas.repository.store.graph.EntityGraphDiscoveryContext;
import org.apache.atlas.repository.store.graph.EntityResolver;
Expand All @@ -40,9 +42,11 @@
import org.apache.atlas.type.TemplateToken;
import org.apache.atlas.utils.AtlasEntityUtil;
import org.apache.atlas.utils.AtlasPerfMetrics.MetricRecorder;
import org.apache.hadoop.util.Time;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
Expand Down Expand Up @@ -103,8 +107,36 @@ public void validateAndNormalize(AtlasEntity entity) throws AtlasBaseException {

validateLabels(entity.getLabels());


type.validateValue(entity, entity.getTypeName(), messages);



// DMEntity and DMAttributeType are requested for update
// by dMQualifiedNamePrefix which is not a unique attribute
// This can return multiple entity/attribute that match this prefix vale
// we have to return latest entity/attribute
if (entity.getTypeName().equals(Constants.ATLAS_DM_ENTITY_TYPE) ||
entity.getTypeName().equals(Constants.ATLAS_DM_ATTRIBUTE_TYPE)){

String qualifiedNamePrefix = (String) entity.getAttributes().get(Constants.ATLAS_DM_QUALIFIED_NAME_PREFIX);
if (qualifiedNamePrefix.isEmpty()){
throw new AtlasBaseException(AtlasErrorCode.QUALIFIED_NAME_PREFIX_NOT_EXIST);
}
// AtlasVertex vertex = AtlasGraphUtilsV2.findLatestEntityAttributeVerticesByType(entity.getTypeName(), qualifiedNamePrefix);
AtlasVertex vertex= discoveryContext.getResolvedEntityVertex(entity.getGuid());
if (vertex == null) {
// no entity exists with this qualifiedName, set qualifiedName and let entity be created
entity.setAttribute(Constants.QUALIFIED_NAME, qualifiedNamePrefix + "_" + RequestContext.get().getRequestTime());
return;
}

// if guidFromVertex is found let entity be updated
entity.setGuid(AtlasGraphUtilsV2.getIdFromVertex(vertex));
type.getNormalizedValue(entity);
return;
}

if (!messages.isEmpty()) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_CRUD_INVALID_PARAMS, messages);
}
Expand Down Expand Up @@ -161,6 +193,8 @@ protected void discover() throws AtlasBaseException {
throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "found null entity");
}

validateAttributesForDataModel(entity);

processDynamicAttributes(entity);

walkEntityGraph(entity);
Expand Down Expand Up @@ -485,4 +519,15 @@ private void processDynamicAttributes(AtlasEntity entity) throws AtlasBaseExcept
}
}
}

private void validateAttributesForDataModel(AtlasEntity entity) throws AtlasBaseException {
if (entity.getTypeName().equals(Constants.ATLAS_DM_ENTITY_TYPE) ||
entity.getTypeName().equals(Constants.ATLAS_DM_ATTRIBUTE_TYPE)) {
if (entity.getAttributes().get(Constants.ATLAS_DM_QUALIFIED_NAME_PREFIX) == null ||
entity.getAttributes().get(Constants.ATLAS_DM_QUALIFIED_NAME_PREFIX) == "") {
throw new AtlasBaseException(AtlasErrorCode.QUALIFIED_NAME_PREFIX_NOT_EXIST);
}
}

}
}
Loading
Loading