Transfer Config App - Auto Generate your Transfer Config File
by Rolando on Sep.13, 2007, under TransferConfig
I've been working on a simple application that introspect any ColdFusion 8 supported database using cfdbinfo and generates the Transfer ORM config file for you. It also works with the new (unstable) version of transfer meaning it handles composite key tables.
I've added a very simple front-end that let's you see all the tables Meta-Data, preview the XML Config File before creating it and of course it lets you create the file itself.
You can set a few config settings depending on what best works for you:
-
UUID Convention - This is meant for SQL server that does not have UUID data type but instead we use char(35),so if you have this turned on every time a Char(35) is found will be interpreted as a UUID data type.
-
Generate PK - ask transfer to generate the PK value for you.
-
Collection Type - <array|struct> lets you choose wich collection type you want to use for the OneToMany relationships.
-
Relationship type to use - In transfer you can pick whether to use the ManyToOne or OneToMany relationships and this will vary depending on your needs. As of now you can only select this as a general setting meaning whatever you pick it will be used on all the Objects created. However both relationships will always be created, it'll just comment out the other one. So if you want to change for one or the other after the file is created all you need to do is uncomment those lines.
-
File name - By default I have the file named transferX.xml. The destination of the file you can change for each site in the environment.xml file mentioned below.
Integrated with the application is something I had done sometime ago with the help of Rob Gonda (which he showed at CFUnited this year) but we never blogged about it. That is the Environment Configurator which is nothing else than an XML file with a CFC that lets you setup different environments and variables (ie Dev, Staging, Production). I know, that's useless for the transfer file which is the same along environments …well I'm using it a bit different here. Instead of copying the Transfer Config App into each one of my projects, I have it in a single location and I add each new site to the environment xml file (ie roland-lopez.com, adobe.com). Then, I add a virtual directory to each site called /transferConfig pointing to Transfer Config, so when the App starts it will notice which domain I'm comming from and will load the specific DSN, among other settings.
For version 2 of Transfer Config I plan to allow for custom settings of each object. So that you can pick things like the relationship type, collection type, generate PK, etc for each table …and yes a better UI.
You can submit bugs and/or requests for the next version at roland [at] soft-itech [dot] com
You can download the App at RIAforge.org
—modified on: 9/17/2007
I just added version 1.0.1 of Transfer Config this includes the following fixes and enhancements:
- Fixed: App would break if database in use contained a table with no primary key defined.
- Enh: change App to be able to run in transferConfig subfolder (can be run directly under the root too)
- Enh: added ability to pick DSN directly from the view/form. The way this will work depends on your settings:
- If you have the Admin password for CF you can add it to the environment.xml.cfm file and the CF Admin API will be used to get a list of DSN's.
- If don’t have Admin privileges on the server, it will try to use the CF serviceFactory to get a list of the DSN’s.
- If none of the previous two are an option, a text field will be used filled out by default with the DSN value you specified in the environment xml file.
- Enh: Prevent direct access to the environment XML file for (obvious) security reasons.
- Other minor enhancements.
—–



