Right - so, I'm using the template from that link called: "Consolidated WOnder Templates with "Clazz" pattern (Ramsey Gurley)"
I downloaded the two java template files and put them in a folder in my project, and set that folder in the eogen -- the templates actually do have some of the clazz stuff, they certainly generate something different so I figured the eogen is using the ones I downloaded but.... I don't see a public interface for "Key" defining the attributes and relationships through that path? That's why I figured I have the wrong template? I get errors on the CoreLogic user preferences, which seems to want to store sort orderings. Shouldn't my _User have attributes basically available under _User.Key.whatever ? On Dec 17, 2010, at 3:05 PM, Ramsey Gurley wrote: > > On Dec 17, 2010, at 2:29 PM, David Holt wrote: > >> I linked to the templates earlier in the thread. >> >> >> On 2010-12-17, at 11:24 AM, Jesse Tayler wrote: >> >>> What template are you generating your EOs from? >>> >>> I'm using _WonderEntity and I don't see clazz stuff in my _Classes >>> >>> I look at BugTracker's eogen and I see it using _Entity from CorBusiness >>> but that template seems to be a regular old EO template. >>> > > > > Quoth the David: > >> http://wiki.objectstyle.org/confluence/display/WOL/EOGenerator+Templates+and+Additions >> >> Look for: >> >> Consolidated WOnder Templates with "Clazz" pattern (Ramsey Gurley) > > Also available at: > > https://r2d2w.svn.sourceforge.net/svnroot/r2d2w/trunk/ERR2d2w/Support/Templates/ > > I'd like to make the generics work better on inherited entities with the > clazz stuff. Right now all the generics will return the most super > superclass on child entities. I think that can be fixed in the generated > _EntityClazz{} but I haven't had time to try it yet. > > Ramsey > > > >>> On Dec 16, 2010, at 9:25 AM, Ricardo J. Parada wrote: >>> >>>> Oh... I just tried this with a Foo.java class: >>>> >>>> public static class Util extends ERXGenericRecordClazz<Foo> { } >>>> public static final Util util = new Util(); >>>> >>>> Then I can do stuff like this: >>>> >>>> Foo aFoo = Foo.util.objectWithPrimaryKeyValue(anEditingContext, 5); >>>> EOEntity entity = Foo.util.entity(); >>>> String entityName = Foo.util.entityName(); >>>> int count = Foo.util.objectCountWithQualifier(anEditingContext, >>>> aQualifier); >>>> NSArray<Foo> allFoos = Foo.util.allObjects(anEditingContext); >>>> ... >>>> >>>> I think I get it now. :-) And the utility methods are overridable >>>> because I can put my own implementation in the definition of my Util >>>> static inner class. >>>> >>>> I like util better than clazz. >>>> >>>> Thanks >>>> >>>> >>>> >>>> >>>> On Dec 15, 2010, at 5:51 PM, Ricardo J. Parada wrote: >>>> >>>>> >>>>> >>>>> I see that the root EOEnterpriseObjectClazz has a bunch of utility >>>>> methods. For example, createAndInsertObject(), allObjects(), >>>>> objectFromRawRow(), objectWithPrimaryKeyValue(), entityName(), entity(), >>>>> createFetchSpecification(), objectCountWithQualifier(), etc. >>>>> >>>>> And they are only defined once instead of each and every _Foo.java. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Dec 15, 2010, at 5:31 PM, David Holt wrote: >>>>> >>>>>> >>>>>> On 2010-12-15, at 1:43 PM, Ricardo J. Parada wrote: >>>>>> >>>>>>> Thanks David. >>>>>>> >>>>>>> I noticed those __Clazz classes are then declared in the EOs as "public >>>>>>> static class". I read the article below to figure what that meant. >>>>>>> I'm still learning java I guess :-) >>>>>>> >>>>>>> http://www.javaworld.com/javaworld/javaqa/2001-08/01-qa-0817-static.html?page=1 >>>>>>> >>>>>>> So I'm trying to put it together. My Foo.java would have a clazz >>>>>>> static variable referencing an instance of FooClazz. I can add methods >>>>>>> to FooClazz in my Foo.java. >>>>>>> So then FooClazz extends _FooClazz which could have some static methods. >>>>>>> >>>>>>> Are we saying that when I define my FooClazz methods I implement them >>>>>>> by calling _FooClazz static methods or I can rewrite (i.e. override) if >>>>>>> needed? >>>>>>> >>>>>>> I think I'm getting there... I ought to try it I guess. :-) >>>>>> >>>>>> I think the key to the use of Clazz in EOs is this line from the article >>>>>> above: >>>>>> >>>>>> "Instead, instances of Justification act as constants that work with any >>>>>> instance of Text. That's why we can get away with declaring >>>>>> Justification static; it is independent of any specific Text instances." >>>>>> >>>>>> The methods inside whatever class (Clazz) you declare as static inside >>>>>> an EO should be independent of any specific instance. You can call >>>>>> something like People.clazz.currentUser located inside the Person class >>>>>> because it isn't dependent on an instance of the Person class. The >>>>>> "currentUser" should return the same result regardless of where you're >>>>>> calling the accessor from, whereas something like a fullName() method >>>>>> can't be in the static member class because it relies on a specific >>>>>> Person instance to be able to give you a result. >>>>>> >>>>>> If you look at Bug.java, you'll see the static BugClazz contains things >>>>>> like qualifiers, fetchSpecification and arrays of objects that shouldn't >>>>>> be dependent on a specific instance of Bug. >>>>>> >>>>>> That's my understanding from reading the above article and watching the >>>>>> errors that Eclipse gives me when I try to access a static method or >>>>>> variable incorrectly. >>>>>> >>>>>> HTH, >>>>>> >>>>>> David >>>>>> >>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Dec 14, 2010, at 5:57 PM, David Holt wrote: >>>>>>> >>>>>>>> >>>>>>>> On 2010-12-14, at 2:20 PM, Ricardo J. Parada wrote: >>>>>>>> >>>>>>>>> >>>>>>>>> I've always wondered what that clazz thingy is. I'm still not sure. >>>>>>>>> I read the javadoc on EOEnterpriseObjectClazz but still I don't quite >>>>>>>>> get it. >>>>>>>>> What is it? Maybe a little example will go a long way in >>>>>>>>> understanding. :-) >>>>>>>> >>>>>>>> Hi Ricardo, >>>>>>>> >>>>>>>> You're not alone :-) >>>>>>>> >>>>>>>> To date I've been following BugTracker as an example to let me >>>>>>>> integrate the pattern into my D2W applications to give me really fine >>>>>>>> control of what objects I'm displaying in lists. >>>>>>>> >>>>>>>> I'm probably not understanding all that the Clazz pattern adds to the >>>>>>>> mix, but using it has allowed me to start understanding Anjo's example >>>>>>>> BusinessLogic in BugTracker and use the patterns I've found in my own >>>>>>>> code, and I know that it has improved my D2W applications considerably. >>>>>>>> >>>>>>>> Here is an example I use inside DocumentClazz >>>>>>>> >>>>>>>> // Class methods go here >>>>>>>> public static class DocumentClazz extends _Document._DocumentClazz { >>>>>>>> >>>>>>>> public EOFetchSpecification >>>>>>>> fetchSpecificationForWorkingGroupDocumentsForDeletion(WorkingGroup wg) >>>>>>>> { >>>>>>>> // selected working group, marked for Deletion >>>>>>>> EOFetchSpecification fs = >>>>>>>> Document.fetchSpec().qualify(Document.WORKING_GROUP.eq(wg).and(Document.IS_FOR_DELETION.eq(true))); >>>>>>>> return fs; >>>>>>>> } >>>>>>>> } >>>>>>>> >>>>>>>> Now when I need to get a list of documents from an action triggered >>>>>>>> from a navigation tab in my application I can use a method such as: >>>>>>>> >>>>>>>> // DELETION TAB >>>>>>>> public WOComponent listDocumentsForDeletion() { >>>>>>>> EOEditingContext ec = ERXEC.newEditingContext(); >>>>>>>> ec.lock(); >>>>>>>> WorkingGroup selectedWG = (WorkingGroup) WorkingGroup.wg(ec); >>>>>>>> try { >>>>>>>> EODatabaseDataSource ds = Document.clazz.newDatabaseDataSource(ec); >>>>>>>> EOFetchSpecification fs = >>>>>>>> Document.clazz.fetchSpecificationForWorkingGroupDocumentsForDeletion(selectedWG); >>>>>>>> ds.setFetchSpecification(fs); >>>>>>>> return (WOComponent) listPageNamed("ListDocumentsForDeletion", ds); >>>>>>>> } >>>>>>>> finally { >>>>>>>> ec.unlock(); >>>>>>>> } >>>>>>>> >>>>>>>> } >>>>>>>> >>>>>>>> David >>>>>>>> >>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> On Dec 14, 2010, at 5:15 PM, David Holt wrote: >>>>>>>>> >>>>>>>>>> Hi Anjo, >>>>>>>>>> >>>>>>>>>> On 2010-12-14, at 1:34 PM, Anjo Krank wrote: >>>>>>>>>> >>>>>>>>>>> There is a reason why stuff in BT is done as it is. >>>>>>>>>>> >>>>>>>>>>> I.e. there is a People.class.setCurrentUser(People user) and >>>>>>>>>>> People.class.currentUser(EOEditingContext ec). Basically it puts >>>>>>>>>>> all the thread storage code (including the key) in People, which >>>>>>>>>>> is, like, good style? >>>>>>>>>> >>>>>>>>>> Absolutely agree. But it was difficult for me to wrap my head around >>>>>>>>>> ERXThreadStorage AND Clazz pattern AND ERCoreBusinessLogic at the >>>>>>>>>> same time. I was just trying to simplify it a little for Jesse. >>>>>>>>>> There is no question that all three together are much more powerful >>>>>>>>>> and useful. >>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Also, ERXThreadStorage already handles EOs and faulting. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> >>>>>>>>>> David >>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Cheers, Anjo >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Am 14.12.2010 um 21:57 schrieb David Holt: >>>>>>>>>>> >>>>>>>>>>>> public static Person currentUser(EOEditingContext ec) { >>>>>>>>>>>> Person currentUser = currentUser(); >>>>>>>>>>>> if (currentUser != null && currentUser.editingContext() >>>>>>>>>>>> != ec) { >>>>>>>>>>>> EOEditingContext currentUserEc = >>>>>>>>>>>> currentUser.editingContext(); >>>>>>>>>>>> currentUserEc.lock(); >>>>>>>>>>>> try { >>>>>>>>>>>> Person localUser = (Person) >>>>>>>>>>>> ERXEOControlUtilities >>>>>>>>>>>> >>>>>>>>>>>> .localInstanceOfObject(ec, currentUser); >>>>>>>>>>>> currentUser = localUser; >>>>>>>>>>>> } finally { >>>>>>>>>>>> currentUserEc.unlock(); >>>>>>>>>>>> } >>>>>>>>>>>> } >>>>>>>>>>>> return currentUser; >>>>>>>>>>>> } >>>>>>>>>>>> > _______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
