import at.clockwork.transfer.gwtTransfer.client.enumeration.AbsenceValueLikeEnum
import at.clockwork.time.domain.*

import grails.util.Holders

class UpdateScriptService {

	def absenceWriteService = Holders.grailsApplication.mainContext.getBean 'absenceWriteService'

	def run(def connection, def dataSourceFields) {

        Absence.findAll().each { absence ->

            if (absence.absenceValueLikeEnum == null) {

                if (absence.valueLikePause == true)
                    absence.absenceValueLikeEnum = AbsenceValueLikeEnum.PAUSE
                else
                    absence.absenceValueLikeEnum = AbsenceValueLikeEnum.PRESENCE

                absenceWriteService.save(absence)

    		}

        }

		true
	}
}