Today we will install the Transfer ORM inside our Contact-O-Matic application.
To complete this tutorial, you should have the Contact-O-Matic installed and running.
If you have not completed this step, please create the database described at the bottom of Series 6 and install the files at Series 10 download link.
Test the application by manually adding several ContactTypes to the ContactType table in your database (I chose Co-Worker, Enemy, Friend). Then use the Contact Form in the ContactOMatic application to enter a few contacts.
Once you confirm the application works as intended, open your /ContactOMatic/config/ColdSpring.xml file and make the following edits to the ModelGlueConfiguration bean:
- Set reload = true
- Set rescaffold = true
- Set debug = true
Reload your application and scroll below the footer to the ModelGlue Debug output. You should see the following message:
Not using an ORM adapter. You will not be able to do automatic database functions.
All good? Now we begin the integration.
The Transfer Integration in ModelGlue:Unity depends on the alias functionality in ColdSpring which is currently found in the BER release.
If you do not have the BER release, or are not sure, you should Checkout the /Head/Coldspring directory into your webroot as ‘coldspring’.
Note: If you complete this series and do not have a version of ColdSpring with alias support, you will not get an obvious error. Here are the CVS configuration details for checking out ColdSpring.
If you use (cf)eclipse, you already have a CVS client. If not, I suggest you download one.
Below is a screenshot of the CVS parameters for Eclipse:
Download the latest Transfer ORM framework at RIA Forge/ Transfer ORM, then extract it to your webroot.
Now open the ContactManagerMG directory and create a ‘transfer’ directory in /ContactManagerMG/Config and also a ‘transfer’ directory inside /ContactManagerMG/Model.
Following that, create two new .xml files named Datasource.xml and Transfer.xml inside /ContactManagerMG/Config/transfer.
Datasource.xml file contains the datasource used by your application. Fill it out like so:
The contents of the Transfer.xml file define the objects Transfer will manage for us. To begin, we define a Contact Object and a ContactType Object. Note:The Contact Object is composed of a ContactType Object through a manytoone relationship. This is because several Contacts can have the same Contact Type, makes sense, no?
Lastly, connect Transfer to ModelGlue:Unity through ColdSpring. Open /ContactManagerMG/config/ColdSpring.xml and paste the following definitions:
Note: If you are using MG:3 Gesture, you do not need the definitions for the ormAdapter and the ormService.
Why? Because these are provided for you already in the Gesture framework. If you use the above definitions, you will get the following error:
Bean creation exception during init() of ModelGlue.unity.orm.transfer.TransferAdapter The TRANSFER parameter to the init function is required but was not passed in.:
The fix is easy. Remove the following XML from the above configuration:
Test the integration by running your ContactOMatic application again. Scroll to the ModelGlue Debug output and look for the Happy Message:
0ms Core Using ORM Adapter: com.adobe.hs.common.orm.TransferAdapter
If you did not get the Happy Message, something is borked. You may see one of the below messages:
Missing Datasource file:
Not using an ORM adapter. You will not be able to do automatic database functions.
Cause: Transfer failed to load: coldspring.beanCreationException : Bean creation exception during init() of transfer.TransferFactory : An error occurred when performing a file operation read on file C:\Webroot\ContactManagerMG\config\transfer\datasource.xml.:The cause of this exception was: java.io.FileNotFoundException: C:\Webroot\ContactManagerMG\config\transfer\datasource.xml (The system cannot find the file specified).
Missing Transfer File
Not using an ORM adapter. You will not be able to do automatic database functions.
Cause: Transfer failed to load: coldspring.beanCreationException : Bean creation exception during init() of transfer.TransferFactory : An error occurred when performing a file operation read on file C:\Webroot\ContactManagerMG\config\transfer\transfer.xml.:The cause of this exception was: java.io.FileNotFoundException: C:\Webroot\ContactManagerMG\config\transfer\transfer.xml (The system cannot find the file specified).
To resolve this, examine the name and path of each of the configuration files above.
Remember: the file path referenced in the ColdSpring.xml / transferConfiguration bean is the path from your webroot or ColdFusion Mapping.
If you still get this message:
Not using an ORM adapter. You will not be able to do automatic database functions.
One of three things is wrong:
- You did not reload your application
- You did not install the ColdSpring BER properly
- You did not install Transfer Properly
For reference, below is the proper directory/file structure for the completed installation: