
import at.clockwork.time.domain.*

class ImportPublicHolidaysService {

	static transactional = false //TODO = true

	def run() {

		println "ImportPublicHolidaysService.run() - start"

		PublicHoliday2Detail.executeUpdate("delete from PublicHoliday2Detail where publicHoliday in (from PublicHoliday where deleted = true)")
		PublicHoliday2Detail.executeUpdate("delete from PublicHoliday2Detail where region in (from Region where deleted = true)")
		PublicHoliday2Detail.executeUpdate("delete from PublicHoliday2Detail where religion in (from Religion where deleted = true)")

		PublicHoliday.executeUpdate("delete from PublicHoliday where id not in (select publicHoliday.id from PublicHoliday2Detail)")

		Region.executeUpdate("delete from Region where id not in (select region.id from PublicHoliday2Detail)")

		println "ImportPublicHolidaysService.run() - end"

	}
	
}