Sorry, I meant if user is a public variable or accessor, not client, in the second paragraph below.
-- Mark
 
On May 21, 2006, at 9:59 AM, Mark Morris wrote:

Hello Reid,

Ken's post has already pointed out how your approach, on the surface anyway, raises a little warning flag.  The code for what he's talking about would be something like:

NSArray bindings = new NSArray( session().valueForKey("user.client") );
qual = EOQualifier.qualifierWithQualifierFormat("client = %@", bindings );
    fs = new EOFetchSpecification("Process", qual, null);

You try and store and deal with complete objects when you can, and in this case EOF will query based on the join attribute you provided in the (possibly hypothetical) "client" relationship. Minor points, note that you can construct and NSArray of one object without going through the Object step, and that you don't need to cast to Session to use valueForKey.  However, if client is a public variable or (preferably) accessor method in your Session, you could change that line to:

NSArray bindings = new NSArray( ((Session)session()).user().client() );

If Bob (in your example) has multiple clients, however, the above doesn't make sense.  If that's the case, and he can choose the client he's currently dealing with, you could just add a currentClient variable and accessors (returning a Client object) to the Session to indicate his choice.  Then the code becomes:

NSArray bindings = new NSArray( ((Session)session()).currentClient() );
qual = EOQualifier.qualifierWithQualifierFormat("client = %@", bindings );
    fs = new EOFetchSpecification("Process", qual, null);

Hope this helps.

Regards,
Mark

On May 21, 2006, at 4:06 AM, Reid Bundonis wrote:

All,

Forgive me for asking what should be obvious (it is the weekend and I left the books at the office, I am a new dad which equals no sleep and brain dead, and the dog ate my homework).  

I am trying to construct an EOQualifier to grab a value from the session store and use that in its search.  For example, I have entities: User, Client, Process & Result.  When the user logs in, they are stored in the session so I can extract stuff about them later on.  This is simple using WOString and the session.user.client.<key> binding.  However, for what ever reason, I can not wrap my empty head around how to call a value from the session and use it for a search.  As an example, there is a user Bob, that is a member of Pretend Co., and has three processes, Run, Spin, & Sit.  These processes have results.  When Bob logs in, I know all about him since he is now in the session store and I can pull values about him throughout the app.  However, I want to build a qualifier with string values from the session store so I can do searches, such as Bob logs in and in the super I request the user's client name from the session and use it in a qualifier to search for all processes related to that client.

For simplicity, I am working in Main and have confirmed that I can access the session store by using WOString and viewing values from the logged user.  Now, I want to create a search that will pull results of Process using the User's Client.  Usually, I just use a bindings with valueForKey and toss it at the qualifier.  But that is for entities in the db.  However, I am not sure how to code the session request.  In my brain it would be something like:


NSArray bindings = new NSArray( new Object [] { (Session)session().valueForKey("user.client.clientName") } );

qual = EOQualifier.qualifierWithQualifierFormat("clientName = %@", bindings );
       
    fs = new EOFetchSpecification("Process", qual, null);

Obviously, that does not work.  If anyone can point a confused session using newbie in the right direction I would appreciate it.  Hope all are enjoying the weekend.  Thanks in advance.

R- _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:

This email sent to [EMAIL PROTECTED]

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to archive@mail-archive.com

Reply via email to