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
d8db4310
Commit
d8db4310
authored
8 years ago
by
Vimal Sharma
Committed by
Madhan Neethiraj
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1435: include common attributes in v2 entity API response
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
parent
22650d6e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
AtlasEntityFormatConverter.java
...apache/atlas/web/adapters/AtlasEntityFormatConverter.java
+21
-0
EntityV2JerseyResourceIT.java
.../apache/atlas/web/resources/EntityV2JerseyResourceIT.java
+11
-0
No files found.
webapp/src/main/java/org/apache/atlas/web/adapters/AtlasEntityFormatConverter.java
View file @
d8db4310
...
...
@@ -23,6 +23,7 @@ import org.apache.atlas.exception.AtlasBaseException;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.instance.AtlasClassification
;
import
org.apache.atlas.model.instance.AtlasEntity
;
import
org.apache.atlas.model.instance.AtlasEntity.Status
;
import
org.apache.atlas.model.instance.AtlasEntityWithAssociations
;
import
org.apache.atlas.model.instance.AtlasObjectId
;
import
org.apache.atlas.type.AtlasEntityType
;
...
...
@@ -31,7 +32,9 @@ import org.apache.atlas.type.AtlasTypeRegistry;
import
org.apache.atlas.typesystem.IReferenceableInstance
;
import
org.apache.atlas.typesystem.IStruct
;
import
org.apache.atlas.typesystem.Referenceable
;
import
org.apache.atlas.typesystem.persistence.AtlasSystemAttributes
;
import
org.apache.atlas.typesystem.persistence.Id
;
import
org.apache.atlas.typesystem.persistence.Id.EntityState
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -61,6 +64,8 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter {
ret
=
new
AtlasEntityWithAssociations
(
id
.
getTypeName
());
ret
.
setGuid
(
id
.
getId
().
_getId
());
EntityState
state
=
id
.
getState
();
ret
.
setStatus
(
convertState
(
state
));
}
else
if
(
v1Obj
instanceof
IReferenceableInstance
)
{
IReferenceableInstance
entity
=
(
IReferenceableInstance
)
v1Obj
;
Map
<
String
,
Object
>
v1Attribs
=
null
;
...
...
@@ -73,6 +78,13 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter {
ret
=
new
AtlasEntityWithAssociations
(
entity
.
getTypeName
(),
super
.
fromV1ToV2
(
entityType
,
v1Attribs
));
ret
.
setGuid
(
entity
.
getId
().
_getId
());
ret
.
setStatus
(
convertState
(
entity
.
getId
().
getState
()));
AtlasSystemAttributes
systemAttributes
=
entity
.
getSystemAttributes
();
ret
.
setCreatedBy
(
systemAttributes
.
createdBy
);
ret
.
setCreateTime
(
systemAttributes
.
createdTime
);
ret
.
setUpdatedBy
(
systemAttributes
.
modifiedBy
);
ret
.
setUpdateTime
(
systemAttributes
.
modifiedTime
);
ret
.
setVersion
(
new
Long
(
entity
.
getId
().
version
));
if
(
CollectionUtils
.
isNotEmpty
(
entity
.
getTraits
()))
{
List
<
AtlasClassification
>
classifications
=
new
ArrayList
<>();
...
...
@@ -96,6 +108,15 @@ public class AtlasEntityFormatConverter extends AtlasStructFormatConverter {
return
ret
;
}
private
AtlasEntity
.
Status
convertState
(
EntityState
state
){
Status
status
=
Status
.
STATUS_ACTIVE
;
if
(
state
!=
null
&&
state
.
equals
(
EntityState
.
DELETED
)){
status
=
Status
.
STATUS_DELETED
;
}
LOG
.
debug
(
"Setting state to {}"
,
state
);
return
status
;
}
@Override
public
Object
fromV2ToV1
(
Object
v2Obj
,
AtlasType
type
)
throws
AtlasBaseException
{
Object
ret
=
null
;
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/resources/EntityV2JerseyResourceIT.java
View file @
d8db4310
...
...
@@ -335,6 +335,17 @@ public class EntityV2JerseyResourceIT extends BaseResourceIT {
assertEquals
(
classifications
.
getList
().
size
(),
8
);
}
@Test
(
dependsOnMethods
=
"testSubmitEntity"
)
public
void
testCommonAttributes
()
throws
Exception
{
AtlasEntity
entity
=
entitiesClientV2
.
getEntityByGuid
(
tableEntity
.
getGuid
());
Assert
.
assertNotNull
(
entity
.
getStatus
());
Assert
.
assertNotNull
(
entity
.
getVersion
());
Assert
.
assertNotNull
(
entity
.
getCreatedBy
());
Assert
.
assertNotNull
(
entity
.
getCreateTime
());
Assert
.
assertNotNull
(
entity
.
getUpdatedBy
());
Assert
.
assertNotNull
(
entity
.
getUpdateTime
());
}
private
void
addProperty
(
String
guid
,
String
property
,
String
value
)
throws
AtlasServiceException
{
AtlasEntity
entityByGuid
=
entitiesClientV2
.
getEntityByGuid
(
guid
);
...
...
This diff is collapsed.
Click to expand it.
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