Ignore:
Timestamp:
Nov 28, 2009, 2:17:34 PM (14 years ago)
Author:
gav
Message:

Upgrade quartz plugin to 0.4.1 propper.
Refactor and enable quartz scheduling for recurring tasks.
Adjust svn ignores to ignore all log files.
Create a pseudo system person for automated insertions.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 stacktrace.log
         1*.log
        22*.war
  • trunk/grails-app/services/CreateDataService.groovy

    r190 r199  
    1818
    1919    /**
    20     * Always call this at startup to ensure admin access.
     20    * Always call this at startup to ensure that we have admin access
     21    * and that the system pseudo person is available.
    2122    */
    22     def ensureAdminAccess() {
     23    def ensureSystemAndAdminAccess() {
    2324        if(!Authority.findByAuthority("ROLE_AppAdmin") ) {
    24             println "ROLE_AppAdmin not found, calling createAdminAuthority()."
     25            log.warn "ROLE_AppAdmin not found, calling createAdminAuthority()."
    2526            createAdminAuthority()
    2627        }
     28        if(!Person.findByloginName("system") ) {
     29            log.warn "LoginName 'system' not found, calling createSystemPerson()."
     30            createSystemPerson()
     31        }
    2732        if(!Person.findByloginName("admin") ) {
    28             println "LoginName 'admin' not found, calling createAdminPerson()."
     33            log.warn "LoginName 'admin' not found, calling createAdminPerson()."
    2934            createAdminPerson()
    3035        }
     
    3540    */
    3641    def createBaseData() {
    37         println "Creating base data..."
     42        log.info "Creating base data..."
    3843        // Person and Utils
    3944        createBaseAuthorities()
    4045        createBasePersonGroups()
    41         createBasePersons()
    4246        createBaseUnitsOfMeasure()
    4347        createBasePeriods()
     
    6468    */
    6569    def createDemoData() {
    66         println "Creating demo data..."
     70        log.info "Creating demo data..."
    6771        // Person and Utils
    6872        createDemoPersons()
     
    148152    }
    149153
     154    def createSystemPerson() {
     155        //Person
     156        def passClearText = "pass"
     157        def passwordEncoded = personService.encodePassword(passClearText)
     158        def personInstance
     159
     160        //Person #1
     161        personInstance = new Person(loginName:"system",
     162                                    firstName:"gnuMims",
     163                                    lastName:"System",
     164                                    description:'''This is a pseudo person that the application uses to insert data. DO NOT
     165                                                        assign login authorities or change the details of this person.''',
     166                                    pass:passClearText,
     167                                    password:passwordEncoded,
     168                                    email:"system@example.com")
     169        saveAndTest(personInstance)
     170    }
     171
    150172    def createAdminPerson() {
    151173        //Person
     
    154176        def personInstance
    155177
    156         //Person #1
     178        //Person #2
    157179        personInstance = new Person(loginName:"admin",
    158180                                    firstName:"Admin",
    159181                                    lastName:"Powers",
     182                                    description:'''Every time the application starts it ensures that the 'admin' login name is available.
     183                                                        DO update the password and other details but keep the login name as 'admin'. ''',
    160184                                    pass:passClearText,
    161185                                    password:passwordEncoded,
     
    166190
    167191    def createBasePersons() {
     192    }
     193
     194    def createDemoPersons() {
    168195        //Person
    169196        def passClearText = "pass"
     
    171198        def personInstance
    172199
    173         //Person #1 is admin.
    174 
    175         //Person #2
     200        //Person #1 is system.
     201        //Person #2 is admin.
     202
     203        //Person #3
    176204        personInstance = new Person(loginName:"manager",
    177205                                    firstName:"Demo",
     
    185213        personInstance.addToPersonGroups(PersonGroup.get(5))
    186214
    187         //Person #3
     215        //Person #4
    188216        personInstance = new Person(loginName:"user",
    189217                                    firstName:"Demo",
     
    195223        personInstance.addToAuthorities(Authority.get(3))
    196224        personInstance.addToPersonGroups(PersonGroup.get(1))
    197     }
    198 
    199     def createDemoPersons() {
    200         //Person
    201         def passClearText = "pass"
    202         def passwordEncoded = personService.encodePassword(passClearText)
    203         def personInstance
    204 
    205         //Person #4
     225
     226        //Person #5
    206227        personInstance = new Person(loginName:"craig",
    207228                                    firstName:"Craig",
     
    214235        personInstance.addToPersonGroups(PersonGroup.get(1))
    215236
    216         //Person #5
     237        //Person #6
    217238        personInstance = new Person(loginName:"john",
    218239                                    firstName:"John",
     
    225246        personInstance.addToPersonGroups(PersonGroup.get(2))
    226247
    227         //Person #6
     248        //Person #7
    228249        personInstance = new Person(loginName:"mann",
    229250                                    firstName:"Production",
     
    425446        def taskPriorityInstance
    426447
    427         taskPriorityInstance = new TaskPriority(name:"Normal")
     448        taskPriorityInstance = new TaskPriority(name:"Normal") // #1
    428449        saveAndTest(taskPriorityInstance)
    429450
    430         taskPriorityInstance = new TaskPriority(name:"Low")
     451        taskPriorityInstance = new TaskPriority(name:"Low") // #2
    431452        saveAndTest(taskPriorityInstance)
    432453
    433         taskPriorityInstance = new TaskPriority(name:"High")
     454        taskPriorityInstance = new TaskPriority(name:"High") // #3
    434455        saveAndTest(taskPriorityInstance)
    435456
    436         taskPriorityInstance = new TaskPriority(name:"Immediate")
     457        taskPriorityInstance = new TaskPriority(name:"Immediate") // #4
    437458        saveAndTest(taskPriorityInstance)
    438459    }
     
    443464        def taskTypeInstance
    444465
    445         taskTypeInstance = new TaskType(name:"Unscheduled Breakin")
     466        taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #1
    446467        saveAndTest(taskTypeInstance)
    447468
    448         taskTypeInstance = new TaskType(name:"Preventative Maintenance")
     469        taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #2
    449470        saveAndTest(taskTypeInstance)
    450471
    451         taskTypeInstance = new TaskType(name:"Project")
     472        taskTypeInstance = new TaskType(name:"Project") // #3
    452473        saveAndTest(taskTypeInstance)
    453474
    454         taskTypeInstance = new TaskType(name:"Turnaround")
     475        taskTypeInstance = new TaskType(name:"Turnaround") // #4
    455476        saveAndTest(taskTypeInstance)
    456477
    457         taskTypeInstance = new TaskType(name:"Production Run")
     478        taskTypeInstance = new TaskType(name:"Production Run") // #5
    458479        saveAndTest(taskTypeInstance)
    459480    }
     
    481502        //Task #1
    482503        p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
    483                 taskStatus:TaskStatus.findByName("Not Started"),
    484504                taskPriority:TaskPriority.get(2),
    485505                taskType:TaskType.get(1),
     
    493513        //Task #2
    494514        p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
    495                 taskStatus:TaskStatus.findByName("Not Started"),
    496515                taskPriority:TaskPriority.get(2),
    497516                taskType:TaskType.get(1),
     
    506525        //Task #3
    507526        p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
    508                 taskStatus:TaskStatus.findByName("Not Started"),
    509527                taskPriority:TaskPriority.get(2),
    510528                taskType:TaskType.get(1),
     
    519537        //Task #4
    520538        p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
    521                  taskStatus:TaskStatus.findByName("Not Started"),
    522539                 taskPriority:TaskPriority.get(2),
    523540                 taskType:TaskType.get(1),
     
    532549        //Task #5
    533550        p = [taskGroup:TaskGroup.findByName("Production Activites"),
    534                  taskStatus:TaskStatus.findByName("Not Started"),
    535551                 taskPriority:TaskPriority.get(2),
    536552                 taskType:TaskType.get(5),
     
    538554                 description:"Production Report",
    539555                 comment:"Production report for specific production run or shift",
    540                 targetStartDate:new Date()-7]
     556                targetStartDate:new Date()-6]
    541557
    542558        taskResult = taskService.create(p)
    543559
    544560        //Task #6
    545         p = [taskGroup:TaskGroup.findByName("New Projects"),
    546                  taskStatus:TaskStatus.findByName("Not Started"),
    547                  taskPriority:TaskPriority.get(2),
    548                  taskType:TaskType.get(3),
    549                  leadPerson:Person.get(1),
    550                  description:"Make killer CMMS app",
    551                  comment:"Use Grails and get a move on!",
    552                 targetStartDate:new Date()-6]
     561        p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
     562                 taskPriority:TaskPriority.get(1),
     563                 taskType:TaskType.get(2),
     564                 leadPerson:Person.get(4),
     565                 description:"This is a recurring task",
     566                 comment:"If there is a parent task specified then this is a generated sub task, if there is a recurring schedule specified then this is a parent task.",
     567                targetStartDate:new Date()]
    553568
    554569        taskResult = taskService.create(p)
     
    631646        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1),
    632647                                                                                                    recurEvery: 1,
    633                                                                                                     recurPeriod: Period.get(1),
    634                                                                                                     startDate: new Date(),
     648                                                                                                    recurPeriod: Period.get(2),
     649                                                                                                    nextTargetStartDate: new Date(),
    635650                                                                                                    generateAhead: 1,
    636                                                                                                     generateAheadPeriod: Period.get(1),
    637                                                                                                     taskDuration: 1,
    638                                                                                                     taskDurationPeriod: Period.get(1))
     651                                                                                                    taskDuration: 2,
     652                                                                                                    taskDurationPeriod: Period.get(1),
     653                                                                                                    enabled: false)
    639654        saveAndTest(taskRecurringScheduleInstance)
    640655
    641656        //TaskRecurringSchedule #2
    642         taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(2),
     657        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6),
    643658                                                                                                    recurEvery: 1,
    644659                                                                                                    recurPeriod: Period.get(1),
    645                                                                                                     startDate: new Date(),
     660                                                                                                    nextTargetStartDate: new Date(),
    646661                                                                                                    generateAhead: 1,
    647                                                                                                     generateAheadPeriod: Period.get(1),
    648662                                                                                                    taskDuration: 1,
    649                                                                                                     taskDurationPeriod: Period.get(1))
     663                                                                                                    taskDurationPeriod: Period.get(1),
     664                                                                                                    enabled: true)
    650665        saveAndTest(taskRecurringScheduleInstance)
    651666    }
     
    10511066        if(!object.save()) {
    10521067//             DemoDataSuccessful = false
    1053             println "'${object}' failed to save!"
    1054             println object.errors
     1068            log.error "'${object}' failed to save!"
     1069            log.error object.errors
    10551070            return false
    10561071        }
Note: See TracChangeset for help on using the changeset viewer.