-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/72046/#review219463
-----------------------------------------------------------



In addition to the added REST APIs we need a REST API to 
setNamespaceAttributes, which the UI will be using to set namespace attributes. 
Server-side code should compare before and after state of namespace attributes 
and identify namespace attributes added/updated/removed and call appropriate 
internal methods for them.

Please make sure to validate the following cases:

```
1. Add Namespace attribute:
---------------------------
* ns2: attr5 = val5
* ns3: attr6 = val6

Before:
______________________
| ns1 | attr1 = val1 |         ns1.attr1 = val1
|     | attr2 = val2 |         ns1.attr2 = val2
|-----|--------------|         ns2.attr3 = val3
| ns2 | attr3 = val3 |         ns2.attr4 = val4
|     | attr4 = val4 |
----------------------

After:
_______________________
| ns1 | attr1 = val1  |
|     | attr2 = val2  |        ns1.attr1 = val1
|-----|---------------|        ns1.attr2 = val2
| ns2 | attr3 = val3  |        ns2.attr3 = val3
|     | attr4 = val4  |        ns2.attr4 = val4
|     | attr5 = val5 +|        ns2.attr5 = val5 +
|-----|-------------- |        ns3.attr6 = val6 +
| ns3 | attr6 = val6 +|
-----------------------


2. Remove Namespace attribute:
------------------------------
* ns1: attr2 = val2
* ns2: attr4 = val4

Before:
_______________________
| ns1 | attr1 = val1  |
|     | attr2 = val2 x|        ns1.attr1 = val1
|-----|---------------|        ns1.attr2 = val2 x
| ns2 | attr3 = val3  |        ns2.attr3 = val3
|     | attr4 = val4 x|        ns2.attr4 = val4 x
|     | attr5 = val5  |        ns2.attr5 = val5
|-----|---------------|        ns3.attr6 = val6
| ns3 | attr6 = val6  |
-----------------------

After:
______________________
| ns1 | attr1 = val1 |
|-----|--------------|        ns1.attr1 = val1
| ns2 | attr3 = val3 |        ns2.attr3 = val3
|     | attr5 = val5 |        ns2.attr5 = val5
|-----|--------------|        ns3.attr6 = val6
| ns3 | attr6 = val6 |
----------------------


3. Update Namespace attribute:
------------------------------
* ns2: attr3 = val333
* ns3: attr6 = val666

Before:
______________________
| ns1 | attr1 = val1 |
|-----|--------------|        ns1.attr1 = val1
| ns2 | attr3 = val3 |        ns2.attr3 = val3
|     | attr5 = val5 |        ns2.attr5 = val5
|-----|--------------|        ns3.attr6 = val6
| ns3 | attr6 = val6 |
----------------------

After:
__________________________
| ns1 | attr1 = val1     |
|-----|------------------|        ns1.attr1 = val1
| ns2 | attr3 = val333 * |        ns2.attr3 = val333 *
|     | attr5 = val5     |        ns2.attr5 = val5
|-----|------------------|        ns3.attr6 = val666 *
| ns3 | attr6 = val666 * |
--------------------------


4. Set Namespace Attribute:
---------------------------

Before: N1
______________________
| ns1 | attr1 = val1 |         ns1.attr1 = val1
|     | attr2 = val2 |         ns1.attr2 = val2
|-----|--------------|         ns2.attr3 = val3
| ns2 | attr3 = val3 |         ns2.attr4 = val4
|     | attr4 = val4 |
----------------------

After: N2
________________________
| ns1 | attr1 = val1   |
|-----|----------------|        ns1.attr1 = val1
| ns2 | attr3 = val333 |        ns2.attr3 = val333
|     | attr5 = val5   |        ns2.attr5 = val5
|-----|----------------|        ns3.attr6 = val666
| ns3 | attr6 = val666 |
------------------------


Added:
------
N2 - N1

Updated:
--------
N1 = N2

Removed:
--------
N1 - N2
```

- Sarath Subramanian


