class UpdateScriptService {

	def run(def connection, def dataSourceFields) {

        at.clockwork.system.service.DataSourceService.execute(
            connection,
            dataSourceFields,
            [
                mySQLStatement:"update cw_sort_definition_detail set sort_expression = 'class TService { static transactional = false; int run(def a, def b, Map rM) { (a.person.dateOfEntry?.getMonth()?:0)*100+(a.person.dateOfEntry?.getDate()?:0) <=> (b.person.dateOfEntry?.getMonth()?:0)*100+(b.person.dateOfEntry?.getDate()?:0) } }' where sort_expression = 'class TestService { static transactional = false; int run(def a, def b) { (a.person.dateOfEntry?.getMonth() ?: 0) * 100 + (a.person.dateOfEntry?.getDate() ?: 0) <=> (b.person.dateOfEntry?.getMonth() ?: 0) * 100 + (b.person.dateOfEntry?.getDate() ?: 0) } }'",
                msSQLStatement:"update cw_sort_definition_detail set sort_expression = 'class TService { static transactional = false; int run(def a, def b, Map rM) { (a.person.dateOfEntry?.getMonth()?:0)*100+(a.person.dateOfEntry?.getDate()?:0) <=> (b.person.dateOfEntry?.getMonth()?:0)*100+(b.person.dateOfEntry?.getDate()?:0) } }' where sort_expression = 'class TestService { static transactional = false; int run(def a, def b) { (a.person.dateOfEntry?.getMonth() ?: 0) * 100 + (a.person.dateOfEntry?.getDate() ?: 0) <=> (b.person.dateOfEntry?.getMonth() ?: 0) * 100 + (b.person.dateOfEntry?.getDate() ?: 0) } }'"
            ]
        )

        at.clockwork.system.service.DataSourceService.execute(
            connection,
            dataSourceFields,
            [
                mySQLStatement:"update cw_sort_definition_detail set sort_expression = 'class TService { static transactional = false; int run(def a, def b, Map rM) { (a.person.dateOfBirth?.getMonth()?:0)*100+(a.person.dateOfBirth?.getDate()?:0) <=> (b.person.dateOfBirth?.getMonth()?:0)*100+(b.person.dateOfBirth?.getDate()?:0) } }' where sort_expression = 'class TestService { static transactional = false; int run(def a, def b) { (a.person.dateOfBirth?.getMonth() ?: 0) * 100 + (a.person.dateOfBirth?.getDate() ?: 0) <=> (b.person.dateOfBirth?.getMonth() ?: 0) * 100 + (b.person.dateOfBirth?.getDate() ?: 0) } }'",
                msSQLStatement:"update cw_sort_definition_detail set sort_expression = 'class TService { static transactional = false; int run(def a, def b, Map rM) { (a.person.dateOfBirth?.getMonth()?:0)*100+(a.person.dateOfBirth?.getDate()?:0) <=> (b.person.dateOfBirth?.getMonth()?:0)*100+(b.person.dateOfBirth?.getDate()?:0) } }' where sort_expression = 'class TestService { static transactional = false; int run(def a, def b) { (a.person.dateOfBirth?.getMonth() ?: 0) * 100 + (a.person.dateOfBirth?.getDate() ?: 0) <=> (b.person.dateOfBirth?.getMonth() ?: 0) * 100 + (b.person.dateOfBirth?.getDate() ?: 0) } }'"
            ]
        )

        at.clockwork.system.service.DataSourceService.execute(
            connection,
            dataSourceFields,
            [
                mySQLStatement:"update cw_sort_definition_detail set sort_expression = 'class TService { static transactional = false; int run(def a, def b, Map rM) { a.date <=> b.date } }' where sort_expression = 'class TestService { static transactional = false; int run(def a, def b) { a.date <=> b.date } }'",
                msSQLStatement:"update cw_sort_definition_detail set sort_expression = 'class TService { static transactional = false; int run(def a, def b, Map rM) { a.date <=> b.date } }' where sort_expression = 'class TestService { static transactional = false; int run(def a, def b) { a.date <=> b.date } }'"
            ]
        )

		true

	}
}