• 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: EOModeler/Prototypes question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOModeler/Prototypes question


  • Subject: Re: EOModeler/Prototypes question
  • From: Dov Rosenberg <email@hidden>
  • Date: Sat, 11 Dec 2004 07:59:44 -0500

Yes you can do that, use the NotificationCenter to register your app to
receive a notification when the model is loaded, when you get the
notification you can replace the connection dictionary and update the
prototypes with the correct information. We typically only update the
datatype and leave the name and length alone.


Here is what we use:

Somewhere in the app initialization add code like :
...
// register to receive notifications when model is added
        Class connParams[] = {
com.webobjects.foundation.NSNotification.class };
        NSSelector connSelector = new
NSSelector("receiveModelAddedNotification", connParams);
        NSNotificationCenter.defaultCenter().addObserver(this, connSelector,
EOModelGroup.ModelAddedNotification, null);

...

When the notification happens, this code gets run.


public void receiveModelAddedNotification(NSNotification notification) {

        EOModel model = (EOModel)notification.object();

        if (model != null && model.name().equals("Content")) {
            model.setConnectionDictionary(getConnectionInfo());

            //System.out.println("Connection Dictionary=" +
getConnectionInfo());
            // We use EOF prototype feature so we can easily change external
            // types to be appropriate to the current database.
            EOEntity prototypeEntity =
model.entityNamed("EOJDBCPrototypes");
            NSDictionary externalPrototypes =
ProtoypeFactory.getExternalTypesForDB(Application.getProperty("DATABASE_TYPE
"));

            if (prototypeEntity != null) {
                NSArray attribs = prototypeEntity.attributes();
                if (attribs != null) {
                    for (int i = 0; i < attribs.count(); i++) {
                        EOAttribute prototypeAttrib =
(EOAttribute)attribs.objectAtIndex(i);
                        if (prototypeAttrib != null) {
                            String prototypeName = prototypeAttrib.name();

                            String properExternalType =
(String)externalPrototypes.objectForKey("prototype_" + prototypeName);

                            if (properExternalType != null) {
                        prototypeAttrib.setExternalType(properExternalType);
                            } else {
                                throw new RuntimeException("MISSING EXTERNAL
DATA TYPE EMAPPING FOR PROTOTYPE: " + "prototype_" + prototypeName);
                            }
                        }
                    }
                }
            }
        }

    }

Hope this helps



--
Dov Rosenberg
Conviveon Corporation



On 12/10/04 3:00 PM, "James Cicenia" <email@hidden> wrote:

> Hello -
>
> I have been requested to make our project IBM compatible. This means
> DB2/Linux/WebSphere.
>
> First off I need to change a bunch of my data types to be compatible
> with
> DB2. What do you do?
>
> Do you maintain two different EOModels? Or, is there a way to change
> the Prototypes on the fly?
>
> Thanks again,
> James Cicenia
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> n.com
>
> This email sent to email@hidden


 _______________________________________________
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

References: 
 >EOModeler/Prototypes question (From: James Cicenia <email@hidden>)

  • Prev by Date: Re: Using NSDictionary as attribute
  • Next by Date: DirectAction authentification and Session
  • Previous by thread: EOModeler/Prototypes question
  • Next by thread: Re: EOModeler/Prototypes question
  • Index(es):
    • Date
    • Thread