Re: Horizontal inheritance
Re: Horizontal inheritance
- Subject: Re: Horizontal inheritance
- From: Chuck Hill <email@hidden>
- Date: Wed, 6 Jan 2010 11:20:41 -0800
The disadvantage is that you can have one class implementing multiple
entities. So it does not work in all cases, but it sounds like it
works for your situation.
Chuck
On Jan 6, 2010, at 11:13 AM, Mark Wardle wrote:
Thanks Chuck,
This works well.
The advantage of using a class is that I can then fetch all forms and
subforms (subclasses) of that class.
Thank you,
Mark
2010/1/4 Chuck Hill <email@hidden>:
On Jan 3, 2010, at 12:18 PM, Mark Wardle wrote:
Hi.
I have an "Encounter" <->> "Form" relationship.
However, a "Form" is an abstract entity with a number of concrete
subclasses.
EOGenerator generates the methods "forms()" and "forms(EOQualifier
qual)".
I'd like to get a list of the form types of a specific subclass.
/**
* Returns all of the forms of the specified type
*/
public NSArray<Form> forms(Class<? extends Form> formClass) {
NSMutableArray<Form> forms = new NSMutableArray<Form>();
for (Form f : forms()) {
if (formClass.isInstance(f)) {
forms.add(f);
}
}
return forms;
}
Surely there's a better way that this?
Am I missing something obvious here with EOF/WO inheritance?
I can see three choices: model, fetch, or filter (as you are doing
above).
It would be more general purpose to use the entity name, rather
than the
class, to filter on. You could do something like this:
public NSArray<Form> forms(String entityName) {
return forms(ERXQ.eq("entityName", entityName));
}
ERXQ assumes you are using Wonder.
Chuck
--
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
--
Dr. Mark Wardle
Specialist registrar, Neurology
Cardiff, UK
--
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