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
8931d475
Commit
8931d475
authored
Jul 26, 2017
by
Peter Gergo Barna
Committed by
Madhan Neethiraj
Jul 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1879: fixed - classification update removes some properties
Signed-off-by:
Madhan Neethiraj
<
madhan@apache.org
>
(cherry picked from commit b566ea6925b74f89fd59ca46e14c1eb687240561)
parent
c97275ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
2 deletions
+71
-2
AtlasTypeDefGraphStore.java
.../atlas/repository/store/graph/AtlasTypeDefGraphStore.java
+6
-0
AtlasTypeDefGraphStoreTest.java
...as/repository/store/graph/AtlasTypeDefGraphStoreTest.java
+65
-2
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStore.java
View file @
8931d475
...
...
@@ -412,6 +412,12 @@ public abstract class AtlasTypeDefGraphStore implements AtlasTypeDefStore, Activ
AtlasTypesDef
ret
=
updateGraphStore
(
typesDef
,
ttr
);
try
{
ttr
.
updateTypes
(
ret
);
}
catch
(
AtlasBaseException
e
)
{
// this shouldn't happen, as the types were already validated
LOG
.
error
(
"failed to update the registry after updating the store"
,
e
);
}
if
(
LOG
.
isDebugEnabled
())
{
LOG
.
debug
(
"<== AtlasTypeDefGraphStore.updateTypesDef(enums={}, structs={}, classfications={}, entities={}, relationships={})"
,
CollectionUtils
.
size
(
typesDef
.
getEnumDefs
()),
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/AtlasTypeDefGraphStoreTest.java
View file @
8931d475
...
...
@@ -29,6 +29,7 @@ import org.apache.atlas.model.typedef.AtlasStructDef;
import
org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.store.AtlasTypeDefStore
;
import
org.apache.atlas.type.AtlasType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.testng.Assert
;
...
...
@@ -38,6 +39,7 @@ import org.testng.annotations.Test;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.List
;
import
static
org
.
testng
.
Assert
.*;
...
...
@@ -432,4 +434,66 @@ public class AtlasTypeDefGraphStoreTest {
}
}
}
\ No newline at end of file
@Test
public
void
testTypeRegistryIsUpdatedAfterGraphStorage
()
throws
AtlasBaseException
{
String
classificationDef
=
"{"
+
"\"name\":\"test_classification_11\","
+
"\"description\":\"\","
+
"\"createdBy\":\"admin\","
+
"\"superTypes\":[],"
+
"\"attributeDefs\":[{"
+
"\"name\":\"test_class_11\","
+
"\"typeName\":\"string\","
+
"\"isOptional\":true,"
+
"\"isUnique\":true,"
+
"\"isIndexable\":true,"
+
"\"cardinality\":\"SINGLE\","
+
"\"valuesMinCount\":0,"
+
"\"valuesMaxCount\":1}]}"
;
String
jsonStr
=
"{"
+
"\"classificationDefs\":["
+
classificationDef
+
"],"
+
"\"entityDefs\":[],"
+
"\"enumDefs\":[],"
+
"\"structDefs\":[]}"
;
// create type from json string
AtlasTypesDef
testTypesDefFromJson
=
AtlasType
.
fromJson
(
jsonStr
,
AtlasTypesDef
.
class
);
AtlasTypesDef
createdTypesDef
=
typeDefStore
.
createTypesDef
(
testTypesDefFromJson
);
// check returned type
assertEquals
(
"test_classification_11"
,
createdTypesDef
.
getClassificationDefs
().
get
(
0
).
getName
());
assertTrue
(
createdTypesDef
.
getClassificationDefs
().
get
(
0
).
getAttributeDefs
().
get
(
0
).
getIsIndexable
());
// save guid
String
guid
=
createdTypesDef
.
getClassificationDefs
().
get
(
0
).
getGuid
();
Date
createdTime
=
createdTypesDef
.
getClassificationDefs
().
get
(
0
).
getCreateTime
();
// get created type and check again
AtlasClassificationDef
getBackFromCache
=
typeDefStore
.
getClassificationDefByName
(
"test_classification_11"
);
assertEquals
(
"test_classification_11"
,
getBackFromCache
.
getName
());
assertTrue
(
getBackFromCache
.
getAttributeDefs
().
get
(
0
).
getIsIndexable
());
assertEquals
(
guid
,
getBackFromCache
.
getGuid
());
assertNotNull
(
getBackFromCache
.
getCreatedBy
());
assertEquals
(
createdTime
,
getBackFromCache
.
getCreateTime
());
// update type, change isIndexable, check the update result
testTypesDefFromJson
=
AtlasType
.
fromJson
(
jsonStr
,
AtlasTypesDef
.
class
);
testTypesDefFromJson
.
getClassificationDefs
().
get
(
0
).
getAttributeDefs
().
get
(
0
).
setIsIndexable
(
false
);
AtlasTypesDef
updatedTypesDef
=
typeDefStore
.
updateTypesDef
(
testTypesDefFromJson
);
assertEquals
(
"test_classification_11"
,
updatedTypesDef
.
getClassificationDefs
().
get
(
0
).
getName
());
assertFalse
(
updatedTypesDef
.
getClassificationDefs
().
get
(
0
).
getAttributeDefs
().
get
(
0
).
getIsIndexable
());
assertEquals
(
guid
,
updatedTypesDef
.
getClassificationDefs
().
get
(
0
).
getGuid
());
assertEquals
(
createdTime
,
updatedTypesDef
.
getClassificationDefs
().
get
(
0
).
getCreateTime
());
// get updated type (both by name and guid) and check again
getBackFromCache
=
typeDefStore
.
getClassificationDefByName
(
"test_classification_11"
);
assertEquals
(
"test_classification_11"
,
getBackFromCache
.
getName
());
assertFalse
(
getBackFromCache
.
getAttributeDefs
().
get
(
0
).
getIsIndexable
());
assertEquals
(
guid
,
getBackFromCache
.
getGuid
());
assertEquals
(
createdTime
,
getBackFromCache
.
getCreateTime
());
getBackFromCache
=
typeDefStore
.
getClassificationDefByGuid
(
guid
);
assertEquals
(
"test_classification_11"
,
getBackFromCache
.
getName
());
assertFalse
(
getBackFromCache
.
getAttributeDefs
().
get
(
0
).
getIsIndexable
());
assertEquals
(
guid
,
getBackFromCache
.
getGuid
());
assertEquals
(
createdTime
,
getBackFromCache
.
getCreateTime
());
}
}
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