Galleon on DataMgr

I recently noticed that Galleon has been used as a sample application for a few frameworks. Showing a complete lack of originality, I decided to do the same thing with DataMgr on Galleon. Where relevant, I changed the code from cfquery calls to DataMgr calls. The goal was to change only the business layer internals and leave the rest of the code unchanged.

(What is DataMgr?)

I did have to make a few changes to Galleon before I could start in earnest:

  1. I had to change galleon.cfc to load DataMgr and return it in getSettings().
  2. I had to change the setSettings method in each model CFC to put DataMgr in variables.DataMgr.
  3. I put XML to define the database in galleon.cfc and passed it into Datamgr.loadXml(). This step could have been avoided, but provided me with some benefits, so it seemed worthwhile.

Note that none of the changes to Galleon are outside of the "cfcs" folder.

Ray had a few queries which I chose to leave alone rather than take them time to grok them fully. Other than that, I was able to replace most of the queries in Galleon.

I didn't track the time involved, but I did make the entire transition in one day.

So, what was gained from the trouble?

More Database Support

Galleon currently runs on Access, Oracle, MySQL and PostGreSQL. By modifying it to run on DataMgr 2.2, it gets additional support for PostGreSQL and Apache Derby. Adding support for a new database could be done by creating a new database adaptor for DataMgr.

Easier Installation

I say this with some trepidation as Ray is really good at making an easy installation. The process to install Galleon requires running a SQL file to set up a database (or using the included Galleon.mdb file for MS Access). This is great for a first installation.

Galleon also includes the ability to choose your own table prefix. If you decide to do that, however, you have to edit the SQL files before you run them (not to bad, a quick find/replace should do the trick).

When upgrading to a new version, you may have to manually add some new columns.

By taking advantage of DataMgr.loadXml(), all of the needed tables and columns (with data) will be created when this version of Galleon is loaded in the browser the first time.

Note that this functionality does require the datasource to have both CREATE and ALTER permissions. I could have also created a fall-back to return the SQL to the user in the even that these permissions weren't available (see CodeCop for an example of this).

This will use whatever prefix is set up in the settings and will automatically add new tables and columns on an upgrade.

Less Code

I did have to add about 400 lines of code to galleon.cfc to bring about the automatic installation that I just mentioned. This obviates the need for nearly 600 lines of SQL and the 450K forums.mdb file. Additionally, I removed about 500 lines of code from the CFCs in in the "cfcs" folder.

No Need for a dbtype setting

The removed code consisted mostly of queries, but often had conditionals based on the dbtype setting. DataMgr handles all of the differences for which dbtype conditionals existed in Galleon, so those are no longer needed.

Moreover, because I used DataMgr 2.2 I was able to take advantage of automatic database detection (thanks again Mark Mandel) allowing DataMgr to determine the database being used from the datasource.

So, no more need for the dbtype setting.

No Other Impact

This isn't really a benefit, but bears mentioning. I didn't have to change any code outside of the "cfcs" folder. I also limited myself to changes that would allow this version to be in the Galleon upgrade path. That is to say that you should be able to directly upgrade from any other version of Galleon to this one.

That being said, I didn't undertake this project in the hopes of getting people to switch to a version of Galleon running on DataMgr. Rather I wanted to provide a fair comparison of DataMgr to a more traditional approach. I would suggest downloading this (using the "download" link at the bottom of this entry) as well as Galleon 2.2.3 (the version on which this is based) for comparison.

Galleon ColdFusion Forums is free and open source written by Ray Camden (download from RIAForge. DataMgr is also free and open source for any use (download 2.1 from RIAForge or 2.2 from my site).

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
I had actually contemplated a 2nd frameworks comparison article using Galleon that would include just ORMs... yours, Transfer, Reactor and DataFaucet ... though it wasn't DataFaucet when I did the first article, it was still part of the onTap framework at the time... But there's been underwhelming response to the original frameworks article, so I'm not sure if I'll end up doing an ORM edition. :) Ray did have a couple queries that were outside his cfc directory, although he was pretty good about keeping most of them in there. Which was pretty handy for the conversion.
# Posted By ike | 8/7/08 7:10 AM
Ike,

Good to know. I actually didn't even look for queries outside of his cfcs folder (as per my goals), so I would have missed those.

I'm glad you had the idea though, because it is certainly a good way to demonstrate the use of a DAL.
# Posted By Steve Bryant | 8/8/08 5:39 AM
Thanks for the complement. :)

Yeah he had I think a stats page and I think his search results might have been outside the cfcs. But it ended up being so few outside his CFCs that you could count them on the fingers on one hand. And imo those really should have been in his CFCs too, and I certainly wouldn't fault anyone for not converting them, particularly given that it's a demonstration.
# Posted By ike | 8/8/08 5:02 PM
I'm assuming this is another orm/helper that only works on Adobe engines? Correct?

Would be great if it worked on Bluedragon or Railo. (Or they added whatever java method is missing that everyone seems to use.)

By the way, what about speed vs other methods?
# Posted By ziggy | 8/18/08 10:58 PM
Ziggy,

Good questions.

DataMgr is a DAL (Data Access Layer) which means that it does occupy the same space as an ORM. It isn't an ORM, however, as it takes a different approach (see the "What is DataMgr?" link at the top of the entry for more information).

I do need to test on Blue Dragon and Railo, but it hasn't yet been high on my priority list. I don't know any reason why it wouldn't work on either of them though.

As to speed, I have only run one brief set of performance tests so far and more are certainly needed. In the meantime, here are the results of my first set of tests:
http://www.bryantwebconsulting.com/blog/index.cfm/...
# Posted By Steve Bryant | 8/19/08 6:03 AM
I'll try it out sometime on BD and let you know later.

I figured there was database info gathered via methods other engines don't have.
# Posted By ziggy | 8/19/08 8:41 PM
I saw this code which doesn't work on BD, as I thought:

>>coldfusion.server.ServiceFactory

So, no luck with BD but I did read someone saying this now worked on Railo though (maybe 3 only, not sure), which is good. Really, it's up to BD to fix BD, isn't it? And me to change to Railo 3 when released ;-)

----------------------

Faq ID    258
Product    BlueDragon
Category    Administration, Supported Features
Question    Does BlueDragon support the coldfusion.server.ServiceFactory in CFMX?
Answer    There is an undocumented API for CFMX which provides programmatic access to the Administration of the server, including listing and updating such information as datasources, mappings, schedule tasks, etc. We appreciate that developers want such a solution in BlueDragon.

Still, this ServiceFactory is not only undocumented but has been deprecated in CFMX 7 in favor of a new CFC-based api, we will not be offering any implementation of these identical undocumented ServiceFactory methods.

We had already begun creating a CFC to provide programmatic Admin access even before the CFMX 7 beta began, and we are still debating whether to proceed with and release that, or rewrite to follow CFMX 7's CFC component and method names After resolving this and related matters, we will make the CFC available as soon as possible.

In the meantime, if BlueDragon VAR partners or other customers have a desparate need for this functionality, we have an early version of our own admin api CFC available. Contact sales@newatlanta.com if interested.
# Posted By ziggy | 8/19/08 9:32 PM
Ziggy,

That is actually funny. I just added that in the newest build. It should only execute if you don't provide the "database" argument on initialization. If that isn't the case, then I might have to look at refactoring that a bit.
# Posted By Steve Bryant | 8/20/08 5:23 AM
OK, that's great! I'll give it a whirl when I can.

Thanks!
# Posted By ziggy | 8/20/08 7:34 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.