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
8d86dd2c
Commit
8d86dd2c
authored
Feb 22, 2018
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2457: updated classification to support multiple validity-periods
parent
5e496e5e
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
22 deletions
+39
-22
Constants.java
.../src/main/java/org/apache/atlas/repository/Constants.java
+1
-3
AtlasClassification.java
.../org/apache/atlas/model/instance/AtlasClassification.java
+22
-7
EntityGraphMapper.java
...he/atlas/repository/store/graph/v1/EntityGraphMapper.java
+7
-5
EntityGraphRetriever.java
...atlas/repository/store/graph/v1/EntityGraphRetriever.java
+5
-5
EntityV2JerseyResourceIT.java
...pache/atlas/web/integration/EntityV2JerseyResourceIT.java
+4
-2
No files found.
common/src/main/java/org/apache/atlas/repository/Constants.java
View file @
8d86dd2c
...
...
@@ -118,9 +118,7 @@ public final class Constants {
public
static
final
String
CLASSIFICATION_ENTITY_GUID
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"entityGuid"
;
public
static
final
String
CLASSIFICATION_PROPAGATE_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"propagate"
;
public
static
final
String
CLASSIFICATION_VALIDITY_PERIOD_STARTTIME_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"vp_startTime"
;
public
static
final
String
CLASSIFICATION_VALIDITY_PERIOD_ENDTIME_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"vp_endTime"
;
public
static
final
String
CLASSIFICATION_VALIDITY_PERIOD_TIMEZONE_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"vp_timeZone"
;
public
static
final
String
CLASSIFICATION_VALIDITY_PERIODS_KEY
=
INTERNAL_PROPERTY_KEY_PREFIX
+
"validityPeriods"
;
private
Constants
()
{
}
...
...
intg/src/main/java/org/apache/atlas/model/instance/AtlasClassification.java
View file @
8d86dd2c
...
...
@@ -19,10 +19,12 @@ package org.apache.atlas.model.instance;
import
com.fasterxml.jackson.annotation.JsonAutoDetect
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
...
...
@@ -53,7 +55,7 @@ public class AtlasClassification extends AtlasStruct implements Serializable {
private
String
entityGuid
=
null
;
private
boolean
propagate
=
true
;
private
TimeBoundary
validityPeriod
=
null
;
private
List
<
TimeBoundary
>
validityPeriods
=
null
;
public
AtlasClassification
()
{
...
...
@@ -99,12 +101,25 @@ public class AtlasClassification extends AtlasStruct implements Serializable {
this
.
propagate
=
propagate
;
}
public
TimeBoundary
getValidityPeriod
()
{
return
validityPeriod
;
public
List
<
TimeBoundary
>
getValidityPeriods
()
{
return
validityPeriod
s
;
}
public
void
setValidityPeriod
(
TimeBoundary
validityPeriod
)
{
this
.
validityPeriod
=
validityPeriod
;
public
void
setValidityPeriods
(
List
<
TimeBoundary
>
validityPeriods
)
{
this
.
validityPeriods
=
validityPeriods
;
}
@JsonIgnore
public
void
addValityPeriod
(
TimeBoundary
validityPeriod
)
{
List
<
TimeBoundary
>
vpList
=
this
.
validityPeriods
;
if
(
vpList
==
null
)
{
vpList
=
new
ArrayList
<>();
this
.
validityPeriods
=
vpList
;
}
vpList
.
add
(
validityPeriod
);
}
@Override
...
...
@@ -115,7 +130,7 @@ public class AtlasClassification extends AtlasStruct implements Serializable {
AtlasClassification
that
=
(
AtlasClassification
)
o
;
return
propagate
==
that
.
propagate
&&
Objects
.
equals
(
entityGuid
,
that
.
entityGuid
)
&&
Objects
.
equals
(
validityPeriod
,
that
.
validityPeriod
);
Objects
.
equals
(
validityPeriod
s
,
that
.
validityPeriods
);
}
@Override
...
...
@@ -129,7 +144,7 @@ public class AtlasClassification extends AtlasStruct implements Serializable {
super
.
toString
(
sb
);
sb
.
append
(
"entityGuid='"
).
append
(
entityGuid
).
append
(
'\''
);
sb
.
append
(
", propagate="
).
append
(
propagate
);
sb
.
append
(
", validityPeriod
="
).
append
(
validityPeriod
);
sb
.
append
(
", validityPeriod
s="
).
append
(
validityPeriods
);
sb
.
append
(
'}'
);
return
sb
.
toString
();
}
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphMapper.java
View file @
8d86dd2c
...
...
@@ -54,6 +54,7 @@ import org.apache.atlas.type.AtlasStructType.AtlasAttribute.AtlasRelationshipEdg
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.utils.AtlasJson
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.IteratorUtils
;
import
org.apache.commons.collections.MapUtils
;
...
...
@@ -1591,12 +1592,13 @@ public class EntityGraphMapper {
private
AtlasEdge
mapClassification
(
EntityOperation
operation
,
final
EntityMutationContext
context
,
AtlasClassification
classification
,
AtlasEntityType
entityType
,
AtlasVertex
parentInstanceVertex
,
AtlasVertex
traitInstanceVertex
)
throws
AtlasBaseException
{
if
(
classification
.
getValidityPeriods
()
!=
null
)
{
String
strValidityPeriods
=
AtlasJson
.
toJson
(
classification
.
getValidityPeriods
());
TimeBoundary
validityPeriod
=
classification
.
getValidityPeriod
();
AtlasGraphUtilsV1
.
setProperty
(
traitInstanceVertex
,
Constants
.
CLASSIFICATION_VALIDITY_PERIOD_STARTTIME_KEY
,
validityPeriod
!=
null
?
validityPeriod
.
getStartTime
()
:
null
);
AtlasGraphUtilsV1
.
setProperty
(
traitInstanceVertex
,
Constants
.
CLASSIFICATION_VALIDITY_PERIOD_ENDTIME_KEY
,
validityPeriod
!=
null
?
validityPeriod
.
getEndTime
()
:
null
);
AtlasGraphUtilsV1
.
setProperty
(
traitInstanceVertex
,
Constants
.
CLASSIFICATION_VALIDITY_PERIOD_TIMEZONE_KEY
,
validityPeriod
!=
null
?
validityPeriod
.
getTimeZone
()
:
null
);
AtlasGraphUtilsV1
.
setProperty
(
traitInstanceVertex
,
Constants
.
CLASSIFICATION_VALIDITY_PERIODS_KEY
,
strValidityPeriods
);
}
else
{
// if 'null', don't update existing value in the classification
}
// map all the attributes to this newly created AtlasVertex
mapAttributes
(
classification
,
traitInstanceVertex
,
operation
,
context
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/EntityGraphRetriever.java
View file @
8d86dd2c
...
...
@@ -51,6 +51,7 @@ import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeUtil
;
import
org.apache.atlas.utils.AtlasJson
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -102,6 +103,7 @@ public final class EntityGraphRetriever {
private
final
String
CREATE_TIME
=
"createTime"
;
private
final
String
QUALIFIED_NAME
=
"qualifiedName"
;
private
static
final
List
<
TimeBoundary
>
TIME_BOUNDARIES_LIST
=
new
ArrayList
<>();
private
static
final
GraphHelper
graphHelper
=
GraphHelper
.
getInstance
();
private
final
AtlasTypeRegistry
typeRegistry
;
...
...
@@ -218,12 +220,10 @@ public final class EntityGraphRetriever {
ret
.
setEntityGuid
(
AtlasGraphUtilsV1
.
getProperty
(
classificationVertex
,
CLASSIFICATION_ENTITY_GUID
,
String
.
class
));
ret
.
setPropagate
(
AtlasGraphUtilsV1
.
getProperty
(
classificationVertex
,
CLASSIFICATION_PROPAGATE_KEY
,
Boolean
.
class
));
String
vpStartTime
=
AtlasGraphUtilsV1
.
getProperty
(
classificationVertex
,
CLASSIFICATION_VALIDITY_PERIOD_STARTTIME_KEY
,
String
.
class
);
String
vpEndTime
=
AtlasGraphUtilsV1
.
getProperty
(
classificationVertex
,
CLASSIFICATION_VALIDITY_PERIOD_ENDTIME_KEY
,
String
.
class
);
String
vpTimeZone
=
AtlasGraphUtilsV1
.
getProperty
(
classificationVertex
,
CLASSIFICATION_VALIDITY_PERIOD_TIMEZONE_KEY
,
String
.
class
);
String
strValidityPeriods
=
AtlasGraphUtilsV1
.
getProperty
(
classificationVertex
,
CLASSIFICATION_VALIDITY_PERIODS_KEY
,
String
.
class
);
if
(
vpStartTime
!=
null
||
vpEndTime
!=
null
||
vpTimeZone
!=
null
)
{
ret
.
setValidityPeriod
(
new
TimeBoundary
(
vpStartTime
,
vpEndTime
,
vpTimeZone
));
if
(
strValidityPeriods
!=
null
)
{
ret
.
setValidityPeriod
s
(
AtlasJson
.
fromJson
(
strValidityPeriods
,
TIME_BOUNDARIES_LIST
.
getClass
()
));
}
mapAttributes
(
classificationVertex
,
ret
,
null
);
...
...
webapp/src/test/java/org/apache/atlas/web/integration/EntityV2JerseyResourceIT.java
View file @
8d86dd2c
...
...
@@ -463,7 +463,7 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
TimeBoundary
validityPeriod
=
new
TimeBoundary
(
"2018/03/01 00:00:00"
,
"2018/04/01 00:00:00"
,
"GMT"
);
classification
.
setEntityGuid
(
tableGuid
);
classification
.
setValid
ityPeriod
(
validityPeriod
);
classification
.
addVal
ityPeriod
(
validityPeriod
);
atlasClientV2
.
addClassifications
(
tableGuid
,
Collections
.
singletonList
(
classification
));
...
...
@@ -481,7 +481,9 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
foundClassification
=
true
;
assertEquals
(
entityClassification
.
getTypeName
(),
piiTrait
.
getName
());
assertEquals
(
entityClassification
.
getValidityPeriod
(),
validityPeriod
);
assertNotNull
(
entityClassification
.
getValidityPeriods
());
assertEquals
(
entityClassification
.
getValidityPeriods
().
size
(),
1
);
assertEquals
(
entityClassification
.
getValidityPeriods
().
get
(
0
),
validityPeriod
);
assertEquals
(
entityClassification
,
classification
);
break
;
...
...
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