[ 
https://issues.apache.org/jira/browse/ATLAS-4410?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17417502#comment-17417502
 ] 

VINAYAK MARRAIYA commented on ATLAS-4410:
-----------------------------------------

Hi

I tried this scenario and the issue seems to be the way the relationship 
instance was created and specifically the way the LinkInformation attribute was 
specified.

Following are the json's to create relationships
1. Creating EntityDef json
2. Creating Entity json
3. Creating RelationshipDef json
4. Creating Relationship instance json


Step-1

Creating EntityDef

POST - http://localhost:21000/api/atlas/v2/types/typedefs

 
{code:java}
{
 "entityDefs": [
 {
 "category": "ENTITY",
 "name": "type_a"
 },
 {
 "category": "ENTITY",
 "name": "type_b"
 }
 ]
}{code}
 


Step-2

Creating Entity

POST - http://localhost:21000/api/atlas/v2/entity/bulk

 
{code:java}
{
 "entities": [
 {
 "typeName": "type_a",
 "guid": "-72ddefefS2UY"
 },
 {
 "typeName": "type_b",
 "guid": "-JL1HddDOfdf"
 }
 ]
}{code}
 


Step-3

Creating RelationshipDef

POST - http://localhost:21000/api/atlas/v2/types/typedefs

 
{code:java}
{
 "relationshipDefs": [
 {
 "propagateTags": "ONE_TO_TWO",
 "description": "description ASSOCIATION between type5 and type6",
 "relationshipCategory": "ASSOCIATION",
 "typeVersion": "1.0",
 "attributeDefs": [
 {
 "name": "LinkInformation",
 "typeName": "string",
 "isOptional": true,
 "cardinality": "SINGLE",
 "valuesMinCount": 0,
 "valuesMaxCount": 1,
 "isUnique": false,
 "isIndexable": false,
 "includeInNotification": false,
 "searchWeight": -1
 }
 ],
 "endDef2": {
 "name": "type_b_rel_attribute",
 "isLegacyAttribute": false,
 "isContainer": false,
 "cardinality": "SINGLE",
 "type": "type_b",
 "description": "description with name: type_2_rel_attribute"
 },
 "endDef1": {
 "name": "type_a_rel_attribute",
 "isLegacyAttribute": false,
 "isContainer": false,
 "cardinality": "SET",
 "type": "type_a",
 "description": "description with name: type_1_rel_attribute"
 },
 "guid": "-2fsdfjhsewl04",
 "name": "association_type_a_and_type_b"
 }
 ]
}
 
{code}

Step-4

Creating Relationship instance

POST- http://localhost:21000/api/atlas/v2/relationship

 
{code:java}
{
 "typeName": "association_type_a_and_type_b",
 "end1": {
 "typeName": "type_a",
 "guid": "b4dae5e8-a606-4e41-9ce3-8f35245f389e" (guid of type_a entity)
 },
 "propagateTags": "NONE",
 "provenanceType": 0,
 "propagatedClassifications": [],
 "end2": {
 "typeName": "type_b",
 "guid": "23c2f3c1-dd74-4190-a6d1-b012c44cbb6d" (guid of type_b entity)
 },
 "blockedPropagatedClassifications": [],
 "guid": "-bjbfdfddfeffef",
 "attributes": {
 "LinkInformation": "TestingInformation"
 }
}{code}
 

 

Following is the output of the above API call.

Output of type_a entity

GET - http://localhost:21000/api/atlas/v2/entity/guid/\{guid of type_a entity}

 
{code:java}
{
 "referredEntities": {},
 "entity": {
 "typeName": "type_a",
 "guid": "b4dae5e8-a606-4e41-9ce3-8f35245f389e",
 "isIncomplete": false,
 "status": "ACTIVE",
 "createdBy": "admin",
 "updatedBy": "admin",
 "createTime": 1632121151626,
 "updateTime": 1632121151626,
 "version": 0,
 "relationshipAttributes": {
 "type_a_rel_attribute": [
 {
 "guid": "23c2f3c1-dd74-4190-a6d1-b012c44cbb6d",
 "typeName": "type_b",
 "entityStatus": "ACTIVE",
 "relationshipType": "association_type_a_and_type_b",
 "relationshipGuid": "ec64783a-58d7-4265-87d6-c1535ce2d9b7",
 "relationshipStatus": "ACTIVE",
 "relationshipAttributes": {
 "typeName": "association_type_a_and_type_b",
 "attributes": {
 "LinkInformation": "TestingInformation"
 }
 }
 }
 ]
 },
 "labels": []
 }
}
 
