|
Re: [texo] how to set references in json [message #900114 is a reply to message #899957] |
Sat, 04 August 2012 07:18 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Erdal,
A reference should also be a json object, so something like this:
{
a: {id: 1},
"_eclass": "mypackage|B"
}
Maybe you have to add the _eclass attribute to the 'a' json object, but can you try first without to see if it works.
gr. Martin
On 08/03/2012 10:28 AM, Erdal Karaca wrote:
> I have the following model:
>
> Class A
> - id : long
>
> Class B
> - a : A
>
>
>
> How do I set a reference to A in B when preparing the json string for HTTP PUT?
>
> I tried to put the long id, but texo complains:
>
>
> java.lang.ClassCastException: java.lang.Integer cannot be cast to org.json.JSONObject
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertSingleEReference(BaseJSONModelConverter.java:247)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convertContent(BaseJSONModelConverter.java:214)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:108)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convert(BaseJSONModelConverter.java:103)
> at org.eclipse.emf.texo.server.service.json.JSONServiceContext.getRequestData(JSONServiceContext.java:91)
> at org.eclipse.emf.texo.server.service.UpdateInsertModelOperation.internalExecute(UpdateInsertModelOperation.java:42)
> at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:48)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doPost(WebServiceHandler.java:107)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doPut(WebServiceHandler.java:121)
> at org.eclipse.emf.texo.server.web.WebServiceServlet.doPut(WebServiceServlet.java:73)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at
> org.eclipse.emf.texo.server.store.CurrentEntityManagerRequestFilter.doFilter(CurrentEntityManagerRequestFilter.java:65)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
> at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
> at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
> at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
> at java.lang.Thread.run(Unknown Source)
>
>
> My json string looks like this:
>
>
> {
> a: 1,
> "_eclass": "mypackage|B"
> }
>
>
> Note: an instance of A is available and 1 is the id of that instance.
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [texo] how to set references in json [message #900443 is a reply to message #900132] |
Tue, 07 August 2012 06:37 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Erdal,
I published a new build which should support this without the _eclass property also, can you retry?
gr. Martin
On 08/04/2012 02:16 PM, Erdal Karaca wrote:
> Martin,
> The reference update works with the _eclass property set.
>
> E.g.
>
>
> {
> a: {"id": 1, "_eclass": "mypackage|A"},
> "_eclass": "mypackage|B"
> }
>
>
> Martin taal wrote on Sat, 04 August 2012 03:18
>> Hi Erdal,
>> A reference should also be a json object, so something like this:
>> {
>> a: {id: 1},
>> "_eclass": "mypackage|B"
>> }
>>
>> Maybe you have to add the _eclass attribute to the 'a' json object, but can you try first without to see if it works.
>>
>> gr. Martin
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03583 seconds