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: "Ricardo J. Parada" <email@hidden>
- Date: Fri, 13 Feb 2009 15:57:32 -0500
Thanks Riccardo... Ok... so it looks like your storing the id in the
database as a string (with a maximum of 3 characters).
At first I thought you were storing it as a number in the database but
now that you sent this I realized that id() returns a String and
forID() takes a String as an argument too.
Thanks
On Feb 13, 2009, at 3:11 PM, Riccardo De Menna wrote:
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:
<attribute.png>
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