Last active
April 28, 2017 20:46
-
-
Save cfvonner/79ea929af09d812cd73c8dc8b2052145 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
component displayname="Base Service" accessors="true" output="false" { | |
property beanFactory; | |
public function init() { | |
return this; | |
} | |
private function populate ( any bean, struct properties, any beanFactory ) { | |
writeLog( text="#GetMetaData( this ).name#-->#getFunctionCalledName()#() arguments: #SerializeJSON( arguments )#", file="GISReports.local.dev", type="information" ); | |
if ( isSimpleValue( bean ) ) { | |
if ( beanFactory.containsBean( bean ) ) bean = beanFactory.getBean( bean ); | |
else bean = beanFactory.construct( bean ); | |
} | |
//TODO: add a test for whether property exists in the bean before trying to push the data in | |
for ( var property in properties ) { | |
if ( !isNull( properties[ property ] ) && | |
( ( isSimpleValue( properties[ property ] ) && Len( properties[ property ] ) ) || | |
!isSimpleValue( properties[ property ] ) ) ) { | |
var args = { }; | |
args[ property ] = properties[ property ]; | |
evaluate( 'bean.set#property#( argumentCollection = args )' ); | |
} | |
} | |
return bean; | |
} | |
private array function populateBeans( required string beanName, required any recordSet ) { | |
var beanArray = []; | |
if ( ( isQuery( recordSet) && recordSet.RecordCount ) || | |
( isArray( recordSet ) && recordSet.len() ) ) { | |
for ( var record in recordSet ) { | |
/*writeLog( text="#GetMetaData( this ).name#-->#getFunctionCalledName()#() for loop: #SerializeJSON( record )#", | |
file="GISReports.local.dev", type="information" );*/ | |
var bean = populate( beanName, record ); | |
beanArray.append( bean ); | |
} | |
} | |
return beanArray; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment