You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@atlas.apache.org by Herman Yu <he...@teeupdata.com> on 2015/10/01 22:18:27 UTC

creating a new entity/associating an entity to another one

Hi Everyone,

I am implementing a model in v0.5, and I would like to know the correct syntax of creating a new entity, and associating an entity to another one.

I have two objects/classTypes defined as:


{
      "typeName”:”BusinessMetadata",
      "attributeDefinitions":[
        {
          "name”:”Category",
          "dataTypeName”:”string",
          …
        },
        ...
      ]
 }
…

{
      "typeName”:"Asset",
      "attributeDefinitions":[
        {
          "name”:"busMeta",
          "dataTypeName”:"BusinessMetadata",
          …
        },
        ...
      ]
    },

and i would like to create an entity of “BusinessMetaData” and then associate it with an existing entity of Asset, what is the correct syntax/json definition using REST API http:// …api/atlas/entities -x PUT . Or is there a documentation which can help?

I tried to create the entity of “BusinessMetaData” through REST API using an entity definition of :
{
	  "typeName":"BusinessMetaData",
	  "values":{
	    "category":"MiddleOffice",
            …..
 	  }
}

but got the following error:

2015-10-01 16:13:02,228 ERROR - [177746769@qtp-159259014-74 - 82c2ab59-556a-4e62-979c-ef7711059fdb:] ~ Unable to deserialize json={       "typeName":"BusinessMetaData",          "values":{        "category":"MiddleOffice",      "term":"FX Trade",      "description":"FX Trades of Middle Office"    }} (DefaultMetadataService:244)
org.json4s.ParserUtil$ParseException: unknown token  
Near: {  
        at org.json4s.native.JsonParser$Parser.fail(JsonParser.scala:207)
        at org.json4s.native.JsonParser$Parser.nextToken(JsonParser.scala:294)
        at org.json4s.native.JsonParser$$anonfun$1.apply(JsonParser.scala:159)
        at org.json4s.native.JsonParser$$anonfun$1.apply(JsonParser.scala:117)
        at org.json4s.native.JsonParser$.parse(JsonParser.scala:105)
        at org.json4s.native.JsonParser$.parse(JsonParser.scala:53)
        at org.json4s.native.Serialization$.read(Serialization.scala:71)
……
2015-10-01 16:13:02,228 ERROR - [177746769@qtp-159259014-74 - 82c2ab59-556a-4e62-979c-ef7711059fdb:] ~ Unable to persist entity instance (EntityResource:112)
java.lang.IllegalArgumentException: Unable to deserialize json
        at org.apache.atlas.services.DefaultMetadataService.deserializeClassInstance(DefaultMetadataService.java:245)
        at org.apache.atlas.services.DefaultMetadataService.createEntity(DefaultMetadataService.java:229)
        at org.apache.atlas.web.resources.EntityResource.submit(EntityResource.java:96)
        at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)


Thanks
Herman


Re: creating a new entity/associating an entity to another one

Posted by Herman Yu <he...@teeupdata.com>.
Thanks Seetharam, see my comments below.

On Oct 1, 2015, at 4:22 PM, Seetharam Venkatesh <ve...@innerzeal.com> wrote:

> The easiest way to do this is to use the type system API. Please look at
> the examples in QuickStart.java or any integration test under webapp module.
> 
[HY] I am doing some POC work, and would like to use REST API for quick test. Is it possible?


> If you plan to associate 2 entities, say A and B together, then A needs to
> compose B. However, you want to associate traits (tags), then you can
> associate any arbitrary Trait to any entity. There are APIs for both.
[HY] I can associated Traits to any entity. To associate two Entities. Would you please elaborate "A has to compose B”. the relationship in my test is quite similar to the hive model, many "hive_table” are associated a “hive_db”, in my test, many “Asset” are associated to “BusinessMetaData”.

what is the best way for me got get the details json definition so to use REST API through command line, or I have to go with type system API using Java?

Thanks
Herman.