September 15th, 2007 on 9:17 pm
Roland,
This looks like a great tool! Awesome work!
You may want to fire off an email to the transfer-dev group, to let everyone know about it. I know there has been some discussion on auto-generating Transfer xml lately.
Also, please feel free to pass on any comments / bugs from the composite key stuff that you have found, I would love to hear it.
Keep up the great work!
September 16th, 2007 on 4:09 pm
Some suggestions:
- do not enable client management: the app fails if no default client storage is set and I set that to “none” as a matter of course on every server.
- change app to run in a transferConfig subfolder instead of assuming your app can be installed directly under the root (I had to edit models.* to transferConfig.models.* in two files to make this work).
- allow the user to supply a DSN on the URL or via a form for situations where a single domain has multiple DSNs (which I’d think is very common)
So far I haven’t actually managed to get it to generate a Transfer XML file. I keep getting:
Element COLUMN_NAME is undefined in STPRIMARYKEY.
at
transferConfig/models/TransferConfig.cfc:851
Seems to happen on every DSN I pick.
September 16th, 2007 on 10:23 pm
Sean, Thanks for your feedback. I’ll making these changes to the App.
In regards to the error (I just sent you an email), I’ll be looking into this tomorrow and will get back to you soon.
September 17th, 2007 on 12:13 am
This is fantastic though like Sean it wouldn’t work for me out of the box. I had to throw a check around line 850 of TransferConfig for the existence of stPrimaryKey.column_name. Also on line 29 of Application.cfc the case of the createComponent for Transferconfig should be TransferConfig, I’m running on a linux box and case matters. But this is really cool, the config it generated was very good, this will save me TONS of time.
September 17th, 2007 on 6:39 pm
Sean and Jon,
Version 1.0.1 has been placed on RIA with the enhancements and fixes requested above.
Thanks for your feedback!
Roland
September 19th, 2007 on 12:37 am
This app is a flippin life saver! Hehe, wish I had it 4 months ago. Thank you so much Roland for putting in such impressive effort.
Quick question though : how would you go about updating transferConfig to generate the transfer xml package nodes to be sorted alphabetically by name? When I’m in the “Tables Meta Data” view, the database tables are nicely sorted from A-Z. But when I’m in “View XML” or when I generate the XML, the database tables are ordered completely random (although the same every time, but not in alphabetical order, so maybe “random” is the right word here - perhaps just “out of alphabetical order”
Thanks again. The more I look through the code, the more I’m extremely impressed.
Marty
September 20th, 2007 on 1:56 am
@Marty,
Thanks for your feedback.
In regards to your question, the following should do the trick. Replace the line +-844 of TransferConfig.cfc containing:
<cfloop collection=”#variables.instance.packages#” item=”ixPackage”>
with this one:
<cfloop list=”#listSort(structKeyList(variables.instance.packages),’textnocase’)#” index=”ixPackage”>
that should do the trick, although I haven’t tested it yet. I’ll add this to the next version but for now I figured you don’t need to wait for it.
September 24th, 2007 on 9:33 pm
Thanks Roland! That works great. Now the transferConfig outputs the database objects in alphabetical order for the transfer.xml file. Sweet!
September 25th, 2007 on 11:47 am
You need to change the way you construct the XML file path - you use “” which is Windows-only. If you use “/” it will work on both platforms.
BTW, we should probably log these as bugs in the RIAforge bug tracker I suppose?
It’s a great labor-saving utility!
September 25th, 2007 on 12:37 pm
There are a couple of other bugs, that I logged on RIAForge. I’ve fixed them locally and would be happy to send a patch file if that helps.
This is a really good tool, thanks again for sharing.
September 26th, 2007 on 9:34 am
@Sean
Yes, please add the bugs RIAForge too. It’s definitely easier to track them there.
Thanks for the input, I’ll make the mod to the app.
@Jon & Marty
Thank you guys for the feedback.
Jon, I have applied the fixes you requested already, they’ll be reflected in the next revision.
October 14th, 2007 on 8:08 pm
Is this a CF8 app only, as I’m trying to run it on 7.02 and keep getting the following error:
Invalid CFML construct found on line 364 at column 103.
ColdFusion was looking at the following text:
)
The CFML compiler was processing:
* an expression beginning with “col”, on line 364, column 98.This message is usually caused by a problem in the expressions structure.
* a script statement beginning with “for” on line 364, column 41.
* a script statement beginning with “{” on line 363, column 75.
* a script statement beginning with “if” on line 363, column 33.
* a cfscript tag beginning on line 362, column 26.
* a cfscript tag beginning on line 362, column 26.
* a cfscript tag beginning on line 362, column 26.
The error occurred in C:Inetpubwwwroot ransferConfigmodelsTransferConfig.cfc: line 364
362 :
363 : if(not isJoinedTable( arguments.stTable )){
364 : for( col=1; col lte arrayLen(arguments.stTable.columns); col++){
365 : if( arguments.stTable.columns[col].is_foreignkey ){
366 :
October 15th, 2007 on 5:54 pm
@Robb
Yes this is Definitely CF8 only. Mainly because the cfdbinfo tag was introduced on CF8, although your error is related to the ++ feature on CFScript which was also introduced in this version.
November 7th, 2007 on 2:07 am
Thank you sir. I have been digging into ORM and have been on a roll with it. You read my mind a good 6 weeks before I even thought it. The force is strong with you.
October 13th, 2008 on 12:44 pm
Roland,
This is awesome however it’s saying my XML file generated is not meeting the same format requirements of the XSD template.
Any ideas why? Maybe it’s newer version?
October 13th, 2008 on 1:03 pm
Transfer.xml.cfm’ is not valid against its XML Schema
[Error] :2:11: cvc-elt.1: Cannot find the declaration of element ‘transfer’.
That’s the error I’m getting when I try to call it as a singleton.
November 8th, 2008 on 4:23 pm
Hi Roland! Thanks for sharing the tool…definitely a timesaver. I did notice an issue that you may or may not be aware of, though. If I have a table whose name begins with ’system’ (eg, ’systemUser’), it gets skipped over in the output. Is this by design?
June 20th, 2009 on 6:11 pm
I can’t seem to download this on RIAForge. I keep getting asked for a user name/password for your “download portal”. Is this project no longer available?
June 20th, 2009 on 7:55 pm
Scott,
(oops!) Thank you for noting this. I have corrected the issue. You should be able to download the project now.
http://transferconfig.riaforge.org/
-Rolando
June 21st, 2009 on 12:53 pm
Great. Thanks!