import at.clockwork.security.domain.*

import at.clockwork.singleton.SystemConfigurations
import at.clockwork.transfer.gwtTransfer.client.enumeration.*
import at.clockwork.generated.service.*

import grails.util.Holders

class UpdateScriptService {

	def reportRoleWriteService = Holders.grailsApplication.mainContext.getBean 'reportRoleWriteService'
	def individualReportRoleWriteService = Holders.grailsApplication.mainContext.getBean 'individualReportRoleWriteService'

    SystemConfigurations systemConfigurations = SystemConfigurations.getInstance()

	def run(def connection, def dataSourceFields) {

        List reportList = [
            ReportRole.Event001,
            ReportRole.Event002
        ]

        ReportRole.findAll().each { ReportRole itReportRole ->

            if ( reportList.any{ it == itReportRole.cwID } ) {

                itReportRole.showDetail = true

                reportRoleWriteService.save( itReportRole )

            }

        }

        IndividualReportRole.findAll().each { IndividualReportRole itIndividualReportRole ->

            if ( reportList.any{ it == itIndividualReportRole.cwID } ) {

                itIndividualReportRole.showDetail = true

                individualReportRoleWriteService.save( itIndividualReportRole )

            }

        }

		true

	}

}