On Jan. 31, 2020, 4:40 a.m., Mandar Ambawane wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/72046/
> -----------------------------------------------------------
> 
> (Updated Jan. 31, 2020, 4:40 a.m.)
> 
> 
> Review request for atlas, Ashutosh Mestry, Madhan Neethiraj, Nixon Rodrigues, 
> and Sarath Subramanian.
> 
> 
> Bugs: ATLAS-3534
>     https://issues.apache.org/jira/browse/ATLAS-3534
> 
> 
> Repository: atlas
> 
> 
> Description
> -------
> 
> Created separate endpoints to associate Namespace attributes to entity
> 
> 
> Diffs
> -----
> 
>   common/src/main/java/org/apache/atlas/repository/Constants.java 0b28243 
>   intg/src/main/java/org/apache/atlas/AtlasErrorCode.java 2054513 
>   intg/src/main/java/org/apache/atlas/model/instance/AtlasEntity.java 1b033b9 
>   intg/src/main/java/org/apache/atlas/type/AtlasNamespaceType.java a141d4a 
>   intg/src/main/java/org/apache/atlas/type/AtlasTypeRegistry.java 97e27d0 
>   
> repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasEntityStore.java
>  928c70d 
>   
> repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java
>  25284e9 
>   
> repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java
>  e427a59 
>   
> repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
>  dc4c399 
>   webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java 6845121 
> 
> 
> Diff: https://reviews.apache.org/r/72046/diff/8/
> 
> 
> Testing
> -------
> 
> Basic testing is done.
> 
> Create NamespaceDef sports:
> 
> curl --location --request POST 
> 'http://localhost:21000/api/atlas/v2/types/typedefs' \
> --header 'Content-Type: application/json' \
> --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
> --data-raw '{
>     "namespaceDefs": [
>         {
>             "name": "sports",
>             "description": "Sample sports",
>             "serviceType": "NAMESPACES",
>             "typeVersion": "1.0",
>             "attributeDefs": [
>                 {
>                     "name": "sports_name",
>                     "typeName": "string",
>                     "options": {
>                         "applicableEntityTypes": "[\"hdfs_path\", 
> \"hive_table\"]",
>                         "maxStrLength": "50"
>                     },
>                     "cardinality": "SINGLE",
>                     "isIndexable": true,
>                     "isOptional": true,
>                     "includeInNotification": true,
>                     "isUnique": false
>                 },
>                 {
>                     "name": "no_of_players",
>                     "typeName": "int",
>                     "options": {
>                         "applicableEntityTypes": "[\"hdfs_path\", 
> \"hive_column\"]"
>                     },
>                     "cardinality": "SINGLE",
>                     "isIndexable": true,
>                     "isOptional": true,
>                     "includeInNotification": true,
>                     "isUnique": false
>                 }
>             ]
>         }
>     ]
> }'
> 
> 
> Create NamespaceDef vehicle:
> 
> curl --location --request POST 
> 'http://localhost:21000/api/atlas/v2/types/typedefs' \
> --header 'Content-Type: application/json' \
> --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
> --data-raw '{
>     "namespaceDefs": [
>         {
>             "name": "vehicle",
>             "description": "Sample vehicle",
>             "serviceType": "NAMESPACES",
>             "typeVersion": "1.0",
>             "attributeDefs": [
>                 {
>                     "name": "vehicle_name",
>                     "typeName": "string",
>                     "options": {
>                         "applicableEntityTypes": "[\"hdfs_path\", 
> \"hive_table\"]",
>                         "maxStrLength": "50"
>                     },
>                     "cardinality": "SINGLE",
>                     "isIndexable": true,
>                     "isOptional": true,
>                     "includeInNotification": true,
>                     "isUnique": false
>                 },
>                 {
>                     "name": "no_of_wheels",
>                     "typeName": "int",
>                     "options": {
>                         "applicableEntityTypes": "[\"hdfs_path\", 
> \"hive_column\"]"
>                     },
>                     "cardinality": "SINGLE",
>                     "isIndexable": true,
>                     "isOptional": true,
>                     "includeInNotification": true,
>                     "isUnique": false
>                 }
>             ]
>         }
>     ]
> }'
> 
> 
> Create hdfs_path entity:
> 
> curl --location --request POST 'http://localhost:21000/api/atlas/v2/entity' \
> --header 'Content-Type: application/json' \
> --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
> --data-raw '{
>     "entity": {
>         "guid": "-1",
>         "typeName": "hdfs_path",
>         "attributes": {
>             "clusterName": "cm",
>             "description": "desc",
>             "location": "localhost",
>             "name": "hdfs_path_entity1",
>             "owner": "admin",
>             "ownerType": "USER",
>             "qualifiedName": "hdfs_path_entity1@cm",
>           "path": "local_path"
>         }
>     }
> }'
> 
> 
> Associate namespace attributes with the created entity
> 
> 
> curl --location --request POST 
> 'http://localhost:21000/api/atlas/v2/entity/guid/ea633224-ccfe-4573-9060-43190cd9531a/namespaces'
>  \
> --header 'Content-Type: application/json' \
> --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
> --data-raw '{
> "sports":{
>       "sports_name":"cricket",
>       "no_of_players":11
> },
> "vehicle":{
>       "vehicle_name": "Car"
> }
> }'
> 
> 
> Add one more namespace attribute in the entity
> 
> curl --location --request POST 
> 'http://localhost:21000/api/atlas/v2/entity/guid/ea633224-ccfe-4573-9060-43190cd9531a/namespaces'
>  \
> --header 'Content-Type: application/json' \
> --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
> --data-raw '{
> "vehicle":{
>       "no_of_wheels": 4
> }
> }'
> 
> 
> Update sports_name attribute with new value as Hockey
> 
> curl --location --request PUT 
> 'http://localhost:21000/api/atlas/v2/entity/guid/ea633224-ccfe-4573-9060-43190cd9531a/namespaces'
>  \
> --header 'Content-Type: application/json' \
> --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
> --data-raw '{
> "sports":{
>       "sports_name": "Hockey"
> }
> }'
> 
> 
> Delete vehicle.vehicle_name namespace attribute
> 
> curl --location --request DELETE 
> 'http://localhost:21000/api/atlas/v2/entity/guid/ea633224-ccfe-4573-9060-43190cd9531a/namespaces'
>  \
> --header 'Content-Type: application/json' \
> --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
> --data-raw '{
> "vehicle":{
>       "vehicle_name": "Car"
> }
> }'
> 
> 
> Thanks,
> 
> Mandar Ambawane
> 
>

Reply via email to