Le 2013-04-03 à 05:40, Giles Palmer <[email protected]> a écrit :
> Hi
>
> Thanks for that.
>
> I was actually trying to see if there was a way to ensure that eo's on their
> own or as part of a relationship get returned in the same form by having
> standard filters for each type of eo.
>
> include(String keyName, ERXKeyFilter existingFilter) is exactly what I was
> looking for.
>
> So for my transaction filter with its to 1 organisation I can do:
>
> ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
> filter.include("organisation", organisationFilter());
Avoid using strings like this, if you rename your relationship, you will not
see that you have a string to change. Either use
include(ERXKey key, ERXKeyFilter existingFilter)
or :
include(MyEntity.ORGANISATION_KEY, organisationFilter())
> Where organisationFilter() is a filter determining how organisations should
> be filtered.
>
> Thanks
>
> Giles
>
>> You shouldn't hard-code your key values. It should look more like this:
>>
>> ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
>> filter.exclude(MyEntity.MY_ATTRIBUTE);
>> filter.exclude(MyEntity.MY_OTHER_ATTRIBUTE);
>> return filter;
>>
>> If you want to include a to-one relationship, but none of its attributes
>> (just type and id):
>>
>> ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
>> filter.include(MyEntity.MY_TO_ONE_RELATIONSHIP_OBJECT);
>> return filter;
>>
>> If you want to include a to-one relationship, and a couple attributes:
>>
>> ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
>> filter.include(MyEntity.MY_TO_ONE_RELATIONSHIP_OBJECT).include(MyOtherEntity.ATTRIBUTE);
>> filter.include(MyEntity.MY_TO_ONE_RELATIONSHIP_OBJECT).include(MyOtherEntity.ATTRIBUTE2);
>> return filter;
>>
>> -G
>>
>> On Apr 2, 2013, at 7:55 AM, Giles Palmer <[email protected]> wrote:
>>
>>> Hi
>>>
>>> I am just starting my first ERRest app and playing with ERXKeyFilters.
>>>
>>> I have an OrganisationController using a filter and I remove unwanted
>>> attributes from the rest response with:
>>>
>>> ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
>>> filter.exclude("dateTimeStamp","autoNotify","notifyMethod","webSitePassword","website");
>>>
>>> This works great, however if I then have a TransactionController and a
>>> Transaction object that has a to-1 Organisation relationship how best do I
>>> also remove the unwanted Organisation attributes from the rest response? At
>>> the moment I have the below:
>>>
>>> ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
>>> filter.include("organisation").includeAttributes();
>>> filter.exclude("organisation.dateTimeStamp","organisation.autoNotify","organisation.notifyMethod","organisation.webSitePassword","organisation.website");
>>>
>>>
>>> but I can't help thinking there is a better way to ensure consistency about
>>> what attributes are contained in the response for various EOs when they
>>> form parts of responses that contain relationship objects. Is there a
>>> better way of achieving this?
>>>
>>> Thanks
>>>
>>> Giles
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/mastermind%40knuckleheads.net
>>>
>>> This email sent to [email protected]
>>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/probert%40macti.ca
>
> This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]