RE: [coldbox:8245] coldbox platform utilities v2.5 released

Convert ColdSpring to WireBox in 1 click

Are we planning on a way to convert your old beanfactory ModelMapping.cfm config to the new WireBox config in one click?

On that note, one thing I’m a little unclear on after reading the WireBox docs (and watching the Will Smith video :slight_smile: is if WireBox can still use the soon-to-be-deprecated addModelMapping() calls without having to run in compat mode. In other words, I’m installing RC2 in my app right now. Am I required to convert to the new mapping DSL now, or can I limp by the with legacy config file and still use the new WireBox?

Thanks!

~Brad

Well, you can limp on it, but the idea is to deprecate the modelMappings completely by 3.1. The methods are now marked as deprecated to favor wirebox integration. So I would stick to a migration plan.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

So have you thought about being able to automatically upgrade the old modelMappings.cfm to the new bind syntax. I realize that the ColdSpring XML is static and easier to convert than a programmatic config that could potentially have if statements or any other kinds of conditional code in it. It seems like a little bit of regex could convert most basic legacy mapping configs and even keep the comments and such intact.

Thanks!

~Brad

yea, I had not thought of it actually, as changing them is pretty easy

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

changing them is pretty easy

Yeah, but I have 211 models mapped, which is about 210 more than I feel like changing by hand. :slight_smile:

~Brad

Ok, I’m not too good at regex, but I came up with a reReplaceNoCase that seems to work pretty well. Can a few of you with funky model mappings try pasting yours between the cfsavecontent tags in my code sample below and running it to see if it successfully converts your mappings while leaving any other surrounding code/comments intact?

The only place where this doesn’t work is in some cases where there are nested function calls inside of the addModelMapping call. The only way to solve that would be with some simple code parsing to count opening and closing parenthesis, but it’s probably not worth it if that is an edge case.

Thanks!

~Brad

// regular
addModelMapping(‘ConstantService’,‘com.ruceci.Utility.ConstantService’);

// Named arguments
addModelMapping(alias=“myAlias”,path=‘com.ruceci.Utility.ConstantService’);

// Lots of spaces!
addModelMapping ( alias = “myAlias” , path = ‘com.ruceci.Utility.ConstantService’ ) ;

// Funky!
addModelMapping(
alias=“myAlias”,
path=‘com.ruceci.Utility.ConstantService’
);

// random variable set
mappingPrefix = “com.ruceci”;

// with stuff
addModelMapping(‘ConstantService’,’#mappingPrefix#.Utility.ConstantService’);
// other stuff
addModelMapping(“ConstantService”,mappingPrefix & ‘.Utility.ConstantService’);

// conditional
if(foo == ‘bar’)
{
addModelMapping(‘ConstantService’,‘com.ruceci.Utility.ConstantService’);
}
else
{
addModelMapping(‘123’,‘com.ruceci.Utility.ConstantService’);
}

addModelMapping(variableName,‘com.ruceci.Utility.ConstantService’);

// This works
addModelMapping(“foobar”,right(“Hello”,3));

// Sadly, these do not
addModelMapping(left(“foobar”,2),“Hello”);
addModelMapping(left(“foobar”,2),right(“Hello”,3));

#reReplaceNoCase(modelMappings,regex,"map(\2).to(\4);","ALL")#

I see nobody jumped at this. Is it because no one is really paying attention or am I just the only one who thinks this would be useful? :slight_smile: (You can be honest)

On this note, I converted my local environment to RC2 and wirebox today and I threw all my 211 model mappings away in favor of one very sexy mapDirectory(). That being said, I’d still like to finish an automatic converter even if no one uses it just because it sounds fun. :slight_smile:

Thanks!

~Brad

I am sure it will be very useful in time, although I am not 100% on what you talking about when you say 211, but if it is to migrate older code over to CB3.0 I think it will be very useful.

Regards,

Andrew Scott

http://www.andyscott.id.au/

The 211 was a reference to the number of model mappings I had. (I mentioned it in this thread yesterday) Luis said they were easy to convert by hand, and I said that I had about 210 too many for that. :slight_smile:

~Brad

Would be useful. Just not running the latest version yet so can't test.

- Gabriel

Well, here's the pull request for it:

It works ok on my machine with my test modelMapping.cfm files, but for simplicity, it currently makes a few assumptions about what your code will look like. Most notably that all your model mappings will exist in the first cfscript tag in the file and will not use nested function calls that take multiple parameters.

Unless Luis likes it enough to merge it into the main repo and release it I don't know how anyone can easily try it out unless they download the code

Thanks!

~Brad

thanks, integrated it

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com