Transfer 0.6.3 RC1 is Released

Wow. I have been pushing like crazy the next release of Transfer finished before I fly out for webDU, and I actually made it.  I leave this afternoon for Sydney at 4:00pm, so I am cutting it fine.

This release has 2 great new features, as well as several critical bug
fixes, not to mention a greatly expanded documentation, including a new
Overview and FAQ.

Rather than try and explain these features all over again, I'm simply going to show off some of the Overview and FAQ:

From the Overview Section:

Transfer Query Language 

is also a scripting language that allows you to perform database
queries based on the information and naming scheme that you set up in
your transfer configuration file called
Transfer Query Language (TQL).  TQL is very similar to SQL,
however since Transfer already knows about the relationships in your
system, you don't have to write as much code to perform complicated
queries against your database.

For example,  if we
wanted to perform a query to list all Posts in my Blog System, with
their Author, and all the Categories they belonged to, ordered by the
post date we would write this in TQL:

<cfsavecontent variable="tql">
    post.Post as Post
        join system.Category
            join user.User
    order by
        Post.dateTime desc

And then we would create a Transfer Query Object by passing the TQL to transfer.createQuery(), and then create the actual query we need by passing the Transfer Query Object to transfer.listByQuery(), as in the example below.

    query = transfer.createQuery(tql);
    qPosts = transfer.listByQuery(query);

Since Transfer already has the relationships between the Post, Category and User, it can intelligently create the SQL joins for you!  Saving you even more time!

There's another Database Management Method you can use with TQL besides transfer.listByQuery(), and that's transfer.readByQuery(). readByQuery returns a Transfer Object, whereas listByQuery() returns a query. readByQuery() requires TQL
that will return only "one row" – if more than one row is returned, an
exception is thrown – and it also requires that you specify the class,
like all the otherreadBy* methods.

Basically, readByQuery()
is a way to create a Transfer Object when you don't want to use the
primary key, but specify some other condition that will return only one

For more information on these Transfer methods, see Using The Data Management Methods .

From the FAQ:

How do I inject dependencies into a TransferObject?

To inject dependencies into a TransferObject, the 'afterNew' event must be used.  

To register an Observer for the afterNew event:

observer = createObject("component", "InjectorObserver").init(); 


The observer must have a method on it that looks like, which is run when the event is fired:

<cffunction name="actionAfterNewTransferEvent" hint="Do something on the new object" access="public" returntype="void" output="false">
    <cfargument name="event" hint="" type="" required="Yes">
    <!--- do stuff here --->

The event is then fired *after* the TransferObject is init()'d and the configure() method is run.

So if you now want to inject something into a TransferObject, you will need to write a setter/getter on it – and you can do it something like this: 

<cffunction name="actionAfterNewTransferEvent" hint="Do something on the new object" access="public" returntype="void" output="false">
    <cfargument name="event" hint="" type="" required="Yes">
    <cfif arguments.event.getTransferObject().getClassName() eq "user.User">
         <cfset arguments.event.getTransferObject().setService(getService()) />

A <cfcase> statement could be used instead of an <cfif> depending on your needs.

You could put this event directly on a Factory of some description if
you  wanted to, or have it on a specific object whose only task is to
inject new
TransferObjects with dependencies, depending on your application design.

Full changelog.

A *HUGE* amount of thanks to Nando, Jaime Metcher, and Aaron Roberson for all the hard work they put into the documentation.  It was greatly appreciated.

You may have also noticed a skip in version numbers.  It's okay, you're
not going totally crazy.  That was just a decision that I made, to
evenly space out all the major feature releases between 0.6.1 and 0.7.

So now the release road map looks like:

0.6.3 : TQL
0.6.6 : Composite Keys
0.6.9 : Soft Deletes
0.7 : All the other small pieces I wanted to fit into 0.7

It also gives me some wiggle room in case I need/want to do a maintenance release between.

Now, I'm off to webDU, and if you are attending, I hope you come and hear me speak!

You can download Transfer from here.

Leave a Comment