Re: Little help with a qualifier
Re: Little help with a qualifier
- Subject: Re: Little help with a qualifier
- From: Gustavo Pizano <email@hidden>
- Date: Tue, 14 Jul 2009 18:13:06 +0200
Grr.. my mistake.. I will see how can I change it. or kepp it in mind for future apps. sorry about that.
about the model.
WG is a table that contains information about .wg files for localizations. but I was asked to divided that wg file into a relational database. htis .wg file its a XML file that its being parsed to the db.
so I put in the entity WG all the basic information about the file, like name and the other attributes.. this .wg has many <file> tags, and inside the <file> tags there are many <textItmes> tags and so on. with their own leafs .
so what I did was to split into a separate Entity each MAYOR tag, so I had at the end. WG, FILE TEXTITEM TRANSLATIONSET(the att base is the enlgish word),TRANSFROMBASE( which will hold the translations for a given TRANSLATIONSET) don't ask me why, I said that only one TRANSLATIONSET has one TRANSFROMBASE, but here I was explained that depending on the context, i.e the word Open can be one way or another.
Then each TRANSFROMBASE (tranlations) are done by USERS, so one USER can make many translations (TRANSFROMBSE) but the Admin assign which TRANSLATIONSET goes to each USER, maybe I used the name bad I would have called better TRANSLATORS.
So the Admin could assign to Gustavo the TRANSLATIONSET with base "Open" but because of destiny is not always fair, Dave was the one who translated it. .. so the money goes for you.
What chuck tells me is to make something like
EOFetchSpecification f = new EOFetchSpecification() .. and f.setDistinct(true)..Imat home now so I dont have my "journal" with sample code lines like this ones. so sorry if Im doing it wrong.
I hope you have a better idea of what Im doing.. I think the EOModel shows what I really want to do, maybe (I would say, for sure )I just got messy with the naming.
G.
On Tue, Jul 14, 2009 at 4:23 PM, David Avendasora
<email@hidden> wrote:
On Jul 14, 2009, at 9:47 AM, Gustavo Pizano wrote:
One step closer to the result...
EOQualifier qual = WG.TO_TRANSLATION_SETS.dot(WGxTS.T_RANSLATIONSET.dot(TRANSLATIONSET.TO_USER_KEY)).eq(((Session)session()).authenticatedUser());
Ouch. That is just hard to read.
Must you use all caps for the Entity names? They should follow Java naming conventions. So TRANSLATIONSET should be TranslationSet. Otherwise it is very hard to tell the difference between a Constant value (which should be ALL_CAPS and a class name.)
that worked, I had to some modifications... I mean by wokr it didn;t blew up. but the resutls are not what I expected.
i.e: I have one WG and that WG has many TRANSLATIONSETS, but from those TRANSLATIONSETS only 4 are asigned to me.
so the what I woudl expect to see is only one WG name in the left list, (because in this example there only one WG), and when I click that name I would see 4 TRANSLATIONSETS (which are the ones assigned to me)
What Im receving is, 4 times the same WG name in the left list, and when I select any it will display all of the TRANSLATIONSET that WG has.
Well, you could always do an ERXArrayUtilities.arrayWithoutDuplicates(yourArray)
:S:S:S:.
But I guess this puts me closer to a proper solution... or not ? :(:S.
I'm concerned that your Model does not accurately reflect the reality of the situation. Maybe it does, but many of the key Entities have very vague names so it is hard to tell.
WG?
TranslationSet?
TranFromBase?
Can you describe the context of the application and how objects of each entity relate to objects in the real world?
I'm concerned that you are having to do a lot of complicated EO stuff because the EOModel doesn't really reflect reality. If users have an obvious relationship to WGs in reality, then the modeled relationship should be more simple as well. This isn't always true, but...
Dave
G.
On Tue, Jul 14, 2009 at 3:34 PM, David Avendasora
<email@hidden> wrote:
On Jul 14, 2009, at 9:12 AM, Gustavo Pizano wrote:
yep... one question that qual I shold apply it to a fetchWGs(qual) ?
Yes, that would work, or if you already had an array of WGs, you could use the EOQualifier.filteredArrayWithQualifier(arrayOfWGs, qual)
Dave
I didn't get when you say that applied to an NSArray.
G.
On Tue, Jul 14, 2009 at 2:45 PM, David Avendasora
<email@hidden> wrote:
I think I may have messed that one up. If it doesn't work, try this:
EOQualifier qual = WG.TSXWG.dot(TSxWG.TRANSLATIONSET.dot(TranslationSet.TOUSER_KEY)).contains(((Session)session()).authenticatedUser());
Dave
On Jul 14, 2009, at 8:35 AM, Gustavo Pizano wrote:
WO thanks Dave, I will give it a try right now
G.
On Tue, Jul 14, 2009 at 2:31 PM, David Avendasora
<email@hidden> wrote:
Gustavo,
This uses Wonder's ERXKey syntax which I like the best:
EOQualifier qual = WG.TSXWG.dot(TSxWG.TRANSLATIONSET.dot(TranslationSet.TOUSER)).contains(((Session)session()).authenticatedUser());
That should give you a qualifier that when applied to an NSArray of WG objects will filter it down to only the WGs that are associated with the authenticatedUser().
Dave
On Jul 14, 2009, at 7:04 AM, Gustavo Pizano wrote:
Yep ((Session)session()).authenticatedUser is returning a USER.
I know that when I try to qualify a User given a name I will gt a good qualifier..
now as Chuck said I need all TRANSLATIONSET for that given user. The relationship between TRANSLATIONSET and USER is called toUser, so Im using the
EOQualifier tsQual = new ERXExistsQualifier(ERXQ.
equals(USER.NAME_KEY,((Session)session()).authenticatedUser().name()), TRANSLATIONSET.TO_USER_KEY);
to get that.
now if I potition myseld to get all the WG that contains the TRANSLATIONSET with a specific USER I must use tsQual, so I tought I could use it from _WG but the relationship between WG and TRANSLATIONSET is a many-to-many having a join table WGxTS, and this table has no name, that;s hy I was thinking that Im in the wrong place. no?
G.
On Tue, Jul 14, 2009 at 12:53 PM, Paul Hoadley
<email@hidden> wrote:
Hi Gustavo, On 14/07/2009, at 5:14 PM, Gustavo Pizano wrote:
Ok this is what I did. but is not working, I have an error in the generated sql or somehting.. becuase it says
java.lang.IllegalStateException: sqlStringForKeyValueQualifier: attempt to generate SQL for er.extensions.qualifiers.ERXKeyValueQualifier (name = 'Gustavo') failed because attribute identified by key 'name' was not reachable from from entity 'WGxTS'
I guess is becaus Im trying to search in the wrong place..
It's not an error in the generated SQL, it's an error in your qualifiers. To be honest, I can't follow your model, but EOF is telling you the problem: you've tried to qualify an entity on a key that doesn't exist in that entity. Specifically, 'WGxTS' has no key called 'name'.
As an aside, earlier you wrote:
but so far what I have from the user is the name... so I will need to get the userID something like toUser.NAME.eq(name).
Yet here: EOQualifier tsQual = new ERXExistsQualifier(ERXQ.equals(USER.NAME_KEY,((Session)session()).authenticatedUser().name()), TRANSLATIONSET.TO_USER_KEY);
Don't you have the User? What's Session.authenticatedUser() returning if it's not a User?
--
Paul.
w http://logicsquad.net/
h http://paul.hoadley.name/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
This email sent to email@hidden
_______________________________________________
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