Re: ERXPrefixQualifierTraversal usage example (@daveeed)
Re: ERXPrefixQualifierTraversal usage example (@daveeed)
- Subject: Re: ERXPrefixQualifierTraversal usage example (@daveeed)
- From: Kieran Kelleher <email@hidden>
- Date: Thu, 10 Jun 2010 17:09:12 -0400
On Jun 10, 2010, at 4:57 PM, Chuck Hill wrote:
>
> On Jun 10, 2010, at 1:48 PM, Kieran Kelleher wrote:
>
>> (In reply to David's tweet - answer too long for twitter!.... and twitlonger makes the sentences wrap too much....)
>> __________________________________________________________
>> David's question:
>> @kierankelleher would you mind showing me an example of how it is used? It sounds like something that could be used with D2W for permissions
>>
>>
>> __________________________________________________________
>> @daveeed
>>
>> For example, in one of my apps, the User entity has a "customersQualifier()" method that returns a qualifier appropriate to the Role of the user that qualifies the user's access to Customer objects in the system. The Qualifier is constructed differently for customer users, inside sales, sysadmin, graphic design, etc. The qualifier itself is based on Customer attributes and in itself is useful only for fetches against the Customer entity.
>>
>> Now let's say I have Barcoded Coupons on Mailers, and someone is scanning Coupon redemptions into a web form for tracking and reporting of advertizement effectiveness and let's say I want to make sure that the person scanning has access to the customer that is related to those coupons. And in this scenario, let's say the relationship keyPath from Coupon Entity to Customer Entity is like this:
>>
>> coupon -> mailer.campaign.program.location.customer
>>
>> So when the coupon ID is scanned in and submitted, I can create a Qualifier for the Coupon based on the ID, and then I need an auxiliary security qualifier to ensure the logged in user has access to the related Customer so I would do sth like these steps:
>>
>> EOQualifier qCoupon = Coupon.XKEY_SERIAL_ID.eq( scannedCouponID );
>> EOQualifier qCustomer = currentUser.customerQualifier();
>>
>> // Since qCustomer qualifies Customer entities and we want to qualify the Coupon that we are fetching based on
>> // the user's restricted access to a specific set of Customer EOs... prefix the customer qualifier to make it a coupon qualifier
>> // that restricts the fetch to coupons related to the customers that this user has access to....
>> qCustomer = ERXPrefixQualifierTraversal.prefixQualifierWithKey( "mailer.campaign.program.location.customer" );
>
>> qCustomer = ERXPrefixQualifierTraversal.prefixQualifierWithKey(qCustomer, "mailer.campaign.program.location.customer" );
>
> you mean?
Exactly :) This was typed into email - not Eclipse! Thnks for spotting that Chuck. .... (BTW Chuck, you are missing out on the "brief" Wo discussions on the Twitter Wo group)
>
>> EOQualifier qFinal = ERXQ.and( qCoupon, qCustomer );
>>
>> Coupon c = ( fetch with qualifier 'qFinal' )
>>
>>
>> I hope that explains the usage of ERXPrefixQualifierTraversal better ....
>>
>> Regards, Kieran
>> _______________________________________________
>> 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
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
>
_______________________________________________
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