Joan,
A slightly better approach is to provide repository entity as a separate entry
in “entities” and refer to the repository in database entity using its temp-id,
as shown below.
This approach will allow an entity be referenced from multiple entities using
its temp-id (instead of adding the entire entity details in each such
reference).
Madhan
{
"message": {
"type": "ENTITY_FULL_UPDATE",
"user": "user",
"entities": [
{
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
"id": {
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "-14568879465268",
"typeName": "database",
"state": "ACTIVE",
"version": 0
},
"typeName": "database",
"values": {
"dbName": "Test7",
"description": "Test db7",
"name": "Testdb7",
"origin_app": "origin",
"origin_username": "externalusername",
"owner": "owner",
"qualifiedName": "Testdb5",
"repository": {
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "-14568879465269",
"typeName": "repository",
"state": "ACTIVE",
"version": 0
}
},
"traitNames": [],
"traits": {}
},
{
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
"id": {
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "-14568879465269",
"typeName": "repository",
"state": "ACTIVE",
"version": 0
},
"typeName": "repository",
"values": {
"qualifiedName": "repository01"
},
"traitNames": [],
"traits": {}
}
]
},
"version": {
"version": "1.0.0"
}
}
From: Madhan Neethiraj <[email protected]>
Date: Thursday, January 4, 2018 at 11:18 PM
To: "[email protected]" <[email protected]>
Subject: Re: Relating to an entity using uniqueAttributes
Joan,
To refer to another entity In Atlas hook notifications, add the referred entity
details as shown below. Also, I would suggest using ENTITY_FULL_UPDATE as
message type (instead of ENTITY_CREATE).
{
"message": {
"type": "ENTITY_FULL_UPDATE",
"user": "user",
"entities": [
{
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
"id": {
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "-14568879465268",
"typeName": "database",
"state": "ACTIVE",
"version": 0
},
"typeName": "database",
"values": {
"dbName": "Test7",
"description": "Test db7",
"name": "Testdb7",
"origin_app": "origin",
"origin_username": "externalusername",
"owner": "owner",
"qualifiedName": "Testdb5",
"repository": {
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
"id": {
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "-14568879465269",
"typeName": "repository",
"state": "ACTIVE",
"version": 0
},
"typeName": "repository",
"values": {
"qualifiedName": "repository01"
},
"traitNames": [],
"traits": {}
}
},
"traitNames": [],
"traits": {}
}
]
},
"version": {
"version": "1.0.0"
}
}
Hope this helps.
Madhan
From: Jo MailingList <[email protected]>
Reply-To: "[email protected]" <[email protected]>
Date: Tuesday, January 2, 2018 at 9:54 AM
To: "[email protected]" <[email protected]>
Subject: Relating to an entity using uniqueAttributes
Hello everyone,
I am trying to create a database that in my type model has a reference to a
repository. I want to create it by sending a message to the ATLAS_HOOK topic to
the Kafka broker as follows:
{
"version": {
"version": "1.0.0"
},
"message": {
"entities": [{
"jsonClass":
"org.apache.atlas.typesystem.json.InstanceSerialization$_Reference",
"id": {
"jsonClass": "org.apache.atlas.typesystem.json.InstanceSerialization$_Id",
"id": "-14568879465268",
"version": 0,
"typeName": "database",
"state": "ACTIVE"
},
"typeName": "database",
"values": {
"qualifiedName": "Testdb5",
"repository": {
"jsonClass":"org.apache.atlas.typesystem.json.InstanceSerialization$_Id"
"version": 0,
"typeName": "repository",
"uniqueAttributes": {
"qualifiedName": "repository01"
},
"state": "ACTIVE"
},
"owner": "owner",
"description": "Test db7",
"name": "Testdb7",
"dbName": "Test7",
"origin_app": "origin",
"origin_username": "externalusername"
},
"traitNames": [],
"traits": {}
}],
"type": "ENTITY_CREATE",
"user": "user"
}
}
The database type expects a repository attribute of the type repository as a
reference. It works when I give the guid of the reference directly but when
trying my example it fails and it seems to me that it does not process the
information I provide as uniqueAttributes. What I see in the application.log is
the following stacktrace:
org.apache.atlas.exception.AtlasBaseException: ObjectId is not valid
AtlasObjectId{guid='null', typeName='repository', uniqueAttributes={}}
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityGraphDiscoveryV1.visitReference(AtlasEntityGraphDiscoveryV1.java:186)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityGraphDiscoveryV1.visitAttribute(AtlasEntityGraphDiscoveryV1.java:234)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityGraphDiscoveryV1.visitEntity(AtlasEntityGraphDiscoveryV1.java:327)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityGraphDiscoveryV1.walkEntityGraph(AtlasEntityGraphDiscoveryV1.java:354)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityGraphDiscoveryV1.discover(AtlasEntityGraphDiscoveryV1.java:142)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityGraphDiscoveryV1.discoverEntities(AtlasEntityGraphDiscoveryV1.java:69)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1.preCreateOrUpdate(AtlasEntityStoreV1.java:523)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1.createOrUpdate(AtlasEntityStoreV1.java:174)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1.createOrUpdate(AtlasEntityStoreV1.java:193)
at
org.apache.atlas.repository.store.graph.v1.AtlasEntityStoreV1$$FastClassBySpringCGLIB$$80c00649.invoke(<generated>)
This message makes me suspicious that Atlas is not processing my input message
correctly and not reading my uniqueAttributes information.
Does someone have a hint of what I am doing wrong or if this is a currrent
issue inside Atlas or it is not a supported feature right now?
Thank you very much,
Best regards,
Joan