JSDOSession Catalog error: multiple read operations specifie

Posted by Marko Myllymäki on 25-Feb-2016 07:14

It seems that the catalog for a rest service can contain only one read operation for each resource, otherwise JSDOSession gives an error message when trying to add the catalog (jsdosession.addCatalog).

I am trying to create these kind of rest services:

/customers     for returning all customers
/customers/1   for returning customer #1

I was hoping to handle these in a single class (customers.cls) having two read methods, one for each case. Now it seems that because of the above mentioned restriction, I have to create two separate classes and also change the rest URIs for something like this:

/customerlist    for returning all customers
/customers/1     for returning customer #1

Or have I missed something?

I am currently using the static catalog file (service.json) which is generated by Development Studio based on the class annotations. OpenEdge version is 11.6. I already tried to use a rest call to dynamically create/modify the catalog instead of using the static file and it seems to work but is there an easier workaround (e.g. with annotation)? Currently the annotations for those read methods are like this:

@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
@progress.service.resourceMapping(type="REST", operation="read", URI="?filter=~{filter~}", alias="", mediaType="application/json").

@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").
@progress.service.resourceMapping(type="REST", operation="read", URI="/~{customerid~}", alias="", mediaType="application/json").

The latter one is used for returning a specific customer. 

 

Posted by egarcia on 25-Feb-2016 08:44

Hello,

The catalog for the Data Object service can only contain one READ operation.

Even though the Data Object service is based on REST, it uses a prescriptive approach with CRUD operations at the collection level (ex: /customers) rather than at a the element level (ex: /customers/1).

(In this case, to access a specific element, you would specify a filter.)

Depending on your client requirements, you might not need to have a method to access the element.

Could you provide information on what clients you are planning to use in addition to the JSDO?

Are you using Kendo UI and the Progress Data Service in Telerik Platform?

Are you planning to use other clients that perform direct REST calls?

The JSDO and the Kendo UI DataSource of type JSDO have support for CRUD operations, Submit and Invoke.

You would not be able to consume the element level operation.

If you use the Kendo UI DataSource of type JSON or other clients you would be able to consume the element level operation.

Thereare some few possible approaches to do what you are looking for:

1) Add an invoke operation to the Business Entity.

The annotations for the method would look like the following:

@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").

@progress.service.resourceMapping(type="REST", operation="invoke", URI="/info/~{customerid~}", alias="", mediaType="application/json").

I think that you could remove "info" from the URI but I have not tested it.

Invoke operations can be called from the JSDO. Please notice that invoke operations handled as PUT request.

2) Even though this is something that is not generally done, you could try adding two READ methods in the way that you were doing and then use the @openapi.openedge.method.property annotation for the method to override the type so that the catalog would only see one READ operation.

Example:

   @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").

   @progress.service.resourceMapping(type="REST", operation="read", URI="/~{customerid~}", alias="", mediaType="application/json")

   @openapi.openedge.method.property (name="type", value="myread").

   METHOD PUBLIC VOID ReadCustomer1(

3) You could create your a REST wrapper or a WebSpeed wrapper to the Business Entity.

REST (it seems that you are already familiar with it): community.progress.com/.../2190

WebSpeed: community.progress.com/.../2677

I hope this helps.

All Replies

Posted by egarcia on 25-Feb-2016 08:44

Hello,

The catalog for the Data Object service can only contain one READ operation.

Even though the Data Object service is based on REST, it uses a prescriptive approach with CRUD operations at the collection level (ex: /customers) rather than at a the element level (ex: /customers/1).

(In this case, to access a specific element, you would specify a filter.)

Depending on your client requirements, you might not need to have a method to access the element.

Could you provide information on what clients you are planning to use in addition to the JSDO?

Are you using Kendo UI and the Progress Data Service in Telerik Platform?

Are you planning to use other clients that perform direct REST calls?

The JSDO and the Kendo UI DataSource of type JSDO have support for CRUD operations, Submit and Invoke.

You would not be able to consume the element level operation.

If you use the Kendo UI DataSource of type JSON or other clients you would be able to consume the element level operation.

Thereare some few possible approaches to do what you are looking for:

1) Add an invoke operation to the Business Entity.

The annotations for the method would look like the following:

@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").

@progress.service.resourceMapping(type="REST", operation="invoke", URI="/info/~{customerid~}", alias="", mediaType="application/json").

I think that you could remove "info" from the URI but I have not tested it.

Invoke operations can be called from the JSDO. Please notice that invoke operations handled as PUT request.

2) Even though this is something that is not generally done, you could try adding two READ methods in the way that you were doing and then use the @openapi.openedge.method.property annotation for the method to override the type so that the catalog would only see one READ operation.

Example:

   @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false").

   @progress.service.resourceMapping(type="REST", operation="read", URI="/~{customerid~}", alias="", mediaType="application/json")

   @openapi.openedge.method.property (name="type", value="myread").

   METHOD PUBLIC VOID ReadCustomer1(

3) You could create your a REST wrapper or a WebSpeed wrapper to the Business Entity.

REST (it seems that you are already familiar with it): community.progress.com/.../2190

WebSpeed: community.progress.com/.../2677

I hope this helps.

Posted by Marko Myllymäki on 25-Feb-2016 09:09

Hi, thanks a lot for your quick response. We use Kendo UI + JSDO (but not Telerik Platform) and currently there are no other clients to consume those services. Basically, my intent was just to follow the commonly used RESTful API practices, but its not a big deal if we have to use a somewhat different API.

I have to check these links you sent and try those suggestions. Thanks!

This thread is closed