Re: Design Question
"Cheong Hee (QSS)" <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <002a01c6acac$8c26c020$0802a8c0@CHNGXP> |
Two EOGenericRecord needs to be created: - PatientAllergy EOGenericRecord - AllergyCodeDescriptor EOGenericRecord that contains key/values of the code and description PatientAllergy has a shared static object of AllergyCodeDescriptor. (Rather than subclass it, a pointer of reference shall be better.) This solved Q3. When application start up, the key/values could be read from disk via ResourceManager or other way of file reading. The key/values then feed into static shared object AllergyCodeDescriptor in PatientAllergy. This is done once only and it avoids the repetition as you mentioned. This solved Q1. When there is any object creation of PatientAllergy later, the shared static object AllergyCodeDescriptor could then pass in the value for initialization or for validation. This solved Q2. I have quite similar situation whereby the license string loaded at each application starts up, will have to decide the package offering based on the license string. I use similar approach and it solved my problem. Hope this of help too while trying to understand yours. Cheong Hee ----- Original Message ----- From: "Paul Lynch" <[email protected]> To: "Michael Deninger" <[email protected]> Cc: "WebObjects Development ListServ" <[email protected]> Sent: Friday, July 21, 2006 3:01 PM Subject: Re: Design Question > > On 21 Jul 2006, at 02:00, Michael Deninger wrote: > >> I have some static data that I need to access from within an >> EOGenericRecord. The data, unfortunately, is not in the DB (and even if >> it were, creating a relationship to the entity would likely not work for >> various reasons). The data is essentially a dictionary of keys / values >> that describe the meaning of the coded values in one of the database >> tables. E.G. >> >> Entity: PatientAllergy >> Attribute: AllergyCode >> >> where AllergyCode is some number (say 83). The meaning of that number is >> in this dictionary (e.g. value = 83, description = "penicillins") >> >> What is the best way to accomplish this? I have considered the >> following: >> >> 1) read this dictionary into my Application object at startup. Sounds >> great, but I cannot figure out how to access EOApplication from an >> EOGenericRecord > > Application application = (Application)Application.application(); > > Works from anywhere. > >> 2) read this dictionary form disk into each EOGenericRecord at the time >> it is created. I think that this would work, but it creates a lot of >> unnecessary repetition of data. > > Think classes - I presume that you are using a subclass of > EOGenericRecord, and not EOGenericRecord itself. Load the table on first > request, as a static method within the appropriate class. > >> 3) hard-code the dictionary into an abstract class extending >> EOGenericRecord and have the Entity inherit from it. > > This seems a little awkward to me. > > You could create a class for the sole purpose of holding the values, as > Ian suggests, but that strikes me as proliferation of objects. On the > whole, I would prefer to implement it as a static method of your entity > class. > > Paul > > _______________________________________________ > WebObjects-dev mailing list > [email protected] > http://www.omnigroup.com/mailman/listinfo/webobjects-dev >