Re: Custom attribute class conversion in entity modeler
Re: Custom attribute class conversion in entity modeler
- Subject: Re: Custom attribute class conversion in entity modeler
- From: Riccardo De Menna <email@hidden>
- Date: Fri, 13 Feb 2009 21:11:20 +0100
Hi Ricardo,
Sorry for being late but I've been out of town for a while.
I was looking for a way to use Java enums converting them directly
from the model.
This setup seems to work nicely.
I have a Client class (an regular EOEnterpriseObject subclass) that
holds a nested java enum like the following named Status.
public class Client extends _Client {
public enum Status {
ACTIVE(0),
DISABLED(1),
TRIAL(2),
DELETED(-2);
private static final Map<Integer,Status> lookup = new
HashMap<Integer,Status>();
private final Integer _id;
private Status(Integer id) { _id = id; }
public static Status forID(String id) {
return lookup.get(new Integer(id));
}
public String id() {
return String.valueOf(_id);
}
static {
for( Status s : EnumSet.allOf(Status.class) )
lookup.put(s._id, s);
}
}
}
And my attribute model is setup as follows:
Transformation to and from the db is done via the forID/id methods. In
this case I'm converting to a CHAR but one could use an INT or
whatever else.
rdm
On 10/feb/09, at 22:28, Ricardo J. Parada wrote:
Cool thanks.
On Feb 10, 2009, at 3:44 PM, Riccardo De Menna wrote:
Ricardo... I read your email but I'm traveling till friday night. I
promise to send you a screenshot as soon as I get back home.
rdm
_______________________________________________
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