• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Custom attribute class conversion in entity modeler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:

PNG image




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

  • Follow-Ups:
    • Re: Custom attribute class conversion in entity modeler
      • From: "Ricardo J. Parada" <email@hidden>
References: 
 >Custom attribute class conversion in entity modeler (From: Riccardo De Menna <email@hidden>)
 >Re: Custom attribute class conversion in entity modeler (From: Mike Schrag <email@hidden>)
 >Re: Custom attribute class conversion in entity modeler (From: Riccardo De Menna <email@hidden>)
 >Re: Custom attribute class conversion in entity modeler (From: Mike Schrag <email@hidden>)
 >Re: Custom attribute class conversion in entity modeler (From: Riccardo De Menna <email@hidden>)
 >Re: Custom attribute class conversion in entity modeler (From: "Ricardo J. Parada" <email@hidden>)

  • Prev by Date: Stable Installer Update (5673)
  • Next by Date: [MEETING] WO-NOVA meeting Tuesday 2/17
  • Previous by thread: Re: Custom attribute class conversion in entity modeler
  • Next by thread: Re: Custom attribute class conversion in entity modeler
  • Index(es):
    • Date
    • Thread