Project Wonder 5.0

er.cayenne
Class CayenneConverter

java.lang.Object
  extended by er.cayenne.CayenneConverter

public class CayenneConverter
extends Object

CayenneModeler (which comes with Cayenne) includes a tool to convert EOModels to Cayenne models: create a new project and then choose Tools -> "Import EOModel".
I suggest trying that first. In my experience it didn't work well because the prototypes in ERPrototypes were not resolved.

This framework will allow you to convert an EOModel to a Cayenne model.

To use it just add the framework to your build path and then add this line to you application's constructor (replace MyModel with the name of your model):
new er.cayenne.CayenneConverter().run(EOModelGroup.defaultGroup().modelNamed("MyModel"));

Run your WO app.
This will create a Cayenne DataMap file (called MyModel.map.xml) in the root of your Sources folder.
To use it you will need to run CayenneModeler and create a new project.
Then give a name to the DataDomain (top-level) node that is created in the new project
Then choose File -> Import DataMap and select the .map.xml file that was generated.

The converter does not copy the connection dictionary from your model - you will need to re-enter that information by creating a DataNode using CayenneModeler.

The converter attempts to convert qualifiers for any fetch specifications you've defined in your model, but this should be considered just a best attempt, not guaranteed to be correct.


Field Summary
static String JAVA_BIGDECIMAL
           
static String JAVA_BLOB
           
static String JAVA_BOOLEAN
           
static String JAVA_BYTE
           
static String JAVA_BYTES
           
static String JAVA_DOUBLE
           
static String JAVA_FLOAT
           
static String JAVA_INTEGER
           
static String JAVA_LONG
           
static String JAVA_SHORT
           
static String JAVA_SQLDATE
           
static String JAVA_STRING
           
static String JAVA_TIME
           
static String JAVA_TIMESTAMP
           
static String JAVA_UTILDATE
           
static int NOT_DEFINED
           
 
Constructor Summary
CayenneConverter()
           
 
Method Summary
 String getJavaClassName(EOAttribute attr)
           
static int getSqlTypeByJava(Class<?> javaClass)
          Guesses a default JDBC type for the Java class.
static int getSqlTypeByJava(String className)
          Returns default java.sql.Types type by the Java type name.
static void main(String[] args)
           
 void run(EOModel model)
          Converts an EOModel to a Cayenne model / project.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOT_DEFINED

public static final int NOT_DEFINED
See Also:
Constant Field Values

JAVA_LONG

public static final String JAVA_LONG
See Also:
Constant Field Values

JAVA_BYTES

public static final String JAVA_BYTES
See Also:
Constant Field Values

JAVA_BOOLEAN

public static final String JAVA_BOOLEAN
See Also:
Constant Field Values

JAVA_STRING

public static final String JAVA_STRING
See Also:
Constant Field Values

JAVA_SQLDATE

public static final String JAVA_SQLDATE
See Also:
Constant Field Values

JAVA_UTILDATE

public static final String JAVA_UTILDATE
See Also:
Constant Field Values

JAVA_BIGDECIMAL

public static final String JAVA_BIGDECIMAL
See Also:
Constant Field Values

JAVA_DOUBLE

public static final String JAVA_DOUBLE
See Also:
Constant Field Values

JAVA_FLOAT

public static final String JAVA_FLOAT
See Also:
Constant Field Values

JAVA_INTEGER

public static final String JAVA_INTEGER
See Also:
Constant Field Values

JAVA_SHORT

public static final String JAVA_SHORT
See Also:
Constant Field Values

JAVA_BYTE

public static final String JAVA_BYTE
See Also:
Constant Field Values

JAVA_TIME

public static final String JAVA_TIME
See Also:
Constant Field Values

JAVA_TIMESTAMP

public static final String JAVA_TIMESTAMP
See Also:
Constant Field Values

JAVA_BLOB

public static final String JAVA_BLOB
See Also:
Constant Field Values
Constructor Detail

CayenneConverter

public CayenneConverter()
Method Detail

main

public static void main(String[] args)

run

public void run(EOModel model)
Converts an EOModel to a Cayenne model / project. See the class docs for more info.

Parameters:
model -

getJavaClassName

public String getJavaClassName(EOAttribute attr)

getSqlTypeByJava

public static int getSqlTypeByJava(String className)
Returns default java.sql.Types type by the Java type name.

Parameters:
className - Fully qualified Java Class name.
Returns:
The SQL type or NOT_DEFINED if no type found.

getSqlTypeByJava

public static int getSqlTypeByJava(Class<?> javaClass)
Guesses a default JDBC type for the Java class.

Since:
1.1

Last updated: Wed, Feb 22, 2012 • 07:00 AM EST

Copyright © 2002 – 2011 Project Wonder.