> 
> On Thu, Oct 1, 2015 at 1:18 PM Herman Yu <he...@teeupdata.com> wrote:
> 
>> Hi Everyone,
>> 
>> I am implementing a model in v0.5, and I would like to know the correct
>> syntax of creating a new entity, and associating an entity to another one.
>> 
>> I have two objects/classTypes defined as:
>> 
>> 
>> {
>>      "typeName”:”BusinessMetadata",
>>      "attributeDefinitions":[
>>        {
>>          "name”:”Category",
>>          "dataTypeName”:”string",
>>          …
>>        },
>>        ...
>>      ]
>> }
>> …
>> 
>> {
>>      "typeName”:"Asset",
>>      "attributeDefinitions":[
>>        {
>>          "name”:"busMeta",
>>          "dataTypeName”:"BusinessMetadata",
>>          …
>>        },
>>        ...
>>      ]
>>    },
>> 
>> and i would like to create an entity of “BusinessMetaData” and then
>> associate it with an existing entity of Asset, what is the correct
>> syntax/json definition using REST API http:// …api/atlas/entities -x PUT
>> . Or is there a documentation which can help?
>> 
>> I tried to create the entity of “BusinessMetaData” through REST API using
>> an entity definition of :
>> {
>>          "typeName":"BusinessMetaData",
>>          "values":{
>>            "category":"MiddleOffice",
>>            …..
>>          }
>> }
>> 
>> but got the following error:
>> 
>> 2015-10-01 16:13:02,228 ERROR - [177746769@qtp-159259014-74 -
>> 82c2ab59-556a-4e62-979c-ef7711059fdb:] ~ Unable to deserialize json={
>> "typeName":"BusinessMetaData",          "values":{
>> "category":"MiddleOffice",      "term":"FX Trade",      "description":"FX
>> Trades of Middle Office"    }} (DefaultMetadataService:244)
>> org.json4s.ParserUtil$ParseException: unknown token
>> Near: {
>>        at org.json4s.native.JsonParser$Parser.fail(JsonParser.scala:207)
>>        at
>> org.json4s.native.JsonParser$Parser.nextToken(JsonParser.scala:294)
>>        at
>> org.json4s.native.JsonParser$$anonfun$1.apply(JsonParser.scala:159)
>>        at
>> org.json4s.native.JsonParser$$anonfun$1.apply(JsonParser.scala:117)
>>        at org.json4s.native.JsonParser$.parse(JsonParser.scala:105)
>>        at org.json4s.native.JsonParser$.parse(JsonParser.scala:53)
>>        at org.json4s.native.Serialization$.read(Serialization.scala:71)
>> ……
>> 2015-10-01 16:13:02,228 ERROR - [177746769@qtp-159259014-74 -
>> 82c2ab59-556a-4e62-979c-ef7711059fdb:] ~ Unable to persist entity instance
>> (EntityResource:112)
>> java.lang.IllegalArgumentException: Unable to deserialize json
>>        at
>> org.apache.atlas.services.DefaultMetadataService.deserializeClassInstance(DefaultMetadataService.java:245)
>>        at
>> org.apache.atlas.services.DefaultMetadataService.createEntity(DefaultMetadataService.java:229)
>>        at
>> org.apache.atlas.web.resources.EntityResource.submit(EntityResource.java:96)
>>        at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
>>        at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> 
>> 
>> Thanks
>> Herman
>> 
>> 


Re: creating a new entity/associating an entity to another one

Posted by Seetharam Venkatesh <ve...@innerzeal.com>.
The easiest way to do this is to use the type system API. Please look at
the examples in QuickStart.java or any integration test under webapp module.

If you plan to associate 2 entities, say A and B together, then A needs to
compose B. However, you want to associate traits (tags), then you can
associate any arbitrary Trait to any entity. There are APIs for both.

On Thu, Oct 1, 2015 at 1:18 PM Herman Yu <he...@teeupdata.com> wrote:

> Hi Everyone,
>
> I am implementing a model in v0.5, and I would like to know the correct
> syntax of creating a new entity, and associating an entity to another one.
>
> I have two objects/classTypes defined as:
>
>
> {
>       "typeName”:”BusinessMetadata",
>       "attributeDefinitions":[
>         {
>           "name”:”Category",
>           "dataTypeName”:”string",
>           …
>         },
>         ...
>       ]
>  }
> …
>
> {
>       "typeName”:"Asset",
>       "attributeDefinitions":[
>         {
>           "name”:"busMeta",
>           "dataTypeName”:"BusinessMetadata",
>           …
>         },
>         ...
>       ]
>     },
>
> and i would like to create an entity of “BusinessMetaData” and then
> associate it with an existing entity of Asset, what is the correct
> syntax/json definition using REST API http:// …api/atlas/entities -x PUT
> . Or is there a documentation which can help?
>
> I tried to create the entity of “BusinessMetaData” through REST API using
> an entity definition of :
> {
>           "typeName":"BusinessMetaData",
>           "values":{
>             "category":"MiddleOffice",
>             …..
>           }
> }
>
> but got the following error:
>
> 2015-10-01 16:13:02,228 ERROR - [177746769@qtp-159259014-74 -
> 82c2ab59-556a-4e62-979c-ef7711059fdb:] ~ Unable to deserialize json={
>  "typeName":"BusinessMetaData",          "values":{
> "category":"MiddleOffice",      "term":"FX Trade",      "description":"FX
> Trades of Middle Office"    }} (DefaultMetadataService:244)
> org.json4s.ParserUtil$ParseException: unknown token
> Near: {
>         at org.json4s.native.JsonParser$Parser.fail(JsonParser.scala:207)
>         at
> org.json4s.native.JsonParser$Parser.nextToken(JsonParser.scala:294)
>         at
> org.json4s.native.JsonParser$$anonfun$1.apply(JsonParser.scala:159)
>         at
> org.json4s.native.JsonParser$$anonfun$1.apply(JsonParser.scala:117)
>         at org.json4s.native.JsonParser$.parse(JsonParser.scala:105)
>         at org.json4s.native.JsonParser$.parse(JsonParser.scala:53)
>         at org.json4s.native.Serialization$.read(Serialization.scala:71)
> ……
> 2015-10-01 16:13:02,228 ERROR - [177746769@qtp-159259014-74 -
> 82c2ab59-556a-4e62-979c-ef7711059fdb:] ~ Unable to persist entity instance
> (EntityResource:112)
> java.lang.IllegalArgumentException: Unable to deserialize json
>         at
> org.apache.atlas.services.DefaultMetadataService.deserializeClassInstance(DefaultMetadataService.java:245)
>         at
> org.apache.atlas.services.DefaultMetadataService.createEntity(DefaultMetadataService.java:229)
>         at
> org.apache.atlas.web.resources.EntityResource.submit(EntityResource.java:96)
>         at sun.reflect.GeneratedMethodAccessor37.invoke(Unknown Source)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>
>
> Thanks
> Herman
>
>