Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
b6a664df
Commit
b6a664df
authored
Aug 24, 2018
by
Sarath Subramanian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2836: Remove redundant encoding of vertex property keys
parent
70e10cc0
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
239 additions
and
188 deletions
+239
-188
Constants.java
.../src/main/java/org/apache/atlas/repository/Constants.java
+38
-37
AtlasStructType.java
.../src/main/java/org/apache/atlas/type/AtlasStructType.java
+10
-2
EntityLineageService.java
...java/org/apache/atlas/discovery/EntityLineageService.java
+3
-1
GraphHelper.java
...n/java/org/apache/atlas/repository/graph/GraphHelper.java
+55
-56
DeleteHandlerV1.java
...ache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
+10
-9
SoftDeleteHandlerV1.java
.../atlas/repository/store/graph/v1/SoftDeleteHandlerV1.java
+13
-13
AtlasClassificationDefStoreV2.java
...ository/store/graph/v2/AtlasClassificationDefStoreV2.java
+3
-1
AtlasEntityChangeNotifier.java
.../repository/store/graph/v2/AtlasEntityChangeNotifier.java
+5
-4
AtlasEntityDefStoreV2.java
...tlas/repository/store/graph/v2/AtlasEntityDefStoreV2.java
+1
-1
AtlasGraphUtilsV2.java
...he/atlas/repository/store/graph/v2/AtlasGraphUtilsV2.java
+39
-4
AtlasRelationshipDefStoreV2.java
...epository/store/graph/v2/AtlasRelationshipDefStoreV2.java
+1
-1
AtlasRelationshipStoreV2.java
...s/repository/store/graph/v2/AtlasRelationshipStoreV2.java
+11
-7
AtlasStructDefStoreV2.java
...tlas/repository/store/graph/v2/AtlasStructDefStoreV2.java
+1
-1
EntityGraphMapper.java
...he/atlas/repository/store/graph/v2/EntityGraphMapper.java
+47
-49
EntityGraphRetriever.java
...atlas/repository/store/graph/v2/EntityGraphRetriever.java
+2
-2
No files found.
common/src/main/java/org/apache/atlas/repository/Constants.java
View file @
b6a664df
...
...
@@ -22,6 +22,8 @@ import org.apache.atlas.ApplicationProperties;
import
org.apache.atlas.AtlasException
;
import
org.apache.commons.configuration.Configuration
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasStructType
.
AtlasAttribute
.
encodePropertyKey
;
/**
* Repository Constants.
*
...
...
@@ -34,52 +36,52 @@ public final class Constants {
public
static
final
String
INTERNAL_PROPERTY_KEY_PREFIX
=
"__"
;
public
static
final
String
RELATIONSHIP_PROPERTY_KEY_PREFIX
=
"_r"
;
public
static
final
String
GUID_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"guid"
;
public
static
final
String
RELATIONSHIP_GUID_PROPERTY_KEY
=
RELATIONSHIP_PROPERTY_KEY_PREFIX
+
GUID_PROPERTY_KEY
;
public
static
final
String
GUID_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"guid"
)
;
public
static
final
String
RELATIONSHIP_GUID_PROPERTY_KEY
=
encodePropertyKey
(
RELATIONSHIP_PROPERTY_KEY_PREFIX
+
GUID_PROPERTY_KEY
)
;
/**
* Entity type name property key.
*/
public
static
final
String
ENTITY_TYPE_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"typeName"
;
public
static
final
String
ENTITY_TYPE_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"typeName"
)
;
public
static
final
String
TYPE_NAME_INTERNAL
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"internal"
;
/**
* Entity type's super types property key.
*/
public
static
final
String
SUPER_TYPES_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"superTypeNames"
;
public
static
final
String
SUPER_TYPES_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"superTypeNames"
)
;
/**
* Full-text for the entity for enabling full-text search.
*/
public
static
final
String
ENTITY_TEXT_PROPERTY_KEY
=
"entityText"
;
public
static
final
String
ENTITY_TEXT_PROPERTY_KEY
=
encodePropertyKey
(
"entityText"
)
;
/**
* Properties for type store graph.
*/
public
static
final
String
TYPE_CATEGORY_PROPERTY_KEY
=
getTypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.category"
);
public
static
final
String
VERTEX_TYPE_PROPERTY_KEY
=
getTypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type"
);
public
static
final
String
TYPENAME_PROPERTY_KEY
=
getTypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.name"
);
public
static
final
String
TYPEDESCRIPTION_PROPERTY_KEY
=
getTypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.description"
);
public
static
final
String
TYPEVERSION_PROPERTY_KEY
=
getTypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.version"
);
public
static
final
String
TYPEOPTIONS_PROPERTY_KEY
=
getTypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.options"
);
public
static
final
String
TYPE_CATEGORY_PROPERTY_KEY
=
get
Encoded
TypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.category"
);
public
static
final
String
VERTEX_TYPE_PROPERTY_KEY
=
get
Encoded
TypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type"
);
public
static
final
String
TYPENAME_PROPERTY_KEY
=
get
Encoded
TypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.name"
);
public
static
final
String
TYPEDESCRIPTION_PROPERTY_KEY
=
get
Encoded
TypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.description"
);
public
static
final
String
TYPEVERSION_PROPERTY_KEY
=
get
Encoded
TypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.version"
);
public
static
final
String
TYPEOPTIONS_PROPERTY_KEY
=
get
Encoded
TypePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"type.options"
);
// relationship def constants
public
static
final
String
RELATIONSHIPTYPE_END1_KEY
=
"endDef1"
;
public
static
final
String
RELATIONSHIPTYPE_END2_KEY
=
"endDef2"
;
public
static
final
String
RELATIONSHIPTYPE_CATEGORY_KEY
=
"relationshipCategory"
;
public
static
final
String
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
=
"tagPropagation"
;
public
static
final
String
RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY
=
"blockedPropagatedClassifications"
;
public
static
final
String
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
=
encodePropertyKey
(
"tagPropagation"
)
;
public
static
final
String
RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY
=
encodePropertyKey
(
"blockedPropagatedClassifications"
)
;
/**
* Trait names property key and index name.
*/
public
static
final
String
TRAIT_NAMES_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"traitNames"
;
public
static
final
String
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"propagatedTraitNames"
;
public
static
final
String
TRAIT_NAMES_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"traitNames"
)
;
public
static
final
String
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"propagatedTraitNames"
)
;
public
static
final
String
VERSION_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"version"
;
public
static
final
String
STATE_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"state"
;
public
static
final
String
CREATED_BY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"createdBy"
;
public
static
final
String
MODIFIED_BY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"modifiedBy"
;
public
static
final
String
VERSION_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"version"
)
;
public
static
final
String
STATE_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"state"
)
;
public
static
final
String
CREATED_BY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"createdBy"
)
;
public
static
final
String
MODIFIED_BY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"modifiedBy"
)
;
/**
* The homeId field is used when saving into Atlas a copy of an object that is being imported from another
...
...
@@ -91,7 +93,7 @@ public final class Constants {
* An object with a non-null homeId is a copy of an object mastered by a different repository and the object
* should only be updated via the notifications and calls from Open Metadata Repository Services.
*/
public
static
final
String
HOME_ID_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"homeId"
;
public
static
final
String
HOME_ID_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"homeId"
)
;
/**
* The isProxy field is used when saving into Atlas a proxy of an entity - i.e. it is not a whole entity, but
...
...
@@ -99,12 +101,11 @@ public final class Constants {
* The isProxy field will be set to true if the entity is a proxy. The field is used during retrieval of an
* entity (proxy) from Atlas to indicate that the entity does not contain full entity detail.
*/
public
static
final
String
IS_PROXY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"isProxy"
;
public
static
final
String
IS_PROXY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"isProxy"
)
;
public
static
final
String
TIMESTAMP_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"timestamp"
;
public
static
final
String
TIMESTAMP_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"timestamp"
)
;
public
static
final
String
MODIFICATION_TIMESTAMP_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"modificationTimestamp"
;
public
static
final
String
MODIFICATION_TIMESTAMP_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"modificationTimestamp"
);
/**
* search backing index name.
...
...
@@ -141,19 +142,19 @@ public final class Constants {
public
static
final
String
ATTRIBUTE_NAME_VERSION
=
"version"
;
public
static
final
String
TEMP_STRUCT_NAME_PREFIX
=
"__tempQueryResultStruct"
;
public
static
final
String
CLASSIFICATION_ENTITY_GUID
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"entityGuid"
;
public
static
final
String
CLASSIFICATION_ENTITY_STATUS
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"entityStatus"
;
public
static
final
String
CLASSIFICATION_VALIDITY_PERIODS_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"validityPeriods"
;
public
static
final
String
CLASSIFICATION_VERTEX_PROPAGATE_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"propagate"
;
public
static
final
String
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"removePropagations"
;
public
static
final
String
CLASSIFICATION_VERTEX_NAME_KEY
=
TYPE_NAME_PROPERTY_KEY
;
public
static
final
String
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"name"
;
public
static
final
String
CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"isPropagated"
;
public
static
final
String
CLASSIFICATION_ENTITY_GUID
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"entityGuid"
)
;
public
static
final
String
CLASSIFICATION_ENTITY_STATUS
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"entityStatus"
)
;
public
static
final
String
CLASSIFICATION_VALIDITY_PERIODS_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"validityPeriods"
)
;
public
static
final
String
CLASSIFICATION_VERTEX_PROPAGATE_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"propagate"
)
;
public
static
final
String
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"removePropagations"
)
;
public
static
final
String
CLASSIFICATION_VERTEX_NAME_KEY
=
encodePropertyKey
(
TYPE_NAME_PROPERTY_KEY
)
;
public
static
final
String
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"name"
)
;
public
static
final
String
CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"isPropagated"
)
;
public
static
final
String
CLASSIFICATION_EDGE_STATE_PROPERTY_KEY
=
STATE_PROPERTY_KEY
;
public
static
final
String
CLASSIFICATION_LABEL
=
"classifiedAs"
;
public
static
final
String
TERM_ASSIGNMENT_LABEL
=
"r:AtlasGlossarySemanticAssignment"
;
public
static
final
String
ATTRIBUTE_INDEX_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"index"
;
public
static
final
String
ATTRIBUTE_KEY_PROPERTY_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"key"
;
public
static
final
String
ATTRIBUTE_INDEX_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"index"
)
;
public
static
final
String
ATTRIBUTE_KEY_PROPERTY_KEY
=
encodePropertyKey
(
INTERNAL_PROPERTY_KEY_PREFIX
+
"key"
)
;
public
static
final
String
VERTEX_ID_IN_IMPORT_KEY
=
"__vIdInImport"
;
public
static
final
String
EDGE_ID_IN_IMPORT_KEY
=
"__eIdInImport"
;
...
...
@@ -161,7 +162,7 @@ public final class Constants {
private
Constants
()
{
}
private
static
String
getTypePropertyKey
(
String
defaultKey
)
{
private
static
String
get
Encoded
TypePropertyKey
(
String
defaultKey
)
{
try
{
Configuration
configuration
=
ApplicationProperties
.
get
();
...
...
@@ -171,9 +172,9 @@ public final class Constants {
return
defaultKey
.
replaceAll
(
"\\."
,
"_"
);
}
return
defaultKey
;
return
encodePropertyKey
(
defaultKey
)
;
}
catch
(
AtlasException
e
)
{
return
defaultKey
;
return
encodePropertyKey
(
defaultKey
)
;
}
}
}
intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
View file @
b6a664df
...
...
@@ -642,6 +642,14 @@ public class AtlasStructType extends AtlasType {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_ATTRIBUTE
,
attrName
,
structDef
.
getName
());
}
public
String
getQualifiedAttributePropertyKey
(
String
attrName
)
throws
AtlasBaseException
{
if
(
allAttributes
.
containsKey
(
attrName
))
{
return
allAttributes
.
get
(
attrName
).
getVertexPropertyName
();
}
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_ATTRIBUTE
,
attrName
,
structDef
.
getName
());
}
AtlasEntityType
getReferencedEntityType
(
AtlasType
type
)
{
if
(
type
instanceof
AtlasArrayType
)
{
type
=
((
AtlasArrayType
)
type
).
getElementType
();
...
...
@@ -853,12 +861,12 @@ public class AtlasStructType extends AtlasType {
return
attrName
.
contains
(
"."
)
?
attrName
:
String
.
format
(
"%s.%s"
,
typeName
,
attrName
);
}
// Keys copied from org.janusgraph.graphdb.types.system.SystemTypeManager.RESERVED_CHARS
// JanusGraph checks that these chars are not part of any keys hence encoding
private
static
String
[][]
RESERVED_CHAR_ENCODE_MAP
=
new
String
[][]
{
new
String
[]
{
"{"
,
"_o"
},
new
String
[]
{
"}"
,
"_c"
},
new
String
[]
{
"\""
,
"_q"
},
new
String
[]
{
"$"
,
"_d"
},
new
String
[]
{
"%"
,
"_p"
},
};
private
static
final
char
[]
IDX_QRY_OFFENDING_CHARS
=
{
'@'
,
'/'
,
' '
,
'-'
};
...
...
repository/src/main/java/org/apache/atlas/discovery/EntityLineageService.java
View file @
b6a664df
...
...
@@ -61,6 +61,8 @@ import java.util.Map;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
RELATIONSHIP_GUID_PROPERTY_KEY
;
@Service
public
class
EntityLineageService
implements
AtlasLineageService
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
EntityLineageService
.
class
);
...
...
@@ -222,7 +224,7 @@ public class EntityLineageService implements AtlasLineageService {
AtlasVertex
outVertex
=
edge
.
getOutVertex
();
String
inGuid
=
AtlasGraphUtilsV2
.
getIdFromVertex
(
inVertex
);
String
outGuid
=
AtlasGraphUtilsV2
.
getIdFromVertex
(
outVertex
);
String
relationGuid
=
AtlasGraphUtilsV2
.
get
Property
(
edge
,
Constants
.
RELATIONSHIP_GUID_PROPERTY_KEY
,
String
.
class
);
String
relationGuid
=
AtlasGraphUtilsV2
.
get
EncodedProperty
(
edge
,
RELATIONSHIP_GUID_PROPERTY_KEY
,
String
.
class
);
boolean
isInputEdge
=
edge
.
getLabel
().
equalsIgnoreCase
(
PROCESS_INPUTS_EDGE
);
if
(!
entities
.
containsKey
(
inGuid
))
{
...
...
repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java
View file @
b6a664df
...
...
@@ -83,12 +83,22 @@ import static org.apache.atlas.repository.Constants.ATTRIBUTE_INDEX_PROPERTY_KEY
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
ATTRIBUTE_KEY_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_ENTITY_GUID
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_ENTITY_STATUS
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_LABEL
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_VERTEX_NAME_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_VERTEX_PROPAGATE_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CREATED_BY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
ENTITY_TYPE_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
MODIFIED_BY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
STATE_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
SUPER_TYPES_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
TIMESTAMP_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
store
.
graph
.
v2
.
AtlasGraphUtilsV2
.
isReference
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasStructType
.
AtlasAttribute
.
AtlasRelationshipEdgeDirection
.
BOTH
;
import
static
org
.
apache
.
atlas
.
type
.
AtlasStructType
.
AtlasAttribute
.
AtlasRelationshipEdgeDirection
.
IN
;
...
...
@@ -163,50 +173,41 @@ public final class GraphHelper {
new
Id
(
guid
,
0
,
typedInstance
.
getTypeName
()),
superTypeNames
);
// add identity
set
Property
(
vertexWithIdentity
,
Constants
.
GUID_PROPERTY_KEY
,
guid
);
AtlasGraphUtilsV2
.
setEncoded
Property
(
vertexWithIdentity
,
Constants
.
GUID_PROPERTY_KEY
,
guid
);
// add version information
set
Property
(
vertexWithIdentity
,
Constants
.
VERSION_PROPERTY_KEY
,
Long
.
valueOf
(
typedInstance
.
getId
().
getVersion
()));
AtlasGraphUtilsV2
.
setEncoded
Property
(
vertexWithIdentity
,
Constants
.
VERSION_PROPERTY_KEY
,
Long
.
valueOf
(
typedInstance
.
getId
().
getVersion
()));
return
vertexWithIdentity
;
}
public
AtlasVertex
createVertexWithoutIdentity
(
String
typeName
,
Id
typedInstanceId
,
Set
<
String
>
superTypeNames
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Creating AtlasVertex for type {} id {}"
,
typeName
,
typedInstanceId
!=
null
?
typedInstanceId
.
_getId
()
:
null
);
LOG
.
debug
(
"Creating AtlasVertex for type {} id {}"
,
typeName
,
typedInstanceId
!=
null
?
typedInstanceId
.
_getId
()
:
null
);
}
final
AtlasVertex
vertexWithoutIdentity
=
graph
.
addVertex
();
final
AtlasVertex
ret
=
graph
.
addVertex
();
// add type information
setProperty
(
vertexWithoutIdentity
,
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
typeName
);
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
ENTITY_TYPE_PROPERTY_KEY
,
typeName
);
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
STATE_PROPERTY_KEY
,
ACTIVE
.
name
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
CREATED_BY_KEY
,
RequestContext
.
get
().
getUser
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
// add super types
for
(
String
superTypeName
:
superTypeNames
)
{
addProperty
(
vertexWithoutIdentity
,
Constants
.
SUPER_TYPES_PROPERTY_KEY
,
superTypeName
);
AtlasGraphUtilsV2
.
addEncodedProperty
(
ret
,
SUPER_TYPES_PROPERTY_KEY
,
superTypeName
);
}
// add state information
setProperty
(
vertexWithoutIdentity
,
Constants
.
STATE_PROPERTY_KEY
,
Id
.
EntityState
.
ACTIVE
.
name
());
// add timestamp information
setProperty
(
vertexWithoutIdentity
,
Constants
.
TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
setProperty
(
vertexWithoutIdentity
,
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
setProperty
(
vertexWithoutIdentity
,
Constants
.
CREATED_BY_KEY
,
RequestContext
.
get
().
getUser
());
setProperty
(
vertexWithoutIdentity
,
Constants
.
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
return
vertexWithoutIdentity
;
return
ret
;
}
public
AtlasEdge
addClassificationEdge
(
AtlasVertex
entityVertex
,
AtlasVertex
classificationVertex
,
boolean
isPropagated
)
{
AtlasEdge
ret
=
addEdge
(
entityVertex
,
classificationVertex
,
CLASSIFICATION_LABEL
);
if
(
ret
!=
null
)
{
AtlasGraphUtilsV2
.
setProperty
(
ret
,
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
,
getTypeName
(
classificationVertex
));
AtlasGraphUtilsV2
.
setProperty
(
ret
,
CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY
,
isPropagated
);
AtlasGraphUtilsV2
.
set
Encoded
Property
(
ret
,
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
,
getTypeName
(
classificationVertex
));
AtlasGraphUtilsV2
.
set
Encoded
Property
(
ret
,
CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY
,
isPropagated
);
}
return
ret
;
...
...
@@ -222,11 +223,11 @@ public final class GraphHelper {
ret
=
graph
.
addEdge
(
fromVertex
,
toVertex
,
edgeLabel
);
if
(
ret
!=
null
)
{
setProperty
(
ret
,
Constants
.
STATE_PROPERTY_KEY
,
Id
.
EntityState
.
ACTIVE
.
name
());
setProperty
(
ret
,
Constants
.
TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
setProperty
(
ret
,
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
setProperty
(
ret
,
Constants
.
CREATED_BY_KEY
,
RequestContext
.
get
().
getUser
());
setProperty
(
ret
,
Constants
.
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
STATE_PROPERTY_KEY
,
ACTIVE
.
name
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
CREATED_BY_KEY
,
RequestContext
.
get
().
getUser
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Added {}"
,
string
(
ret
));
...
...
@@ -383,7 +384,7 @@ public final class GraphHelper {
boolean
ret
=
false
;
if
(
classificationVertex
!=
null
)
{
Boolean
enabled
=
AtlasGraphUtilsV2
.
getProperty
(
classificationVertex
,
CLASSIFICATION_VERTEX_PROPAGATE_KEY
,
Boolean
.
class
);
Boolean
enabled
=
AtlasGraphUtilsV2
.
get
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_VERTEX_PROPAGATE_KEY
,
Boolean
.
class
);
ret
=
(
enabled
==
null
)
?
true
:
enabled
;
}
...
...
@@ -395,7 +396,7 @@ public final class GraphHelper {
boolean
ret
=
false
;
if
(
classificationVertex
!=
null
)
{
Boolean
enabled
=
AtlasGraphUtilsV2
.
getProperty
(
classificationVertex
,
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
,
Boolean
.
class
);
Boolean
enabled
=
AtlasGraphUtilsV2
.
get
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
,
Boolean
.
class
);
ret
=
(
enabled
==
null
)
?
true
:
enabled
;
}
...
...
@@ -452,7 +453,7 @@ public final class GraphHelper {
AtlasVertex
classificationVertex
=
(
edge
!=
null
)
?
edge
.
getInVertex
()
:
null
;
if
(
classificationVertex
!=
null
)
{
String
guid
=
AtlasGraphUtilsV2
.
getProperty
(
classificationVertex
,
CLASSIFICATION_ENTITY_GUID
,
String
.
class
);
String
guid
=
AtlasGraphUtilsV2
.
get
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_ENTITY_GUID
,
String
.
class
);
if
(
StringUtils
.
equals
(
guid
,
associatedEntityGuid
))
{
ret
=
edge
;
...
...
@@ -614,7 +615,7 @@ public final class GraphHelper {
return
edge
;
}
else
{
Long
modificationTime
=
edge
.
getProperty
(
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
Long
.
class
);
Long
modificationTime
=
edge
.
getProperty
(
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
Long
.
class
);
if
(
modificationTime
!=
null
&&
modificationTime
>=
latestDeletedEdgeTime
)
{
latestDeletedEdgeTime
=
modificationTime
;
latestDeletedEdge
=
edge
;
...
...
@@ -749,13 +750,11 @@ public final class GraphHelper {
}
public
static
void
addToPropagatedTraitNames
(
AtlasVertex
entityVertex
,
String
classificationName
)
{
String
actualPropertyName
=
GraphHelper
.
encodePropertyKey
(
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Adding property {} = \"{}\" to vertex {}"
,
actualPropertyName
,
classificationName
,
string
(
entityVertex
));
LOG
.
debug
(
"Adding property {} = \"{}\" to vertex {}"
,
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
,
classificationName
,
string
(
entityVertex
));
}
entityVertex
.
addListProperty
(
actualPropertyName
,
classificationName
);
entityVertex
.
addListProperty
(
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
,
classificationName
);
}
public
static
void
removeFromPropagatedTraitNames
(
AtlasVertex
entityVertex
,
String
classificationName
)
{
...
...
@@ -997,8 +996,8 @@ public final class GraphHelper {
}
public
static
void
updateModificationMetadata
(
AtlasVertex
vertex
)
{
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
}
public
static
String
getQualifiedNameForMapKey
(
String
prefix
,
String
key
)
{
...
...
@@ -1041,7 +1040,7 @@ public final class GraphHelper {
while
(
iterator
.
hasNext
())
{
AtlasEdge
edge
=
iterator
.
next
();
ret
.
add
(
AtlasGraphUtilsV2
.
getProperty
(
edge
,
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
,
String
.
class
));
ret
.
add
(
AtlasGraphUtilsV2
.
get
Encoded
Property
(
edge
,
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
,
String
.
class
));
}
}
...
...
@@ -1150,7 +1149,7 @@ public final class GraphHelper {
public
static
List
<
String
>
getSuperTypeNames
(
AtlasVertex
<?,?>
entityVertex
)
{
ArrayList
<
String
>
superTypes
=
new
ArrayList
<>();
Collection
<
String
>
propertyValues
=
entityVertex
.
getPropertyValues
(
Constants
.
SUPER_TYPES_PROPERTY_KEY
,
String
.
class
);
Collection
<
String
>
propertyValues
=
entityVertex
.
getPropertyValues
(
SUPER_TYPES_PROPERTY_KEY
,
String
.
class
);
if
(
CollectionUtils
.
isNotEmpty
(
propertyValues
))
{
for
(
String
value
:
propertyValues
)
{
...
...
@@ -1192,7 +1191,7 @@ public final class GraphHelper {
}
public
static
String
getTypeName
(
AtlasElement
element
)
{
return
element
.
getProperty
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
String
.
class
);
return
element
.
getProperty
(
ENTITY_TYPE_PROPERTY_KEY
,
String
.
class
);
}
public
static
Id
.
EntityState
getState
(
AtlasElement
element
)
{
...
...
@@ -1205,7 +1204,7 @@ public final class GraphHelper {
}
public
static
String
getStateAsString
(
AtlasElement
element
)
{
return
element
.
getProperty
(
Constants
.
STATE_PROPERTY_KEY
,
String
.
class
);
return
element
.
getProperty
(
STATE_PROPERTY_KEY
,
String
.
class
);
}
public
static
Status
getStatus
(
AtlasElement
element
)
{
...
...
@@ -1217,11 +1216,11 @@ public final class GraphHelper {
}
public
static
String
getClassificationName
(
AtlasVertex
classificationVertex
)
{
return
AtlasGraphUtilsV2
.
getProperty
(
classificationVertex
,
CLASSIFICATION_VERTEX_NAME_KEY
,
String
.
class
);
return
AtlasGraphUtilsV2
.
get
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_VERTEX_NAME_KEY
,
String
.
class
);
}
public
static
String
getClassificationEntityGuid
(
AtlasVertex
classificationVertex
)
{
return
AtlasGraphUtilsV2
.
getProperty
(
classificationVertex
,
CLASSIFICATION_ENTITY_GUID
,
String
.
class
);
return
AtlasGraphUtilsV2
.
get
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_ENTITY_GUID
,
String
.
class
);
}
public
static
Integer
getIndexValue
(
AtlasEdge
edge
)
{
...
...
@@ -1262,7 +1261,7 @@ public final class GraphHelper {
List
<
String
>
ret
=
null
;
if
(
edge
!=
null
)
{
List
<
String
>
classificationIds
=
AtlasGraphUtilsV2
.
get
Property
(
edge
,
Constants
.
RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY
,
List
.
class
);
List
<
String
>
classificationIds
=
AtlasGraphUtilsV2
.
get
EncodedProperty
(
edge
,
RELATIONSHIPTYPE_BLOCKED_PROPAGATED_CLASSIFICATIONS_KEY
,
List
.
class
);
ret
=
CollectionUtils
.
isNotEmpty
(
classificationIds
)
?
classificationIds
:
Collections
.
emptyList
();
}
...
...
@@ -1271,32 +1270,32 @@ public final class GraphHelper {
}
public
static
PropagateTags
getPropagateTags
(
AtlasElement
element
)
{
String
propagateTags
=
element
.
getProperty
(
Constants
.
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
,
String
.
class
);
String
propagateTags
=
element
.
getProperty
(
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
,
String
.
class
);
return
(
propagateTags
==
null
)
?
null
:
PropagateTags
.
valueOf
(
propagateTags
);
}
public
static
Status
getClassificationEntityStatus
(
AtlasElement
element
)
{
String
status
=
element
.
getProperty
(
C
onstants
.
C
LASSIFICATION_ENTITY_STATUS
,
String
.
class
);
String
status
=
element
.
getProperty
(
CLASSIFICATION_ENTITY_STATUS
,
String
.
class
);
return
(
status
==
null
)
?
null
:
Status
.
valueOf
(
status
);
}
//Added conditions in fetching system attributes to handle test failures in GremlinTest where these properties are not set
public
static
String
getCreatedByAsString
(
AtlasElement
element
){
return
element
.
getProperty
(
C
onstants
.
C
REATED_BY_KEY
,
String
.
class
);
return
element
.
getProperty
(
CREATED_BY_KEY
,
String
.
class
);
}
public
static
String
getModifiedByAsString
(
AtlasElement
element
){
return
element
.
getProperty
(
Constants
.
MODIFIED_BY_KEY
,
String
.
class
);
return
element
.
getProperty
(
MODIFIED_BY_KEY
,
String
.
class
);
}
public
static
long
getCreatedTime
(
AtlasElement
element
){
return
element
.
getProperty
(
Constants
.
TIMESTAMP_PROPERTY_KEY
,
Long
.
class
);
return
element
.
getProperty
(
TIMESTAMP_PROPERTY_KEY
,
Long
.
class
);
}
public
static
long
getModifiedTime
(
AtlasElement
element
){
return
element
.
getProperty
(
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
Long
.
class
);
return
element
.
getProperty
(
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
Long
.
class
);
}
public
static
boolean
isActive
(
AtlasEntity
entity
)
{
...
...
@@ -1323,8 +1322,8 @@ public final class GraphHelper {
String
propertyKey
=
attributeInfo
.
getQualifiedName
();
try
{
result
=
findVertex
(
propertyKey
,
instance
.
get
(
attributeInfo
.
getName
()),
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
classType
.
getTypeName
(),
Constants
.
STATE_PROPERTY_KEY
,
Id
.
EntityState
.
ACTIVE
.
name
());
ENTITY_TYPE_PROPERTY_KEY
,
classType
.
getTypeName
(),
STATE_PROPERTY_KEY
,
Id
.
EntityState
.
ACTIVE
.
name
());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Found vertex by unique attribute : {}={}"
,
propertyKey
,
instance
.
get
(
attributeInfo
.
getName
()));
}
...
...
@@ -1373,8 +1372,8 @@ public final class GraphHelper {
//construct gremlin query
AtlasGraphQuery
query
=
graph
.
query
();
query
.
has
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
classType
.
getTypeName
());
query
.
has
(
Constants
.
STATE_PROPERTY_KEY
,
Id
.
EntityState
.
ACTIVE
.
name
());
query
.
has
(
ENTITY_TYPE_PROPERTY_KEY
,
classType
.
getTypeName
());
query
.
has
(
STATE_PROPERTY_KEY
,
Id
.
EntityState
.
ACTIVE
.
name
());
List
<
AtlasGraphQuery
>
orChildren
=
new
ArrayList
<
AtlasGraphQuery
>();
...
...
@@ -1446,7 +1445,7 @@ public final class GraphHelper {
if
(
CollectionUtils
.
isNotEmpty
(
vertices
))
{
for
(
AtlasVertex
vertex
:
vertices
)
{
String
entityTypeProperty
=
vertex
.
getProperty
(
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
String
.
class
);
String
entityTypeProperty
=
vertex
.
getProperty
(
ENTITY_TYPE_PROPERTY_KEY
,
String
.
class
);
if
(
entityTypeProperty
!=
null
)
{
ret
.
add
(
getTypeName
(
vertex
));
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java
View file @
b6a664df
...
...
@@ -61,6 +61,8 @@ import static org.apache.atlas.model.typedef.AtlasRelationshipDef.PropagateTags.
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_ENTITY_STATUS
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
CLASSIFICATION_LABEL
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
MODIFIED_BY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
PROPAGATED_TRAIT_NAMES_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
RELATIONSHIP_GUID_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.*;
...
...
@@ -270,8 +272,7 @@ public abstract class DeleteHandlerV1 {
}
boolean
isInternalType
=
isInternalType
(
entityVertex
);
boolean
forceDelete
=
(
typeCategory
==
STRUCT
||
typeCategory
==
CLASSIFICATION
)
&&
(
forceDeleteStructTrait
||
isInternalType
);
boolean
forceDelete
=
(
typeCategory
==
STRUCT
||
typeCategory
==
CLASSIFICATION
)
&&
(
forceDeleteStructTrait
||
isInternalType
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"isInternal = {}, forceDelete = {}"
,
isInternalType
,
forceDelete
);
...
...
@@ -305,8 +306,8 @@ public abstract class DeleteHandlerV1 {
RequestContext
requestContext
=
RequestContext
.
get
();
if
(!
requestContext
.
isUpdatedEntity
(
GraphHelper
.
getGuid
(
referencedVertex
)))
{
GraphHelper
.
setProperty
(
referencedVertex
,
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
requestContext
.
getRequestTime
());
GraphHelper
.
setProperty
(
referencedVertex
,
Constants
.
MODIFIED_BY_KEY
,
requestContext
.
getUser
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
referencedVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
requestContext
.
getRequestTime
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
referencedVertex
,
MODIFIED_BY_KEY
,
requestContext
.
getUser
());
requestContext
.
recordEntityUpdate
(
entityRetriever
.
toAtlasObjectId
(
referencedVertex
));
}
...
...
@@ -613,7 +614,7 @@ public abstract class DeleteHandlerV1 {
}
public
void
deletePropagatedEdge
(
AtlasEdge
edge
)
throws
AtlasBaseException
{
String
classificationName
=
AtlasGraphUtilsV2
.
getProperty
(
edge
,
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
,
String
.
class
);
String
classificationName
=
AtlasGraphUtilsV2
.
get
Encoded
Property
(
edge
,
CLASSIFICATION_EDGE_NAME_PROPERTY_KEY
,
String
.
class
);
AtlasVertex
entityVertex
=
edge
.
getOutVertex
();
if
(
LOG
.
isDebugEnabled
())
{
...
...
@@ -655,7 +656,7 @@ public abstract class DeleteHandlerV1 {
if
(
isClassificationEdge
(
edge
))
{
AtlasVertex
classificationVertex
=
edge
.
getInVertex
();
AtlasGraphUtilsV2
.
setProperty
(
classificationVertex
,
CLASSIFICATION_ENTITY_STATUS
,
DELETED
.
name
());
AtlasGraphUtilsV2
.
set
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_ENTITY_STATUS
,
DELETED
.
name
());
}
deleteEdge
(
edge
,
force
);
...
...
@@ -801,7 +802,7 @@ public abstract class DeleteHandlerV1 {
edge
=
graphHelper
.
getEdgeForLabel
(
outVertex
,
edgeLabel
);
if
(
shouldUpdateInverseReferences
)
{
GraphHelper
.
set
Property
(
outVertex
,
propertyName
,
null
);
AtlasGraphUtilsV2
.
setEncoded
Property
(
outVertex
,
propertyName
,
null
);
}
}
else
{
// Cannot unset a required attribute.
...
...
@@ -879,8 +880,8 @@ public abstract class DeleteHandlerV1 {
RequestContext
requestContext
=
RequestContext
.
get
();
if
(!
requestContext
.
isUpdatedEntity
(
outId
))
{
GraphHelper
.
setProperty
(
outVertex
,
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
requestContext
.
getRequestTime
());
GraphHelper
.
setProperty
(
outVertex
,
Constants
.
MODIFIED_BY_KEY
,
requestContext
.
getUser
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
outVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
requestContext
.
getRequestTime
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
outVertex
,
MODIFIED_BY_KEY
,
requestContext
.
getUser
());
requestContext
.
recordEntityUpdate
(
entityRetriever
.
toAtlasObjectId
(
outVertex
));
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/SoftDeleteHandlerV1.java
View file @
b6a664df
...
...
@@ -20,8 +20,7 @@ package org.apache.atlas.repository.store.graph.v1;
import
org.apache.atlas.RequestContext
;
import
org.apache.atlas.annotation.ConditionalOnAtlasProperty
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntity.Status
;
import
org.apache.atlas.repository.graph.GraphHelper
;
import
org.apache.atlas.repository.graphdb.AtlasEdge
;
import
org.apache.atlas.repository.graphdb.AtlasVertex
;
...
...
@@ -31,6 +30,7 @@ import org.springframework.stereotype.Component;
import
javax.inject.Inject
;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
DELETED
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
MODIFIED_BY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
STATE_PROPERTY_KEY
;
...
...
@@ -53,18 +53,18 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 {
if
(
force
)
{
graphHelper
.
removeVertex
(
instanceVertex
);
}
else
{
AtlasEntity
.
Status
state
=
AtlasGraphUtilsV2
.
getState
(
instanceVertex
);
Status
state
=
AtlasGraphUtilsV2
.
getState
(
instanceVertex
);
if
(
state
!=
AtlasEntity
.
Status
.
DELETED
)
{
GraphHelper
.
setProperty
(
instanceVertex
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
DELETED
.
name
());
GraphHelper
.
set
Property
(
instanceVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
GraphHelper
.
set
Property
(
instanceVertex
,
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
if
(
state
!=
DELETED
)
{
AtlasGraphUtilsV2
.
setEncodedProperty
(
instanceVertex
,
STATE_PROPERTY_KEY
,
DELETED
.
name
());
AtlasGraphUtilsV2
.
setEncoded
Property
(
instanceVertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
setEncoded
Property
(
instanceVertex
,
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
}
}
}
@Override
protected
void
deleteEdge
(
AtlasEdge
edge
,
boolean
force
)
throws
AtlasBaseException
{
protected
void
deleteEdge
(
AtlasEdge
edge
,
boolean
force
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> SoftDeleteHandlerV1.deleteEdge({}, {})"
,
GraphHelper
.
string
(
edge
),
force
);
}
...
...
@@ -72,12 +72,12 @@ public class SoftDeleteHandlerV1 extends DeleteHandlerV1 {
if
(
force
)
{
graphHelper
.
removeEdge
(
edge
);
}
else
{
AtlasEntity
.
Status
state
=
AtlasGraphUtilsV2
.
getState
(
edge
);
Status
state
=
AtlasGraphUtilsV2
.
getState
(
edge
);
if
(
state
!=
AtlasEntity
.
Status
.
DELETED
)
{
GraphHelper
.
setProperty
(
edge
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
DELETED
.
name
());
GraphHelper
.
set
Property
(
edge
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
GraphHelper
.
set
Property
(
edge
,
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
if
(
state
!=
DELETED
)
{
AtlasGraphUtilsV2
.
setEncodedProperty
(
edge
,
STATE_PROPERTY_KEY
,
DELETED
.
name
());
AtlasGraphUtilsV2
.
setEncoded
Property
(
edge
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
setEncoded
Property
(
edge
,
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
}
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasClassificationDefStoreV2.java
View file @
b6a664df
...
...
@@ -40,6 +40,8 @@ import java.util.List;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
TYPENAME_PROPERTY_KEY
;
/**
* ClassificationDef store in v1 format.
*/
...
...
@@ -301,7 +303,7 @@ class AtlasClassificationDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasClassif
AtlasVertex
ret
=
typeDefStore
.
findTypeVertexByGuidAndCategory
(
guid
,
TypeCategory
.
TRAIT
);
String
typeName
=
AtlasGraphUtilsV2
.
get
Property
(
ret
,
Constants
.
TYPENAME_PROPERTY_KEY
,
String
.
class
);
String
typeName
=
AtlasGraphUtilsV2
.
get
EncodedProperty
(
ret
,
TYPENAME_PROPERTY_KEY
,
String
.
class
);
if
(
AtlasGraphUtilsV2
.
typeHasInstanceVertex
(
typeName
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_HAS_REFERENCES
,
typeName
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityChangeNotifier.java
View file @
b6a664df
...
...
@@ -61,6 +61,7 @@ import java.util.Set;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditActionV2
.
PROPAGATED_CLASSIFICATION_ADD
;
import
static
org
.
apache
.
atlas
.
model
.
audit
.
EntityAuditEventV2
.
EntityAuditActionV2
.
PROPAGATED_CLASSIFICATION_DELETE
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
ENTITY_TEXT_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
util
.
AtlasRepositoryConfiguration
.
isV2EntityNotificationEnabled
;
...
...
@@ -455,7 +456,7 @@ public class AtlasEntityChangeNotifier {
try
{
String
fullText
=
fullTextMapperV2
.
getIndexTextForEntity
(
guid
);
GraphHelper
.
setProperty
(
vertex
,
Constants
.
ENTITY_TEXT_PROPERTY_KEY
,
fullText
);
AtlasGraphUtilsV2
.
setEncodedProperty
(
vertex
,
ENTITY_TEXT_PROPERTY_KEY
,
fullText
);
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"FullText mapping failed for Vertex[ guid = {} ]"
,
guid
,
e
);
}
...
...
@@ -482,10 +483,10 @@ public class AtlasEntityChangeNotifier {
try
{
String
classificationFullText
=
fullTextMapperV2
.
getIndexTextForClassifications
(
entityId
,
classifications
);
String
existingFullText
=
(
String
)
GraphHelper
.
getProperty
(
atlasVertex
,
Constants
.
ENTITY_TEXT_PROPERTY_KEY
);
String
existingFullText
=
AtlasGraphUtilsV2
.
getEncodedProperty
(
atlasVertex
,
ENTITY_TEXT_PROPERTY_KEY
,
String
.
class
);
String
newFullText
=
existingFullText
+
" "
+
classificationFullText
;
String
newFullText
=
existingFullText
+
" "
+
classificationFullText
;
GraphHelper
.
setProperty
(
atlasVertex
,
Constants
.
ENTITY_TEXT_PROPERTY_KEY
,
newFullText
);
AtlasGraphUtilsV2
.
setEncodedProperty
(
atlasVertex
,
ENTITY_TEXT_PROPERTY_KEY
,
newFullText
);
}
catch
(
AtlasBaseException
e
)
{
LOG
.
error
(
"FullText mapping failed for Vertex[ guid = {} ]"
,
entityId
,
e
);
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityDefStoreV2.java
View file @
b6a664df
...
...
@@ -303,7 +303,7 @@ public class AtlasEntityDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasEntityDe
AtlasVertex
ret
=
typeDefStore
.
findTypeVertexByGuidAndCategory
(
guid
,
TypeCategory
.
CLASS
);
String
typeName
=
AtlasGraphUtilsV2
.
getProperty
(
ret
,
Constants
.
TYPENAME_PROPERTY_KEY
,
String
.
class
);
String
typeName
=
AtlasGraphUtilsV2
.
get
Encoded
Property
(
ret
,
Constants
.
TYPENAME_PROPERTY_KEY
,
String
.
class
);
if
(
AtlasGraphUtilsV2
.
typeHasInstanceVertex
(
typeName
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_HAS_REFERENCES
,
typeName
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasGraphUtilsV2.java
View file @
b6a664df
...
...
@@ -130,7 +130,7 @@ public class AtlasGraphUtilsV2 {
case
ENTITY:
case
STRUCT:
case
CLASSIFICATION:
return
fromType
.
getQualifiedAttribute
Name
(
attributeName
);
return
fromType
.
getQualifiedAttribute
PropertyKey
(
attributeName
);
default
:
throw
new
AtlasBaseException
(
AtlasErrorCode
.
UNKNOWN_TYPE
,
fromType
.
getTypeCategory
().
name
());
}
...
...
@@ -169,20 +169,43 @@ public class AtlasGraphUtilsV2 {
* @param value
*/
public
static
AtlasVertex
addProperty
(
AtlasVertex
vertex
,
String
propertyName
,
Object
value
)
{
return
addProperty
(
vertex
,
propertyName
,
value
,
false
);
}
public
static
AtlasVertex
addEncodedProperty
(
AtlasVertex
vertex
,
String
propertyName
,
Object
value
)
{
return
addProperty
(
vertex
,
propertyName
,
value
,
true
);
}
public
static
AtlasVertex
addProperty
(
AtlasVertex
vertex
,
String
propertyName
,
Object
value
,
boolean
isEncoded
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> addProperty({}, {}, {})"
,
toString
(
vertex
),
propertyName
,
value
);
}
propertyName
=
encodePropertyKey
(
propertyName
);
if
(!
isEncoded
)
{
propertyName
=
encodePropertyKey
(
propertyName
);
}
vertex
.
addProperty
(
propertyName
,
value
);
return
vertex
;
}
public
static
<
T
extends
AtlasElement
>
void
setProperty
(
T
element
,
String
propertyName
,
Object
value
)
{
setProperty
(
element
,
propertyName
,
value
,
false
);
}
public
static
<
T
extends
AtlasElement
>
void
setEncodedProperty
(
T
element
,
String
propertyName
,
Object
value
)
{
setProperty
(
element
,
propertyName
,
value
,
true
);
}
public
static
<
T
extends
AtlasElement
>
void
setProperty
(
T
element
,
String
propertyName
,
Object
value
,
boolean
isEncoded
)
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"==> setProperty({}, {}, {})"
,
toString
(
element
),
propertyName
,
value
);
}
propertyName
=
encodePropertyKey
(
propertyName
);
if
(!
isEncoded
)
{
propertyName
=
encodePropertyKey
(
propertyName
);
}
Object
existingValue
=
element
.
getProperty
(
propertyName
,
Object
.
class
);
...
...
@@ -211,7 +234,19 @@ public class AtlasGraphUtilsV2 {
}
public
static
<
T
extends
AtlasElement
,
O
>
O
getProperty
(
T
element
,
String
propertyName
,
Class
<
O
>
returnType
)
{
Object
property
=
element
.
getProperty
(
encodePropertyKey
(
propertyName
),
returnType
);
return
getProperty
(
element
,
propertyName
,
returnType
,
false
);
}
public
static
<
T
extends
AtlasElement
,
O
>
O
getEncodedProperty
(
T
element
,
String
propertyName
,
Class
<
O
>
returnType
)
{
return
getProperty
(
element
,
propertyName
,
returnType
,
true
);
}
public
static
<
T
extends
AtlasElement
,
O
>
O
getProperty
(
T
element
,
String
propertyName
,
Class
<
O
>
returnType
,
boolean
isEncoded
)
{
if
(!
isEncoded
)
{
propertyName
=
encodePropertyKey
(
propertyName
);
}
Object
property
=
element
.
getProperty
(
propertyName
,
returnType
);
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"getProperty({}, {}) ==> {}"
,
toString
(
element
),
propertyName
,
returnType
.
cast
(
property
));
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipDefStoreV2.java
View file @
b6a664df
...
...
@@ -345,7 +345,7 @@ public class AtlasRelationshipDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasRe
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_GUID_NOT_FOUND
,
guid
);
}
String
typeName
=
AtlasGraphUtilsV2
.
getProperty
(
ret
,
Constants
.
TYPENAME_PROPERTY_KEY
,
String
.
class
);
String
typeName
=
AtlasGraphUtilsV2
.
get
Encoded
Property
(
ret
,
Constants
.
TYPENAME_PROPERTY_KEY
,
String
.
class
);
if
(
AtlasGraphUtilsV2
.
relationshipTypeHasInstanceEdges
(
typeName
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_HAS_REFERENCES
,
typeName
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
View file @
b6a664df
...
...
@@ -70,6 +70,10 @@ import static org.apache.atlas.model.instance.AtlasEntity.Status.ACTIVE;
import
static
org
.
apache
.
atlas
.
model
.
instance
.
AtlasEntity
.
Status
.
DELETED
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasRelationshipDef
.
PropagateTags
.
ONE_TO_TWO
;
import
static
org
.
apache
.
atlas
.
model
.
typedef
.
AtlasRelationshipDef
.
PropagateTags
.
TWO_TO_ONE
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
ENTITY_TYPE_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
RELATIONSHIP_GUID_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
Constants
.
VERSION_PROPERTY_KEY
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getBlockedClassificationIds
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getClassificationEntityGuid
;
import
static
org
.
apache
.
atlas
.
repository
.
graph
.
GraphHelper
.
getClassificationName
;
...
...
@@ -353,7 +357,7 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
String
attrVertexProperty
=
attr
.
getVertexPropertyName
();
Object
attrValue
=
relationship
.
getAttribute
(
attrName
);
AtlasGraphUtilsV2
.
setProperty
(
ret
,
attrVertexProperty
,
attrValue
);
AtlasGraphUtilsV2
.
set
Encoded
Property
(
ret
,
attrVertexProperty
,
attrValue
);
}
}
}
catch
(
RepositoryException
e
)
{
...
...
@@ -380,7 +384,7 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
String
attrVertexProperty
=
attr
.
getVertexPropertyName
();
if
(
relationship
.
hasAttribute
(
attrName
))
{
AtlasGraphUtilsV2
.
setProperty
(
relationshipEdge
,
attrVertexProperty
,
relationship
.
getAttribute
(
attrName
));
AtlasGraphUtilsV2
.
set
Encoded
Property
(
relationshipEdge
,
attrVertexProperty
,
relationship
.
getAttribute
(
attrName
));
}
}
}
...
...
@@ -485,7 +489,7 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
Map
<
AtlasVertex
,
List
<
AtlasVertex
>>
currentClassificationsMap
=
graphHelper
.
getClassificationPropagatedEntitiesMapping
(
currentClassificationVertices
);
// Update propagation edge
AtlasGraphUtilsV2
.
set
Property
(
edge
,
Constants
.
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
,
newTagPropagation
.
name
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
edge
,
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
,
newTagPropagation
.
name
());
List
<
AtlasVertex
>
updatedClassificationVertices
=
getClassificationVertices
(
edge
);
List
<
AtlasVertex
>
classificationVerticesUnion
=
(
List
<
AtlasVertex
>)
CollectionUtils
.
union
(
currentClassificationVertices
,
updatedClassificationVertices
);
...
...
@@ -741,10 +745,10 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
String
relationshipGuid
=
relationship
.
getGuid
();
final
String
guid
=
AtlasTypeUtil
.
isAssignedGuid
(
relationshipGuid
)
?
relationshipGuid
:
UUID
.
randomUUID
().
toString
();
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
relationship
.
getTypeName
());
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
RELATIONSHIP_GUID_PROPERTY_KEY
,
guid
);
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
VERSION_PROPERTY_KEY
,
getRelationshipVersion
(
relationship
));
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
,
tagPropagation
.
name
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
ENTITY_TYPE_PROPERTY_KEY
,
relationship
.
getTypeName
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
RELATIONSHIP_GUID_PROPERTY_KEY
,
guid
);
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
VERSION_PROPERTY_KEY
,
getRelationshipVersion
(
relationship
));
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
RELATIONSHIPTYPE_TAG_PROPAGATION_KEY
,
tagPropagation
.
name
());
// blocked propagated classifications
handleBlockedClassifications
(
ret
,
relationship
.
getBlockedPropagatedClassifications
());
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasStructDefStoreV2.java
View file @
b6a664df
...
...
@@ -309,7 +309,7 @@ public class AtlasStructDefStoreV2 extends AtlasAbstractDefStoreV2<AtlasStructDe
AtlasVertex
ret
=
typeDefStore
.
findTypeVertexByGuidAndCategory
(
guid
,
TypeCategory
.
STRUCT
);
String
typeName
=
AtlasGraphUtilsV2
.
getProperty
(
ret
,
Constants
.
TYPENAME_PROPERTY_KEY
,
String
.
class
);
String
typeName
=
AtlasGraphUtilsV2
.
get
Encoded
Property
(
ret
,
Constants
.
TYPENAME_PROPERTY_KEY
,
String
.
class
);
if
(
AtlasGraphUtilsV2
.
typeHasInstanceVertex
(
typeName
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TYPE_HAS_REFERENCES
,
typeName
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
View file @
b6a664df
...
...
@@ -126,42 +126,42 @@ public class EntityGraphMapper {
AtlasVertex
ret
=
createStructVertex
(
entity
);
for
(
String
superTypeName
:
entityType
.
getAllSuperTypes
())
{
AtlasGraphUtilsV2
.
add
Property
(
ret
,
Constants
.
SUPER_TYPES_PROPERTY_KEY
,
superTypeName
);
AtlasGraphUtilsV2
.
add
EncodedProperty
(
ret
,
SUPER_TYPES_PROPERTY_KEY
,
superTypeName
);
}
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
GUID_PROPERTY_KEY
,
guid
);
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
VERSION_PROPERTY_KEY
,
getEntityVersion
(
entity
));
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
GUID_PROPERTY_KEY
,
guid
);
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
VERSION_PROPERTY_KEY
,
getEntityVersion
(
entity
));
return
ret
;
}
public
void
updateSystemAttributes
(
AtlasVertex
vertex
,
AtlasEntity
entity
)
{
if
(
entity
.
getStatus
()
!=
null
)
{
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
STATE_PROPERTY_KEY
,
entity
.
getStatus
().
name
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
STATE_PROPERTY_KEY
,
entity
.
getStatus
().
name
());
}
if
(
entity
.
getCreateTime
()
!=
null
)
{
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
TIMESTAMP_PROPERTY_KEY
,
entity
.
getCreateTime
().
getTime
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
TIMESTAMP_PROPERTY_KEY
,
entity
.
getCreateTime
().
getTime
());
}
if
(
entity
.
getUpdateTime
()
!=
null
)
{
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
entity
.
getUpdateTime
().
getTime
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
entity
.
getUpdateTime
().
getTime
());
}
if
(
StringUtils
.
isNotEmpty
(
entity
.
getCreatedBy
()))
{
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
CREATED_BY_KEY
,
entity
.
getCreatedBy
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
CREATED_BY_KEY
,
entity
.
getCreatedBy
());
}
if
(
StringUtils
.
isNotEmpty
(
entity
.
getUpdatedBy
()))
{
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
MODIFIED_BY_KEY
,
entity
.
getUpdatedBy
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
MODIFIED_BY_KEY
,
entity
.
getUpdatedBy
());
}
if
(
StringUtils
.
isNotEmpty
(
entity
.
getHomeId
()))
{
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
HOME_ID_KEY
,
entity
.
getHomeId
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
HOME_ID_KEY
,
entity
.
getHomeId
());
}
if
(
entity
.
isProxy
()
!=
null
)
{
AtlasGraphUtilsV2
.
set
Property
(
vertex
,
Constants
.
IS_PROXY_KEY
,
entity
.
isProxy
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
vertex
,
IS_PROXY_KEY
,
entity
.
isProxy
());
}
}
...
...
@@ -238,12 +238,12 @@ public class EntityGraphMapper {
final
AtlasVertex
ret
=
graph
.
addVertex
();
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
ENTITY_TYPE_PROPERTY_KEY
,
struct
.
getTypeName
());
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
ACTIVE
.
name
());
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
CREATED_BY_KEY
,
RequestContext
.
get
().
getUser
());
GraphHelper
.
setProperty
(
ret
,
Constants
.
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
ENTITY_TYPE_PROPERTY_KEY
,
struct
.
getTypeName
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
ACTIVE
.
name
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
RequestContext
.
get
().
getRequestTime
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
CREATED_BY_KEY
,
RequestContext
.
get
().
getUser
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
ret
,
MODIFIED_BY_KEY
,
RequestContext
.
get
().
getUser
());
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== createStructVertex({})"
,
struct
.
getTypeName
());
...
...
@@ -261,9 +261,9 @@ public class EntityGraphMapper {
AtlasVertex
ret
=
createStructVertex
(
classification
);
AtlasGraphUtilsV2
.
add
Property
(
ret
,
Constants
.
SUPER_TYPES_PROPERTY_KEY
,
classificationType
.
getAllSuperTypes
());
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
CLASSIFICATION_ENTITY_GUID
,
classification
.
getEntityGuid
());
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
CLASSIFICATION_ENTITY_STATUS
,
classification
.
getEntityStatus
().
name
());
AtlasGraphUtilsV2
.
add
EncodedProperty
(
ret
,
SUPER_TYPES_PROPERTY_KEY
,
classificationType
.
getAllSuperTypes
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
CLASSIFICATION_ENTITY_GUID
,
classification
.
getEntityGuid
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
CLASSIFICATION_ENTITY_STATUS
,
classification
.
getEntityStatus
().
name
());
return
ret
;
}
...
...
@@ -344,7 +344,8 @@ public class EntityGraphMapper {
private
void
mapAttribute
(
AtlasAttribute
attribute
,
Object
attrValue
,
AtlasVertex
vertex
,
EntityOperation
op
,
EntityMutationContext
context
)
throws
AtlasBaseException
{
if
(
attrValue
==
null
)
{
AtlasAttributeDef
attributeDef
=
attribute
.
getAttributeDef
();
AtlasType
attrType
=
attribute
.
getAttributeType
();
AtlasType
attrType
=
attribute
.
getAttributeType
();
if
(
attrType
.
getTypeCategory
()
==
TypeCategory
.
PRIMITIVE
)
{
if
(
attributeDef
.
getDefaultValue
()
!=
null
)
{
attrValue
=
attrType
.
createDefaultValue
(
attributeDef
.
getDefaultValue
());
...
...
@@ -589,7 +590,7 @@ public class EntityGraphMapper {
return
;
}
AtlasGraphUtilsV2
.
set
Property
(
edge
,
Constants
.
RELATIONSHIP_GUID_PROPERTY_KEY
,
parentRelationshipGuid
);
AtlasGraphUtilsV2
.
set
EncodedProperty
(
edge
,
RELATIONSHIP_GUID_PROPERTY_KEY
,
parentRelationshipGuid
);
}
// legacy method to create edges for inverse reference
...
...
@@ -628,7 +629,7 @@ public class EntityGraphMapper {
}
}
AtlasGraphUtilsV2
.
setProperty
(
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
(),
ret
);
AtlasGraphUtilsV2
.
set
Encoded
Property
(
ctx
.
getReferringVertex
(),
ctx
.
getVertexProperty
(),
ret
);
return
ret
;
}
...
...
@@ -776,8 +777,9 @@ public class EntityGraphMapper {
// for import use the relationship guid provided
if
(
context
.
isImport
())
{
String
relationshipGuid
=
getRelationshipGuid
(
ctx
.
getValue
());
if
(!
StringUtils
.
isEmpty
(
relationshipGuid
))
{
AtlasGraphUtilsV2
.
set
Property
(
ret
,
Constants
.
RELATIONSHIP_GUID_PROPERTY_KEY
,
relationshipGuid
);
AtlasGraphUtilsV2
.
set
EncodedProperty
(
ret
,
RELATIONSHIP_GUID_PROPERTY_KEY
,
relationshipGuid
);
}
}
...
...
@@ -1126,26 +1128,23 @@ public class EntityGraphMapper {
}
private
AtlasEdge
updateEdge
(
AtlasAttributeDef
attributeDef
,
Object
value
,
AtlasEdge
currentEdge
,
final
AtlasVertex
entityVertex
)
throws
AtlasBaseException
{
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"Updating entity reference {} for reference attribute {}"
,
attributeDef
.
getName
());
}
LOG
.
debug
(
"Updating entity reference {} for reference attribute {}"
,
attributeDef
.
getName
());
// Update edge if it exists
AtlasVertex
currentVertex
=
currentEdge
.
getInVertex
();
String
currentEntityId
=
getIdFromVertex
(
currentVertex
);
String
newEntityId
=
getIdFromVertex
(
entityVertex
);
AtlasEdge
newEdge
=
currentEdge
;
if
(!
currentEntityId
.
equals
(
newEntityId
))
{
// add an edge to the class vertex from the instance
if
(
entityVertex
!=
null
)
{
try
{
newEdge
=
graphHelper
.
getOrCreateEdge
(
currentEdge
.
getOutVertex
(),
entityVertex
,
currentEdge
.
getLabel
());
}
catch
(
RepositoryException
e
)
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INTERNAL_ERROR
,
e
);
}
AtlasVertex
currentVertex
=
currentEdge
.
getInVertex
();
String
currentEntityId
=
getIdFromVertex
(
currentVertex
);
String
newEntityId
=
getIdFromVertex
(
entityVertex
);
AtlasEdge
newEdge
=
currentEdge
;
if
(!
currentEntityId
.
equals
(
newEntityId
)
&&
entityVertex
!=
null
)
{
try
{
newEdge
=
graphHelper
.
getOrCreateEdge
(
currentEdge
.
getOutVertex
(),
entityVertex
,
currentEdge
.
getLabel
());
}
catch
(
RepositoryException
e
)
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INTERNAL_ERROR
,
e
);
}
}
return
newEdge
;
}
...
...
@@ -1250,7 +1249,7 @@ public class EntityGraphMapper {
}
private
void
setArrayElementsProperty
(
AtlasType
elementType
,
AtlasVertex
vertex
,
String
vertexPropertyName
,
List
<
Object
>
values
)
{
if
(!
isReference
(
elementType
))
{
GraphHelper
.
set
Property
(
vertex
,
vertexPropertyName
,
values
);
AtlasGraphUtilsV2
.
setEncoded
Property
(
vertex
,
vertexPropertyName
,
values
);
}
}
...
...
@@ -1277,8 +1276,8 @@ public class EntityGraphMapper {
if
(
ctx
.
getAttribute
().
isOwnedRef
()
&&
getStatus
(
edge
)
==
DELETED
&&
getStatus
(
edge
.
getInVertex
())
==
DELETED
)
{
//Resurrect the vertex and edge to ACTIVE state
GraphHelper
.
setProperty
(
edge
,
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
ACTIVE
.
name
());
GraphHelper
.
setProperty
(
edge
.
getInVertex
(),
STATE_PROPERTY_KEY
,
AtlasEntity
.
Status
.
ACTIVE
.
name
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
edge
,
STATE_PROPERTY_KEY
,
ACTIVE
.
name
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
edge
.
getInVertex
(),
STATE_PROPERTY_KEY
,
ACTIVE
.
name
());
}
}
}
...
...
@@ -1340,7 +1339,7 @@ public class EntityGraphMapper {
LOG
.
debug
(
"Adding classification [{}] to [{}] using edge label: [{}]"
,
classificationName
,
entityTypeName
,
getTraitLabel
(
classificationName
));
}
GraphHelper
.
ad
dProperty
(
entityVertex
,
TRAIT_NAMES_PROPERTY_KEY
,
classificationName
);
AtlasGraphUtilsV2
.
addEncode
dProperty
(
entityVertex
,
TRAIT_NAMES_PROPERTY_KEY
,
classificationName
);
// add a new AtlasVertex for the struct or trait instance
AtlasVertex
classificationVertex
=
createClassificationVertex
(
classification
);
...
...
@@ -1589,7 +1588,7 @@ public class EntityGraphMapper {
Boolean
updatedRemovePropagations
=
classification
.
getRemovePropagationsOnEntityDelete
();
if
(
updatedRemovePropagations
!=
null
&&
(
updatedRemovePropagations
!=
currentRemovePropagations
))
{
AtlasGraphUtilsV2
.
setProperty
(
classificationVertex
,
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
,
updatedRemovePropagations
);
AtlasGraphUtilsV2
.
set
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
,
updatedRemovePropagations
);
isClassificationUpdated
=
true
;
}
...
...
@@ -1695,18 +1694,17 @@ public class EntityGraphMapper {
if
(
classification
.
getValidityPeriods
()
!=
null
)
{
String
strValidityPeriods
=
AtlasJson
.
toJson
(
classification
.
getValidityPeriods
());
AtlasGraphUtilsV2
.
set
Property
(
traitInstanceVertex
,
Constants
.
CLASSIFICATION_VALIDITY_PERIODS_KEY
,
strValidityPeriods
);
AtlasGraphUtilsV2
.
set
EncodedProperty
(
traitInstanceVertex
,
CLASSIFICATION_VALIDITY_PERIODS_KEY
,
strValidityPeriods
);
}
else
{
// if 'null', don't update existing value in the classification
}
if
(
classification
.
isPropagate
()
!=
null
)
{
AtlasGraphUtilsV2
.
set
Property
(
traitInstanceVertex
,
Constants
.
CLASSIFICATION_VERTEX_PROPAGATE_KEY
,
classification
.
isPropagate
());
AtlasGraphUtilsV2
.
set
EncodedProperty
(
traitInstanceVertex
,
CLASSIFICATION_VERTEX_PROPAGATE_KEY
,
classification
.
isPropagate
());
}
if
(
classification
.
getRemovePropagationsOnEntityDelete
()
!=
null
)
{
AtlasGraphUtilsV2
.
setProperty
(
traitInstanceVertex
,
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
,
classification
.
getRemovePropagationsOnEntityDelete
());
AtlasGraphUtilsV2
.
setEncodedProperty
(
traitInstanceVertex
,
CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY
,
classification
.
getRemovePropagationsOnEntityDelete
());
}
// map all the attributes to this newly created AtlasVertex
...
...
@@ -1742,7 +1740,7 @@ public class EntityGraphMapper {
entityVertex
.
removeProperty
(
TRAIT_NAMES_PROPERTY_KEY
);
for
(
String
traitName
:
traitNames
)
{
GraphHelper
.
ad
dProperty
(
entityVertex
,
TRAIT_NAMES_PROPERTY_KEY
,
traitName
);
AtlasGraphUtilsV2
.
addEncode
dProperty
(
entityVertex
,
TRAIT_NAMES_PROPERTY_KEY
,
traitName
);
}
}
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
View file @
b6a664df
...
...
@@ -284,12 +284,12 @@ public final class EntityGraphRetriever {
public
AtlasClassification
toAtlasClassification
(
AtlasVertex
classificationVertex
)
throws
AtlasBaseException
{
AtlasClassification
ret
=
new
AtlasClassification
(
getTypeName
(
classificationVertex
));
ret
.
setEntityGuid
(
AtlasGraphUtilsV2
.
getProperty
(
classificationVertex
,
CLASSIFICATION_ENTITY_GUID
,
String
.
class
));
ret
.
setEntityGuid
(
AtlasGraphUtilsV2
.
get
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_ENTITY_GUID
,
String
.
class
));
ret
.
setEntityStatus
(
getClassificationEntityStatus
(
classificationVertex
));
ret
.
setPropagate
(
isPropagationEnabled
(
classificationVertex
));
ret
.
setRemovePropagationsOnEntityDelete
(
getRemovePropagations
(
classificationVertex
));
String
strValidityPeriods
=
AtlasGraphUtilsV2
.
getProperty
(
classificationVertex
,
CLASSIFICATION_VALIDITY_PERIODS_KEY
,
String
.
class
);
String
strValidityPeriods
=
AtlasGraphUtilsV2
.
get
Encoded
Property
(
classificationVertex
,
CLASSIFICATION_VALIDITY_PERIODS_KEY
,
String
.
class
);
if
(
strValidityPeriods
!=
null
)
{
ret
.
setValidityPeriods
(
AtlasJson
.
fromJson
(
strValidityPeriods
,
TIME_BOUNDARIES_LIST_TYPE
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment