
To execute the script (Assuming groovy is in your path:)
>groovy ojb2jpa.groovy


************************

The ojb2jpa.groovy script performs some conversion tasks to help 
convert your Rice client from OJB persistence model to JPA
The script performs the following tasks:
- generates a persistence.xml file in the META-INF directory
- generates the JPA annotated BO POJO source files
- generates composite primary key class source files 
- generates mysql sql scripts for creating sequence generation tables
- generates orm.xml files for mysql sequence annotation overrides (not yet implemented)
configuration properties control which tasks to perform. 

Note: The generated files have not been verified to be correct.
They are intended to provide a head start in converting from OJB to JPA


The script can search your project for your existing OJB repository config files,
or you can specify the repository files


/*** Properties Local to your local environment ***
 ***    YOU NEED TO CHANGE THESE                ***
 ***                                            ***
/* project root from which to search for files (all subdirectories will be searched)*/
projHome = 'c:/java/rice/projects'   

// an array of directories under the project to locate java files
def sourceDirectories = ['/impl/src/main/java/']

// the directory where to place the META-INF/persistence.xml file
def resourceDir = '/impl/src/main/resources/'

// the schema name of your rice client database
def schemaName = "RICE110DEV"

persistenceUnitName = "rice"

// a regular expression used to auto-locate your old OJB repository config files
// the default behavior searches for  *OJB*repository.xml  files
// this is only required if scanning for files
ojbMappingPattern = ~/.*OJB.*repository.*xml/   /* regular expression to match OJB mapping files */


***  Script task control parameters ***
***  These properties configure which tasks to perform
***

persistenceXml = true		/* create persistenceXml files */
createBOs = true
pkClasses = false
mysql = false
def scanForConfigFiles = true
dry = true   /* perform a dry run, output to the console, do not actually create the files. */


// other misc. config properties
def verbose = false
def backupExtension = ".backup"
def metainf = 'META-INF/'
verbose = true

/*************  Dependencies *********************/

NOTE:  For the generated composite primary key id classes to compile, you will need the Rice version 1.1 .jar files in your build path.
This is because the generated classes inherit from CompositePrimaryKeyBase which is a new class beginning in version 1.1

/*****************************************************/

Recently fixed issues:
- for Composite Primay Key classes modify to extend from CompositePrimaryKeyBase.
	CompositePrimaryKeyBase implements the equals() and hashCode() methods. These methods use reflection, so it should work for derived classes

Known Issues:
- modify script to catch exceptions, log, and continue 
- modify script to prevent duplicate annotations
- add handling of @TYPE annotations for Booleans.
- add handling of @TRANSIENT
- handle when client repository references rice modules (no source code)
- clean up script to use global vars
- re-org project to be more modular
- modify POJO creator to log and continue instead of return. (rather than crash on the first error, will show all the errors)
- move pk creation to after pojo creation