• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Map an Object in ERRest
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Map an Object in ERRest


  • Subject: Re: Map an Object in ERRest
  • From: Rodrigo de Sousa <email@hidden>
  • Date: Thu, 09 Jun 2016 23:37:02 -0400

Hello Samuel,

Thanks for your answer.

I forgot to mention, but in my case I got this problem to create the object.

The method that I got the error is this:
ERXRouteController.create(String entityName, ERXKeyFilter filter)

I know that I can use the filter to use with primitive attributes but it not work with Object.

Do you have any idea in my case to create an object and don't change my old API?

Thanks again,
Rodrigo.

2016-06-08 20:06 GMT-04:00 Samuel Pelletier <email@hidden>:
Hi,

I think your only solution is to create a custom NSDictionary with the required key and return it like this:

NSMutableDictionary<String, Object> result = new NSMutableDictionary<String, Object>();
result.setObjectForKey(someObject.federalDocument(), "federalDocument");
result.setObjectForKey(someObject.customer(), "customer");

return response(result, ERXKeyFilter.filterWithAllRecursive());

This will returns all attributes and relationships of customer, adjust the filter if required.

Samuel


Le 8 juin 2016 à 16:22, Rodrigo de Sousa <email@hidden> a écrit :

Hello,

I am using the ERRest in my project and I am having a problem. I changed some attributes to a new relationship, but I want to discover if there is a way to not change my old API request.

For example:

Old request:
{
    "customer": {
        "email": "email@hidden",
        "name": "Rodrigo de Sousa",
        "phone": "11 1234-5678"
    },
    "federalDocument":"123123123"
}

Now, I have a new relationship called Sale Detail that have a customer.

New request:
{
        "saleDetail": {
              "customer": {
                    "email": "email@hidden",
                    "name": "Rodrigo de Sousa",
                    "phone": "11 1234-5678"
         },
         "federalDocument":"123123123"
    }
}

I know that I can use the ERXKeyFilter.filterWithAllRecursive() and add in the map like in the example below. It works well with primitive attributes, but I can use some like this with an Object (in my case, the Customer)? Is possible to continue using the old request and not break my API?

Example:
filter.addMap("saleDetail.federalDocument", "federalDocument"); 

With this example, I can use the federalDocument in the old way. I tested here and it works.

I can use some like in the example below?

Example:
filter.addMap("saleDetail.customer", "customer"); 

When I tried to use this, this exception was thrown:

java.lang.IllegalArgumentException: There is no to-one relationship named 'saleDetail.customer' on 'CommercialInvoice'.
at er.rest.ERXRestRequestNode.updateObjectWithFilter(ERXRestRequestNode.java:1296)
at er.rest.ERXRestRequestNode.createObjectWithFilter(ERXRestRequestNode.java:863)
at er.rest.routes.ERXRouteController.create(ERXRouteController.java:670)
at er.rest.routes.ERXRouteController.create(ERXRouteController.java:638)

Thanks for any help!
Rodrigo.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Map an Object in ERRest
      • From: Samuel Pelletier <email@hidden>
References: 
 >Map an Object in ERRest (From: Rodrigo de Sousa <email@hidden>)
 >Re: Map an Object in ERRest (From: Samuel Pelletier <email@hidden>)

  • Prev by Date: Re: Intalling WO on Ubuntu 16.04 Xenial
  • Next by Date: Re: Intalling WO on Ubuntu 16.04 Xenial
  • Previous by thread: Re: Map an Object in ERRest
  • Next by thread: Re: Map an Object in ERRest
  • Index(es):
    • Date
    • Thread