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
ac808af0
Commit
ac808af0
authored
Feb 10, 2020
by
Madhan Neethiraj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-3613: updated search to support namespace attributes
parent
10bcaa80
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
94 additions
and
84 deletions
+94
-84
AtlasClassificationType.java
...n/java/org/apache/atlas/type/AtlasClassificationType.java
+5
-0
AtlasEntityType.java
.../src/main/java/org/apache/atlas/type/AtlasEntityType.java
+0
-0
AtlasStructType.java
.../src/main/java/org/apache/atlas/type/AtlasStructType.java
+9
-7
GremlinQueryComposer.java
...ain/java/org/apache/atlas/query/GremlinQueryComposer.java
+2
-2
IdentifierHelper.java
...rc/main/java/org/apache/atlas/query/IdentifierHelper.java
+19
-8
RegistryBasedLookup.java
...main/java/org/apache/atlas/query/RegistryBasedLookup.java
+15
-28
AtlasEntityStoreV2.java
...e/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java
+5
-5
EntityGraphMapper.java
...he/atlas/repository/store/graph/v2/EntityGraphMapper.java
+17
-17
EntityGraphRetriever.java
...atlas/repository/store/graph/v2/EntityGraphRetriever.java
+19
-14
AtlasNamespaceDefStoreV2Test.java
...pository/store/graph/v2/AtlasNamespaceDefStoreV2Test.java
+3
-3
No files found.
intg/src/main/java/org/apache/atlas/type/AtlasClassificationType.java
View file @
ac808af0
...
@@ -238,6 +238,11 @@ public class AtlasClassificationType extends AtlasStructType {
...
@@ -238,6 +238,11 @@ public class AtlasClassificationType extends AtlasStructType {
classificationDef
.
setSubTypes
(
subTypes
);
classificationDef
.
setSubTypes
(
subTypes
);
}
}
@Override
public
AtlasAttribute
getSystemAttribute
(
String
attributeName
)
{
return
AtlasClassificationType
.
CLASSIFICATION_ROOT
.
allAttributes
.
get
(
attributeName
);
}
private
void
addSubType
(
AtlasClassificationType
subType
)
{
private
void
addSubType
(
AtlasClassificationType
subType
)
{
subTypes
.
add
(
subType
.
getTypeName
());
subTypes
.
add
(
subType
.
getTypeName
());
}
}
...
...
intg/src/main/java/org/apache/atlas/type/AtlasEntityType.java
View file @
ac808af0
This diff is collapsed.
Click to expand it.
intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
View file @
ac808af0
...
@@ -226,17 +226,19 @@ public class AtlasStructType extends AtlasType {
...
@@ -226,17 +226,19 @@ public class AtlasStructType extends AtlasType {
ret
=
getSystemAttribute
(
attributeName
);
ret
=
getSystemAttribute
(
attributeName
);
}
}
if
(
ret
==
null
)
{
ret
=
getNamespaceAttribute
(
attributeName
);
}
return
ret
;
return
ret
;
}
}
public
AtlasAttribute
getSystemAttribute
(
String
attributeName
)
{
public
AtlasAttribute
getSystemAttribute
(
String
attributeName
)
{
AtlasAttribute
ret
=
null
;
return
null
;
if
(
this
instanceof
AtlasEntityType
)
{
}
ret
=
AtlasEntityType
.
ENTITY_ROOT
.
allAttributes
.
get
(
attributeName
);
}
else
if
(
this
instanceof
AtlasClassificationType
)
{
public
AtlasAttribute
getNamespaceAttribute
(
String
attributeName
)
{
ret
=
AtlasClassificationType
.
CLASSIFICATION_ROOT
.
allAttributes
.
get
(
attributeName
);
return
null
;
}
return
ret
;
}
}
@Override
@Override
...
...
repository/src/main/java/org/apache/atlas/query/GremlinQueryComposer.java
View file @
ac808af0
...
@@ -119,9 +119,9 @@ public class GremlinQueryComposer {
...
@@ -119,9 +119,9 @@ public class GremlinQueryComposer {
if
(
ia
.
isTrait
())
{
if
(
ia
.
isTrait
())
{
String
traitName
=
ia
.
get
();
String
traitName
=
ia
.
get
();
if
(
traitName
.
equals
IgnoreCase
(
ALL_CLASSIFICATIONS
))
{
if
(
traitName
.
equals
(
ALL_CLASSIFICATIONS
))
{
addTrait
(
GremlinClause
.
ANY_TRAIT
,
ia
);
addTrait
(
GremlinClause
.
ANY_TRAIT
,
ia
);
}
else
if
(
traitName
.
equals
IgnoreCase
(
NO_CLASSIFICATIONS
))
{
}
else
if
(
traitName
.
equals
(
NO_CLASSIFICATIONS
))
{
addTrait
(
GremlinClause
.
NO_TRAIT
,
ia
);
addTrait
(
GremlinClause
.
NO_TRAIT
,
ia
);
}
else
{
}
else
{
addTrait
(
GremlinClause
.
TRAIT
,
ia
);
addTrait
(
GremlinClause
.
TRAIT
,
ia
);
...
...
repository/src/main/java/org/apache/atlas/query/IdentifierHelper.java
View file @
ac808af0
...
@@ -20,6 +20,8 @@ package org.apache.atlas.query;
...
@@ -20,6 +20,8 @@ package org.apache.atlas.query;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.AtlasErrorCode
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.type.AtlasNamespaceType
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
...
@@ -148,7 +150,6 @@ public class IdentifierHelper {
...
@@ -148,7 +150,6 @@ public class IdentifierHelper {
raw
=
context
.
getTypeNameFromAlias
(
this
.
raw
);
raw
=
context
.
getTypeNameFromAlias
(
this
.
raw
);
}
}
updateParts
();
updateTypeInfo
(
lookup
,
context
);
updateTypeInfo
(
lookup
,
context
);
setIsTrait
(
context
,
lookup
,
attributeName
);
setIsTrait
(
context
,
lookup
,
attributeName
);
updateEdgeInfo
(
lookup
,
context
);
updateEdgeInfo
(
lookup
,
context
);
...
@@ -183,15 +184,29 @@ public class IdentifierHelper {
...
@@ -183,15 +184,29 @@ public class IdentifierHelper {
}
}
private
void
updateTypeInfo
(
org
.
apache
.
atlas
.
query
.
Lookup
lookup
,
GremlinQueryComposer
.
Context
context
)
{
private
void
updateTypeInfo
(
org
.
apache
.
atlas
.
query
.
Lookup
lookup
,
GremlinQueryComposer
.
Context
context
)
{
parts
=
StringUtils
.
split
(
raw
,
"."
);
// check if this is a namespace attribute
if
(
parts
.
length
==
2
)
{
try
{
AtlasType
type
=
lookup
.
getType
(
parts
[
0
]);
if
(
type
instanceof
AtlasNamespaceType
)
{
parts
=
new
String
[
1
];
parts
[
0
]
=
raw
;
}
}
catch
(
AtlasBaseException
excp
)
{
// ignore
}
}
if
(
parts
.
length
==
1
)
{
if
(
parts
.
length
==
1
)
{
typeName
=
context
.
hasAlias
(
parts
[
0
])
?
typeName
=
context
.
hasAlias
(
parts
[
0
])
?
context
.
getTypeNameFromAlias
(
parts
[
0
])
:
context
.
getTypeNameFromAlias
(
parts
[
0
])
:
context
.
getActiveTypeName
();
context
.
getActiveTypeName
();
qualifiedName
=
getDefaultQualifiedNameForSinglePartName
(
context
,
parts
[
0
]);
qualifiedName
=
getDefaultQualifiedNameForSinglePartName
(
context
,
parts
[
0
]);
attributeName
=
parts
[
0
];
attributeName
=
parts
[
0
];
}
}
else
if
(
parts
.
length
==
2
)
{
if
(
parts
.
length
==
2
)
{
boolean
isAttrOfActiveType
=
lookup
.
hasAttribute
(
context
,
parts
[
0
]);
boolean
isAttrOfActiveType
=
lookup
.
hasAttribute
(
context
,
parts
[
0
]);
if
(
isAttrOfActiveType
)
{
if
(
isAttrOfActiveType
)
{
attributeName
=
parts
[
0
];
attributeName
=
parts
[
0
];
...
@@ -242,10 +257,6 @@ public class IdentifierHelper {
...
@@ -242,10 +257,6 @@ public class IdentifierHelper {
}
}
}
}
private
void
updateParts
()
{
parts
=
StringUtils
.
split
(
raw
,
"."
);
}
public
String
getQualifiedName
()
{
public
String
getQualifiedName
()
{
return
qualifiedName
;
return
qualifiedName
;
}
}
...
...
repository/src/main/java/org/apache/atlas/query/RegistryBasedLookup.java
View file @
ac808af0
...
@@ -21,7 +21,6 @@ package org.apache.atlas.query;
...
@@ -21,7 +21,6 @@ package org.apache.atlas.query;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.exception.AtlasBaseException
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.TypeCategory
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
org.apache.atlas.model.typedef.AtlasBaseTypeDef
;
import
org.apache.atlas.repository.Constants
;
import
org.apache.atlas.type.*
;
import
org.apache.atlas.type.*
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
...
@@ -29,20 +28,12 @@ import java.util.*;
...
@@ -29,20 +28,12 @@ import java.util.*;
import
static
org
.
apache
.
atlas
.
discovery
.
SearchContext
.
MATCH_ALL_CLASSIFIED
;
import
static
org
.
apache
.
atlas
.
discovery
.
SearchContext
.
MATCH_ALL_CLASSIFIED
;
import
static
org
.
apache
.
atlas
.
discovery
.
SearchContext
.
MATCH_ALL_NOT_CLASSIFIED
;
import
static
org
.
apache
.
atlas
.
discovery
.
SearchContext
.
MATCH_ALL_NOT_CLASSIFIED
;
import
static
org
.
apache
.
atlas
.
discovery
.
SearchContext
.
MATCH_ALL_ENTITY_TYPES
;
import
static
org
.
apache
.
atlas
.
model
.
discovery
.
SearchParameters
.
ALL_CLASSIFICATIONS
;
import
static
org
.
apache
.
atlas
.
model
.
discovery
.
SearchParameters
.
ALL_CLASSIFICATIONS
;
import
static
org
.
apache
.
atlas
.
model
.
discovery
.
SearchParameters
.
NO_CLASSIFICATIONS
;
import
static
org
.
apache
.
atlas
.
model
.
discovery
.
SearchParameters
.
NO_CLASSIFICATIONS
;
import
static
org
.
apache
.
atlas
.
model
.
discovery
.
SearchParameters
.
ALL_ENTITY_TYPES
;
class
RegistryBasedLookup
implements
Lookup
{
class
RegistryBasedLookup
implements
Lookup
{
private
static
final
Set
<
String
>
SYSTEM_ATTRIBUTES
=
new
HashSet
<>(
Arrays
.
asList
(
Constants
.
GUID_PROPERTY_KEY
,
Constants
.
MODIFIED_BY_KEY
,
Constants
.
CREATED_BY_KEY
,
Constants
.
STATE_PROPERTY_KEY
,
Constants
.
TIMESTAMP_PROPERTY_KEY
,
Constants
.
MODIFICATION_TIMESTAMP_PROPERTY_KEY
,
Constants
.
HOME_ID_KEY
));
private
static
final
Map
<
String
,
String
>
NUMERIC_ATTRIBUTES
=
new
HashMap
<
String
,
String
>()
{{
private
static
final
Map
<
String
,
String
>
NUMERIC_ATTRIBUTES
=
new
HashMap
<
String
,
String
>()
{{
put
(
AtlasBaseTypeDef
.
ATLAS_TYPE_SHORT
,
""
);
put
(
AtlasBaseTypeDef
.
ATLAS_TYPE_SHORT
,
""
);
put
(
AtlasBaseTypeDef
.
ATLAS_TYPE_INT
,
""
);
put
(
AtlasBaseTypeDef
.
ATLAS_TYPE_INT
,
""
);
...
@@ -63,10 +54,12 @@ class RegistryBasedLookup implements Lookup {
...
@@ -63,10 +54,12 @@ class RegistryBasedLookup implements Lookup {
public
AtlasType
getType
(
String
typeName
)
throws
AtlasBaseException
{
public
AtlasType
getType
(
String
typeName
)
throws
AtlasBaseException
{
AtlasType
ret
;
AtlasType
ret
;
if
(
typeName
.
equals
IgnoreCase
(
ALL_CLASSIFICATIONS
))
{
if
(
typeName
.
equals
(
ALL_CLASSIFICATIONS
))
{
ret
=
MATCH_ALL_CLASSIFIED
;
ret
=
MATCH_ALL_CLASSIFIED
;
}
else
if
(
typeName
.
equals
IgnoreCase
(
NO_CLASSIFICATIONS
))
{
}
else
if
(
typeName
.
equals
(
NO_CLASSIFICATIONS
))
{
ret
=
MATCH_ALL_NOT_CLASSIFIED
;
ret
=
MATCH_ALL_NOT_CLASSIFIED
;
}
else
if
(
typeName
.
equals
(
ALL_ENTITY_TYPES
))
{
ret
=
MATCH_ALL_ENTITY_TYPES
;
}
else
{
}
else
{
ret
=
typeRegistry
.
getType
(
typeName
);
ret
=
typeRegistry
.
getType
(
typeName
);
}
}
...
@@ -81,15 +74,7 @@ class RegistryBasedLookup implements Lookup {
...
@@ -81,15 +74,7 @@ class RegistryBasedLookup implements Lookup {
return
""
;
return
""
;
}
}
if
(
isSystemAttribute
(
name
))
{
return
et
.
getQualifiedAttributeName
(
name
);
return
name
;
}
else
{
return
et
.
getQualifiedAttributeName
(
name
);
}
}
private
boolean
isSystemAttribute
(
String
s
)
{
return
SYSTEM_ATTRIBUTES
.
contains
(
s
);
}
}
@Override
@Override
...
@@ -99,10 +84,6 @@ class RegistryBasedLookup implements Lookup {
...
@@ -99,10 +84,6 @@ class RegistryBasedLookup implements Lookup {
return
false
;
return
false
;
}
}
if
(
isSystemAttribute
(
attributeName
))
{
return
true
;
}
AtlasType
at
=
getAttributeType
(
et
,
attributeName
);
AtlasType
at
=
getAttributeType
(
et
,
attributeName
);
if
(
at
==
null
)
{
if
(
at
==
null
)
{
return
false
;
return
false
;
...
@@ -144,8 +125,7 @@ class RegistryBasedLookup implements Lookup {
...
@@ -144,8 +125,7 @@ class RegistryBasedLookup implements Lookup {
public
boolean
hasAttribute
(
GremlinQueryComposer
.
Context
context
,
String
typeName
)
{
public
boolean
hasAttribute
(
GremlinQueryComposer
.
Context
context
,
String
typeName
)
{
AtlasEntityType
entityType
=
context
.
getActiveEntityType
();
AtlasEntityType
entityType
=
context
.
getActiveEntityType
();
return
(
entityType
!=
null
)
&&
return
getAttribute
(
entityType
,
typeName
)
!=
null
;
(
isSystemAttribute
(
typeName
)
||
entityType
.
hasAttribute
(
typeName
)
||
entityType
.
hasRelationshipAttribute
(
typeName
));
}
}
@Override
@Override
...
@@ -178,6 +158,8 @@ class RegistryBasedLookup implements Lookup {
...
@@ -178,6 +158,8 @@ class RegistryBasedLookup implements Lookup {
t
=
MATCH_ALL_CLASSIFIED
;
t
=
MATCH_ALL_CLASSIFIED
;
}
else
if
(
typeName
.
equalsIgnoreCase
(
NO_CLASSIFICATIONS
))
{
}
else
if
(
typeName
.
equalsIgnoreCase
(
NO_CLASSIFICATIONS
))
{
t
=
MATCH_ALL_NOT_CLASSIFIED
;
t
=
MATCH_ALL_NOT_CLASSIFIED
;
}
else
if
(
typeName
.
equalsIgnoreCase
(
ALL_ENTITY_TYPES
))
{
t
=
MATCH_ALL_ENTITY_TYPES
;
}
else
{
}
else
{
t
=
typeRegistry
.
getType
(
typeName
);
t
=
typeRegistry
.
getType
(
typeName
);
}
}
...
@@ -257,6 +239,11 @@ class RegistryBasedLookup implements Lookup {
...
@@ -257,6 +239,11 @@ class RegistryBasedLookup implements Lookup {
@Override
@Override
public
String
getVertexPropertyName
(
String
typeName
,
String
attrName
)
{
public
String
getVertexPropertyName
(
String
typeName
,
String
attrName
)
{
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
typeName
);
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
typeName
);
if
(
entityType
==
null
&&
StringUtils
.
equals
(
typeName
,
ALL_ENTITY_TYPES
))
{
entityType
=
MATCH_ALL_ENTITY_TYPES
;
}
AtlasStructType
.
AtlasAttribute
attribute
=
getAttribute
(
entityType
,
attrName
);
AtlasStructType
.
AtlasAttribute
attribute
=
getAttribute
(
entityType
,
attrName
);
if
(
attribute
==
null
)
{
if
(
attribute
==
null
)
{
return
null
;
return
null
;
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java
View file @
ac808af0
...
@@ -1377,19 +1377,19 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
...
@@ -1377,19 +1377,19 @@ public class AtlasEntityStoreV2 implements AtlasEntityStore {
private
void
validateNamespaceAttributes
(
AtlasVertex
entityVertex
,
AtlasEntityType
entityType
,
Map
<
String
,
Map
<
String
,
Object
>>
entityNamespaces
,
boolean
isOverwrite
)
throws
AtlasBaseException
{
private
void
validateNamespaceAttributes
(
AtlasVertex
entityVertex
,
AtlasEntityType
entityType
,
Map
<
String
,
Map
<
String
,
Object
>>
entityNamespaces
,
boolean
isOverwrite
)
throws
AtlasBaseException
{
List
<
String
>
messages
=
new
ArrayList
<>();
List
<
String
>
messages
=
new
ArrayList
<>();
Map
<
String
,
List
<
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
.
getNamespaceAttributes
();
Map
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
.
getNamespaceAttributes
();
for
(
String
nsName
:
entityNamespaces
.
keySet
())
{
for
(
String
nsName
:
entityNamespaces
.
keySet
())
{
if
(!
entityNamespaces
.
containsKey
(
nsName
))
{
if
(!
entity
Type
Namespaces
.
containsKey
(
nsName
))
{
messages
.
add
(
nsName
+
": invalid namespace for entity type "
+
entityType
.
getTypeName
());
messages
.
add
(
nsName
+
": invalid namespace for entity type "
+
entityType
.
getTypeName
());
continue
;
continue
;
}
}
List
<
AtlasNamespaceAttribute
>
entityTypeNsAttributes
=
entityTypeNamespaces
.
get
(
nsName
);
Map
<
String
,
AtlasNamespaceAttribute
>
entityTypeNsAttributes
=
entityTypeNamespaces
.
get
(
nsName
);
Map
<
String
,
Object
>
entityNsAttributes
=
entityNamespaces
.
get
(
nsName
);
Map
<
String
,
Object
>
entityNsAttributes
=
entityNamespaces
.
get
(
nsName
);
for
(
AtlasNamespaceAttribute
nsAttribute
:
entityTypeNsAttributes
)
{
for
(
AtlasNamespaceAttribute
nsAttribute
:
entityTypeNsAttributes
.
values
()
)
{
AtlasType
attrType
=
nsAttribute
.
getAttributeType
();
AtlasType
attrType
=
nsAttribute
.
getAttributeType
();
String
attrName
=
nsAttribute
.
getName
();
String
attrName
=
nsAttribute
.
getName
();
Object
attrValue
=
entityNsAttributes
.
get
(
attrName
);
Object
attrValue
=
entityNsAttributes
.
get
(
attrName
);
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
View file @
ac808af0
...
@@ -427,14 +427,14 @@ public class EntityGraphMapper {
...
@@ -427,14 +427,14 @@ public class EntityGraphMapper {
LOG
.
debug
(
"==> setNamespaceAttributes(entityVertex={}, entityType={}, entityNamespaces={}"
,
entityVertex
,
entityType
.
getTypeName
(),
entityNamespaces
);
LOG
.
debug
(
"==> setNamespaceAttributes(entityVertex={}, entityType={}, entityNamespaces={}"
,
entityVertex
,
entityType
.
getTypeName
(),
entityNamespaces
);
}
}
Map
<
String
,
List
<
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
.
getNamespaceAttributes
();
Map
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
.
getNamespaceAttributes
();
for
(
Map
.
Entry
<
String
,
List
<
AtlasNamespaceAttribute
>>
entry
:
entityTypeNamespaces
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entry
:
entityTypeNamespaces
.
entrySet
())
{
String
nsName
=
entry
.
getKey
();
String
nsName
=
entry
.
getKey
();
List
<
AtlasNamespaceAttribute
>
entityTypeNsAttributes
=
entry
.
getValue
();
Map
<
String
,
AtlasNamespaceAttribute
>
entityTypeNsAttributes
=
entry
.
getValue
();
Map
<
String
,
Object
>
entityNsAttributes
=
MapUtils
.
isEmpty
(
entityNamespaces
)
?
null
:
entityNamespaces
.
get
(
nsName
);
Map
<
String
,
Object
>
entityNsAttributes
=
MapUtils
.
isEmpty
(
entityNamespaces
)
?
null
:
entityNamespaces
.
get
(
nsName
);
for
(
AtlasNamespaceAttribute
nsAttribute
:
entityTypeNsAttributes
)
{
for
(
AtlasNamespaceAttribute
nsAttribute
:
entityTypeNsAttributes
.
values
()
)
{
String
nsAttrName
=
nsAttribute
.
getName
();
String
nsAttrName
=
nsAttribute
.
getName
();
Object
nsAttrExistingValue
=
entityVertex
.
getProperty
(
nsAttribute
.
getVertexPropertyName
(),
Object
.
class
);
Object
nsAttrExistingValue
=
entityVertex
.
getProperty
(
nsAttribute
.
getVertexPropertyName
(),
Object
.
class
);
Object
nsAttrNewValue
=
MapUtils
.
isEmpty
(
entityNsAttributes
)
?
null
:
entityNsAttributes
.
get
(
nsAttrName
);
Object
nsAttrNewValue
=
MapUtils
.
isEmpty
(
entityNsAttributes
)
?
null
:
entityNsAttributes
.
get
(
nsAttrName
);
...
@@ -480,19 +480,19 @@ public class EntityGraphMapper {
...
@@ -480,19 +480,19 @@ public class EntityGraphMapper {
LOG
.
debug
(
"==> addOrUpdateNamespaceAttributes(entityVertex={}, entityType={}, entityNamespaces={}"
,
entityVertex
,
entityType
.
getTypeName
(),
entityNamespaces
);
LOG
.
debug
(
"==> addOrUpdateNamespaceAttributes(entityVertex={}, entityType={}, entityNamespaces={}"
,
entityVertex
,
entityType
.
getTypeName
(),
entityNamespaces
);
}
}
Map
<
String
,
List
<
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
.
getNamespaceAttributes
();
Map
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
.
getNamespaceAttributes
();
if
(
MapUtils
.
isNotEmpty
(
entityTypeNamespaces
)
&&
MapUtils
.
isNotEmpty
(
entityNamespaces
))
{
if
(
MapUtils
.
isNotEmpty
(
entityTypeNamespaces
)
&&
MapUtils
.
isNotEmpty
(
entityNamespaces
))
{
for
(
Map
.
Entry
<
String
,
List
<
AtlasNamespaceAttribute
>>
entry
:
entityTypeNamespaces
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entry
:
entityTypeNamespaces
.
entrySet
())
{
String
nsName
=
entry
.
getKey
();
String
nsName
=
entry
.
getKey
();
List
<
AtlasNamespaceAttribute
>
entityTypeNsAttributes
=
entry
.
getValue
();
Map
<
String
,
AtlasNamespaceAttribute
>
entityTypeNsAttributes
=
entry
.
getValue
();
Map
<
String
,
Object
>
entityNsAttributes
=
entityNamespaces
.
get
(
nsName
);
Map
<
String
,
Object
>
entityNsAttributes
=
entityNamespaces
.
get
(
nsName
);
if
(
MapUtils
.
isEmpty
(
entityNsAttributes
))
{
if
(
MapUtils
.
isEmpty
(
entityNsAttributes
))
{
continue
;
continue
;
}
}
for
(
AtlasNamespaceAttribute
nsAttribute
:
entityTypeNsAttributes
)
{
for
(
AtlasNamespaceAttribute
nsAttribute
:
entityTypeNsAttributes
.
values
()
)
{
String
nsAttrName
=
nsAttribute
.
getName
();
String
nsAttrName
=
nsAttribute
.
getName
();
if
(!
entityNsAttributes
.
containsKey
(
nsAttrName
))
{
if
(!
entityNsAttributes
.
containsKey
(
nsAttrName
))
{
...
@@ -528,12 +528,12 @@ public class EntityGraphMapper {
...
@@ -528,12 +528,12 @@ public class EntityGraphMapper {
LOG
.
debug
(
"==> removeNamespaceAttributes(entityVertex={}, entityType={}, entityNamespaces={}"
,
entityVertex
,
entityType
.
getTypeName
(),
entityNamespaces
);
LOG
.
debug
(
"==> removeNamespaceAttributes(entityVertex={}, entityType={}, entityNamespaces={}"
,
entityVertex
,
entityType
.
getTypeName
(),
entityNamespaces
);
}
}
Map
<
String
,
List
<
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
.
getNamespaceAttributes
();
Map
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
.
getNamespaceAttributes
();
if
(
MapUtils
.
isNotEmpty
(
entityTypeNamespaces
)
&&
MapUtils
.
isNotEmpty
(
entityNamespaces
))
{
if
(
MapUtils
.
isNotEmpty
(
entityTypeNamespaces
)
&&
MapUtils
.
isNotEmpty
(
entityNamespaces
))
{
for
(
Map
.
Entry
<
String
,
List
<
AtlasNamespaceAttribute
>>
entry
:
entityTypeNamespaces
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entry
:
entityTypeNamespaces
.
entrySet
())
{
String
nsName
=
entry
.
getKey
();
String
nsName
=
entry
.
getKey
();
List
<
AtlasNamespaceAttribute
>
entityTypeNsAttributes
=
entry
.
getValue
();
Map
<
String
,
AtlasNamespaceAttribute
>
entityTypeNsAttributes
=
entry
.
getValue
();
if
(!
entityNamespaces
.
containsKey
(
nsName
))
{
// nothing to remove for this namespace
if
(!
entityNamespaces
.
containsKey
(
nsName
))
{
// nothing to remove for this namespace
continue
;
continue
;
...
@@ -541,7 +541,7 @@ public class EntityGraphMapper {
...
@@ -541,7 +541,7 @@ public class EntityGraphMapper {
Map
<
String
,
Object
>
entityNsAttributes
=
entityNamespaces
.
get
(
nsName
);
Map
<
String
,
Object
>
entityNsAttributes
=
entityNamespaces
.
get
(
nsName
);
for
(
AtlasNamespaceAttribute
nsAttribute
:
entityTypeNsAttributes
)
{
for
(
AtlasNamespaceAttribute
nsAttribute
:
entityTypeNsAttributes
.
values
()
)
{
// if (entityNsAttributes is empty) remove all attributes in this namespace
// if (entityNsAttributes is empty) remove all attributes in this namespace
// else remove the attribute only if its given in entityNsAttributes
// else remove the attribute only if its given in entityNsAttributes
if
(
MapUtils
.
isEmpty
(
entityNsAttributes
)
||
entityNsAttributes
.
containsKey
(
nsAttribute
.
getName
()))
{
if
(
MapUtils
.
isEmpty
(
entityNsAttributes
)
||
entityNsAttributes
.
containsKey
(
nsAttribute
.
getName
()))
{
...
...
repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
View file @
ac808af0
...
@@ -678,21 +678,26 @@ public class EntityGraphRetriever {
...
@@ -678,21 +678,26 @@ public class EntityGraphRetriever {
if
(
CollectionUtils
.
isNotEmpty
(
attributes
))
{
if
(
CollectionUtils
.
isNotEmpty
(
attributes
))
{
for
(
String
attrName
:
attributes
)
{
for
(
String
attrName
:
attributes
)
{
String
nonQualifiedAttrName
=
toNonQualifiedName
(
attrName
);
AtlasAttribute
attribute
=
entityType
.
getAttribute
(
attrName
);
if
(
ret
.
hasAttribute
(
attrName
))
{
continue
;
}
AtlasAttribute
attribute
=
entityType
.
getAttribute
(
nonQualifiedAttrName
);
if
(
attribute
==
null
)
{
if
(
attribute
==
null
)
{
attribute
=
entityType
.
getRelationshipAttribute
(
nonQualifiedAttrName
,
null
);
attrName
=
toNonQualifiedName
(
attrName
);
if
(
ret
.
hasAttribute
(
attrName
))
{
continue
;
}
attribute
=
entityType
.
getAttribute
(
attrName
);
if
(
attribute
==
null
)
{
attribute
=
entityType
.
getRelationshipAttribute
(
attrName
,
null
);
}
}
}
Object
attrValue
=
getVertexAttribute
(
entityVertex
,
attribute
);
Object
attrValue
=
getVertexAttribute
(
entityVertex
,
attribute
);
if
(
attrValue
!=
null
)
{
if
(
attrValue
!=
null
)
{
ret
.
setAttribute
(
nonQualifiedA
ttrName
,
attrValue
);
ret
.
setAttribute
(
a
ttrName
,
attrValue
);
}
}
}
}
}
}
...
@@ -765,15 +770,15 @@ public class EntityGraphRetriever {
...
@@ -765,15 +770,15 @@ public class EntityGraphRetriever {
}
}
private
void
mapNamespaceAttributes
(
AtlasVertex
entityVertex
,
AtlasEntity
entity
)
throws
AtlasBaseException
{
private
void
mapNamespaceAttributes
(
AtlasVertex
entityVertex
,
AtlasEntity
entity
)
throws
AtlasBaseException
{
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
entity
.
getTypeName
());
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
entity
.
getTypeName
());
Map
<
String
,
List
<
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
!=
null
?
entityType
.
getNamespaceAttributes
()
:
null
;
Map
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entityTypeNamespaces
=
entityType
!=
null
?
entityType
.
getNamespaceAttributes
()
:
null
;
if
(
MapUtils
.
isNotEmpty
(
entityTypeNamespaces
))
{
if
(
MapUtils
.
isNotEmpty
(
entityTypeNamespaces
))
{
for
(
Map
.
Entry
<
String
,
List
<
AtlasNamespaceAttribute
>>
entry
:
entityTypeNamespaces
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
entry
:
entityTypeNamespaces
.
entrySet
())
{
String
nsName
=
entry
.
getKey
();
String
nsName
=
entry
.
getKey
();
List
<
AtlasNamespaceAttribute
>
nsAttributes
=
entry
.
getValue
();
Map
<
String
,
AtlasNamespaceAttribute
>
nsAttributes
=
entry
.
getValue
();
for
(
AtlasNamespaceAttribute
nsAttribute
:
nsAttributes
)
{
for
(
AtlasNamespaceAttribute
nsAttribute
:
nsAttributes
.
values
()
)
{
Object
nsAttrValue
=
mapVertexToAttribute
(
entityVertex
,
nsAttribute
,
null
,
false
,
false
);
Object
nsAttrValue
=
mapVertexToAttribute
(
entityVertex
,
nsAttribute
,
null
,
false
,
false
);
if
(
nsAttrValue
!=
null
)
{
if
(
nsAttrValue
!=
null
)
{
...
...
repository/src/test/java/org/apache/atlas/repository/store/graph/v2/AtlasNamespaceDefStoreV2Test.java
View file @
ac808af0
...
@@ -25,7 +25,7 @@ import org.apache.atlas.model.typedef.AtlasNamespaceDef;
...
@@ -25,7 +25,7 @@ import org.apache.atlas.model.typedef.AtlasNamespaceDef;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasStructDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.model.typedef.AtlasTypesDef
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasEntityType
;
import
org.apache.atlas.type.AtlasNamespaceType
;
import
org.apache.atlas.type.AtlasNamespaceType
.AtlasNamespaceAttribute
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasType
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.apache.atlas.type.AtlasTypeRegistry
;
import
org.testng.Assert
;
import
org.testng.Assert
;
...
@@ -84,7 +84,7 @@ public class AtlasNamespaceDefStoreV2Test {
...
@@ -84,7 +84,7 @@ public class AtlasNamespaceDefStoreV2Test {
createNamespaceTypes
(
namespaceName
);
createNamespaceTypes
(
namespaceName
);
Assert
.
assertEquals
(
typeRegistry
.
getAllNamespaceDefs
().
size
(),
1
);
Assert
.
assertEquals
(
typeRegistry
.
getAllNamespaceDefs
().
size
(),
1
);
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
"hive_table"
);
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
"hive_table"
);
Map
<
String
,
List
<
AtlasNamespaceType
.
AtlasNamespaceAttribute
>>
m1
=
entityType
.
getNamespaceAttributes
();
Map
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
m1
=
entityType
.
getNamespaceAttributes
();
Assert
.
assertEquals
(
m1
.
get
(
namespaceName
).
size
(),
2
);
Assert
.
assertEquals
(
m1
.
get
(
namespaceName
).
size
(),
2
);
}
}
...
@@ -117,7 +117,7 @@ public class AtlasNamespaceDefStoreV2Test {
...
@@ -117,7 +117,7 @@ public class AtlasNamespaceDefStoreV2Test {
updateNamespaceTypeDefs
(
namespaceDef
);
updateNamespaceTypeDefs
(
namespaceDef
);
typeDefStore
.
updateTypesDef
(
typesDefs
);
typeDefStore
.
updateTypesDef
(
typesDefs
);
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
"hive_table"
);
AtlasEntityType
entityType
=
typeRegistry
.
getEntityTypeByName
(
"hive_table"
);
Map
<
String
,
List
<
AtlasNamespaceType
.
AtlasNamespaceAttribute
>>
m1
=
entityType
.
getNamespaceAttributes
();
Map
<
String
,
Map
<
String
,
AtlasNamespaceAttribute
>>
m1
=
entityType
.
getNamespaceAttributes
();
Assert
.
assertEquals
(
m1
.
get
(
namespaceName
).
size
(),
3
);
Assert
.
assertEquals
(
m1
.
get
(
namespaceName
).
size
(),
3
);
}
}
...
...
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