{code}

Output of type_b entity

GET - http://localhost:21000/api/atlas/v2/entity/guid/\{guid of type_b entity}
{code:java}
{
 "referredEntities": {},
 "entity": {
 "typeName": "type_b",
 "guid": "23c2f3c1-dd74-4190-a6d1-b012c44cbb6d",
 "isIncomplete": false,
 "status": "ACTIVE",
 "createdBy": "admin",
 "updatedBy": "admin",
 "createTime": 1632121151626,
 "updateTime": 1632121151626,
 "version": 0,
 "relationshipAttributes": {
 "type_b_rel_attribute": {
 "guid": "b4dae5e8-a606-4e41-9ce3-8f35245f389e",
 "typeName": "type_a",
 "entityStatus": "ACTIVE",
 "relationshipType": "association_type_a_and_type_b",
 "relationshipGuid": "ec64783a-58d7-4265-87d6-c1535ce2d9b7",
 "relationshipStatus": "ACTIVE",
 "relationshipAttributes": {
 "typeName": "association_type_a_and_type_b",
 "attributes": {
 "LinkInformation": "TestingInformation"
 }
 }
 }
 },
 "labels": []
 }
}{code}
As you can see, LinkInformation is specified under "attributes" and when you 
search for the entity using GUID as you mentioned in jira, you will be able to 
see the value of "LinkInformation".

 

CC - [~mandar_va]

> Name relationship link between two different types in Apache Atlas
> ------------------------------------------------------------------
>
>                 Key: ATLAS-4410
>                 URL: https://issues.apache.org/jira/browse/ATLAS-4410
>             Project: Atlas
>          Issue Type: Test
>          Components:  atlas-core
>    Affects Versions: 2.0.0
>            Reporter: Saqib
>            Priority: Blocker
>             Fix For: 2.0.0
>
>
> I am trying to name relationship link (by using attributeDefs) between two 
> different types. The relationship is now registered in Atlas and definition 
> fetch results as below:
>  
> {{{
> "category": "RELATIONSHIP",
> "guid": "9b1059c3-8707-46db-ae3c-e8d1b4ef6333",
> "createdBy": "admin",
> "updatedBy": "admin",
> "createTime": 1625233869809,
> "updateTime": 1625496519772,
> "version": 6,
> "name": "field_assignment",
> "description": "someDescription.",
> "typeVersion": "1.0",
> "attributeDefs": [
>     \{
>         "name": "LinkInformation",
>         "typeName": "string",
>         "isOptional": true,
>         "cardinality": "SINGLE",
>         "valuesMinCount": 0,
>         "valuesMaxCount": 1,
>         "isUnique": false,
>         "isIndexable": false,
>         "includeInNotification": false,
>         "searchWeight": -1
>     }
> ],
> "relationshipCategory": "ASSOCIATION",
> "propagateTags": "NONE",
> "endDef1": \{
>     "type": "custom_dataset",
>     "name": "fields",
>     "isContainer": false,
>     "cardinality": "SET",
>     "isLegacyAttribute": false
> },
> "endDef2": \{
>     "type": "custom_field",
>     "name": "datasets",
>     "isContainer": false,
>     "cardinality": "SET",
>     "isLegacyAttribute": false
> }}}
> }
> Now, I am trying to create a relationship between two types while defining an 
> Entity for either type like
>  
> {{{
> "entities": [
>     \{
>         "typeName": "custom_field",
>         "createdBy": "admin",
>         "guid": -1000,
>         "attributes": {
>             "name": "type",
>             "datasets": [
>                 {
>                     "guid": "-200",
>                     "typeName": "custom_dataset"
>                 }
>             ]
>         },
>         "classifications": [],
>         
>     }
> ],
> "referredEntities": \{
>     "-200": {
>         "guid": "-200",
>         "typeName": "custome_dataset",
>         "relationshipAttributes" : {"LinkInformation": "key"},
>         
>         "attributes": \{
>             "qualifiedName": "test"
>         }
>     }
> }}}
> }
> Through, while executing this, I don't see any error and entities are created 
> but {{LinkInformation}} is null by simply doing a search by {{GUID}} for 
> entities.
>  
> {{...
> "relationshipAttributes": \{
>                     "typeName": "field_assignment",
>                     "attributes": {
>                         "LinkInformation": null
>                     }
>                 }
> ...}}
> I am not able to find a good documentation anywhere for this. Can anyone help?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to