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-165 | Add support for bulk in data models #3588

Open
wants to merge 88 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 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
2b7b7fe
Merge branch 'master' into task/CJ-157
aarshi0301 Sep 30, 2024
9ff1a60
beautify condition
aarshi0301 Sep 30, 2024
95e81fe
cache model info
aarshi0301 Sep 30, 2024
7cfc4a0
add null check
aarshi0301 Oct 1, 2024
b599511
add null check
aarshi0301 Oct 1, 2024
a67c2a6
Bulk entity
aarshi0301 Oct 1, 2024
568e0ab
cache model and version info for attributes
aarshi0301 Oct 1, 2024
86a6501
cache model and version info for entities
aarshi0301 Oct 1, 2024
64b60bf
fix code for bulk
aarshi0301 Oct 1, 2024
36d8752
Merge branch 'master' into task/CJ-165
aarshi0301 Oct 1, 2024
fc182ec
remove bulk processor
aarshi0301 Oct 1, 2024
ecb8311
add modelInfo
aarshi0301 Oct 1, 2024
11a2607
dont craete entity when attribute is created
aarshi0301 Oct 1, 2024
3c9e821
moinor enhancements
aarshi0301 Oct 1, 2024
e9cb412
create cache for model entity
aarshi0301 Oct 2, 2024
58de282
cache model entity at the time of creation
aarshi0301 Oct 2, 2024
f2622ab
load entity from vertex
aarshi0301 Oct 2, 2024
22a2378
load entity from context
aarshi0301 Oct 2, 2024
c65b3b5
fix constructor
aarshi0301 Oct 2, 2024
11c746e
change order of retrieval
aarshi0301 Oct 2, 2024
207b221
update attribute type
aarshi0301 Oct 2, 2024
feb133c
Update updated array
aarshi0301 Oct 3, 2024
5d571cc
fix exclusion
aarshi0301 Oct 3, 2024
d4b6dd9
get vertex in case data models
aarshi0301 Oct 3, 2024
235cfe5
update naming convention
aarshi0301 Oct 3, 2024
9e27694
fix names
aarshi0301 Oct 3, 2024
b4d225e
add associations
aarshi0301 Oct 3, 2024
82c35ab
fix qualidfiedName pattern
aarshi0301 Oct 4, 2024
3523f78
Merge branch 'master' into task/CJ-165
aarshi0301 Oct 4, 2024
e84cfa1
fix error code
aarshi0301 Oct 8, 2024
73fcd35
Fix constants name
aarshi0301 Oct 8, 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
45 changes: 45 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,49 @@ public final class Constants {

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

/***
* DataModel
*/
public static final String MODEL_ENTITY = "ModelEntity";
public static final String MODEL_ATTRIBUTE = "ModelAttribute";
public static final String MODEL_DATA_MODEL = "ModelDataModel";
public static final String MODEL_VERSION = "ModelVersion";
public static final String MODEL_ENTITY_ASSOCIATION = "ModelEntityAssociation";
public static final String MODEL_ATTRIBUTE_ASSOCIATION = "ModelAttributeAssociation";
public static final String MODEL_QUALIFIED_NAME_PATTERN = "modelVersionAgnosticQualifiedName";
public static final String MODEL_NAMESPACE = "modelNamespace";
public static final String MODEL_EXPIRED_AT_SYSTEM_DATE = "modelExpiredAtSystemDate";
public static final String MODEL_EXPIRED_AT_BUSINESS_DATE = "modelExpiredAtBusinessDate";
public static final String MODEL_SYSTEM_DATE = "modelSystemDate";
public static final String MODEL_BUSINESS_DATE = "modelBusinessDate";
public static final String MODEL_MODEL_VERSION_RELATION = "model_data_model_model_versions";
public static final String RELATED_DATA_MODEL = "modelDataModel";
public static final String RELATED_MODEL_VERSIONS = "modelVersions";
public static final String MODEL_VERSIONS_MODEL_VERSION_ENTITY_RELATION = "model_versions_model_version_entities";
public static final String MODEL_VERSION_ENTITIES = "modelVersionEntities";
public static final String MODEL_ENTITY_MAPPED_FROM_ENTITIES = "modelEntityMappedFromEntities";
public static final String MODEL_ENTITY_MAPPED_TO_ENTITIES = "modelEntityMappedToEntities";
public static final String MODEL_ENTITY_MODEL_ATTRIBUTES_RELATION = "model_attribute_entities_model_entity_attributes";
public static final String MODEL_ENTITY_ATTRIBUTES = "modelEntityAttributes";
public static final String MODEL_ATTRIBUTE_ENTITIES = "modelAttributeEntities";
public static final String MODEL_ATTRIBUTE_MAPPED_TO_ATTRIBUTES = "modelAttributeMappedToAttributes";
public static final String MODEL_ATTRIBUTE_MAPPED_FROM_ATTRIBUTES = "modelAttributeMappedFromAttributes";
public static final String MODEL_ENTITY_RELATED_FROM_ENTITIES = "modelEntityRelatedFromEntities";
public static final String MODEL_ENTITY_RELATED_TO_ENTITIES = "modelEntityRelatedToEntities";
public static final String MODEL_ATTRIBUTE_RELATED_FROM_ATTRIBUTES = "modelAttributeRelatedFromAttributes";
public static final String MODEL_ATTRIBUTE_RELATED_TO_ATTRIBUTES = "modelAttributeRelatedToAttributes";
public static String MODEL_ENTITY_ASSOCIATION_TO = "modelEntityAssociationTo";
public static String MODEL_ENTITY_ASSOCIATION_FROM = "modelEntityAssociationFrom";
public static String MODEL_ATTRIBUTE_ASSOCIATION_FROM = "modelAttributeAssociationFrom";
public static String MODEL_ATTRIBUTE_ASSOCIATION_TO = "modelAttributeAssociationTo";








/**
* 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 @@ -376,6 +419,8 @@ public final class Constants {
public static final String NON_COMPLIANT_ASSET_POLICY_GUIDS = "nonCompliantAssetPolicyGUIDs";
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", "modelEntity {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", "modelAgnosticQualifiedName is mandatory for modelEntity/modelAttribute"),
NO_TYPE_EXISTS_FOR_QUALIFIED_NAME_PREFIX (400,"ATLAS-400-00-119", "No modelEntity/modelAttribute exists for modelAgnosticQualifiedName : {0}"),
NAME_NAMESPACE_NOT_EXIST (400, "ATLAS-400-00-120", "name/namespace are mandatory for modelEntity/modelAttribute"),
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 Down Expand Up @@ -103,8 +105,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.MODEL_ENTITY) ||
entity.getTypeName().equals(Constants.MODEL_ATTRIBUTE)){

String qualifiedNamePrefix = (String) entity.getAttributes().get(Constants.MODEL_QUALIFIED_NAME_PATTERN);
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 +191,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 +517,15 @@ private void processDynamicAttributes(AtlasEntity entity) throws AtlasBaseExcept
}
}
}

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

}
}
Loading
Loading