Changeset 21 for trunk/src/grails-app


Ignore:
Timestamp:
Jan 19, 2009, 8:31:46 PM (15 years ago)
Author:
gavin
Message:

Remove TypeOfClass? and change to ClassType?. Update ERD to match.
Create and add openMimLogo/Icon.
Generate-all *.
Configure BootStrap? and add entries, some not saving yet.
Update DatabaseDesign?.tex and index.gsp

Location:
trunk/src/grails-app
Files:
29 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/grails-app/conf/BootStrap.groovy

    r20 r21  
    1 class BootStrap {
     1import grails.util.GrailsUtil
    22
    3      def init = { servletContext ->
     3class BootStrap
     4{
     5    def init = { servletContext ->
    46
    5         //TypeOfPersonGroup
    6          new TypeOfPersonGroup(name:"Department").save()
    7          new TypeOfPersonGroup(name:"Contractor").save()
    8          new TypeOfPersonGroup(name:"ProjectTeam").save()
    9          
    10          //PersonGroup
    11          new PersonGroup(typeOfPersonGroup:TypeOfPersonGroup.get(1),
    12              name:"Electrical").save()
    13          new PersonGroup(typeOfPersonGroup:TypeOfPersonGroup.get(2),
    14              name:"Kewl AirCon Guys").save()
    15          new PersonGroup(typeOfPersonGroup:TypeOfPersonGroup.get(3),
    16              name:"openMim").save()
    17      }
     7    println "**** BootStrap; GrailsUtil.environment: ${GrailsUtil.environment}"
     8   
     9        switch (GrailsUtil.environment)
     10        {
     11            case "development":
     12                        println "**** BootStrap detected development"
     13                        configureForDevelopment()
     14                        break
     15            case "test":
     16                        println "**** BootStrap detected test"
     17                        configureForTest()
     18                        break
     19            case "production":
     20                        println "**** BootStrap detected production"
     21                        configureForProduction()
     22                        break
     23        }
     24   
     25    }
    1826
    1927    def destroy = {
    20      }
     28    }
     29   
     30    /*
     31        Tasks to do when Grails is running in each environment.
     32    */
     33    void configureForDevelopment()
     34    {
     35        println "BootStrap configureForDevelopment() called"
     36   
     37        //TypeOfPersonGroup
     38        new PersonGroupType(name:"Department").save()
     39        println "PersonGroup = ${PersonGroupType.get(1)}"
     40        new PersonGroupType(name:"Contractor").save()
     41        new PersonGroupType(name:"ProjectTeam").save()
     42   
     43        //PersonGroup
     44        new PersonGroup(PersonGroupType:PersonGroupType.findByName("Department"), name:"Electrical").save()
     45        new PersonGroup(
     46            PersonGroupType:PersonGroupType.get(2),
     47            name:"Kewl AirCon Guys").save()
     48        new PersonGroup(
     49            PersonGroupType:PersonGroupType.get(3),
     50            name:"openMim").save()
     51           
     52        //Person
     53        new Person(personGroup:PersonGroup.get(1),
     54            firstName:"FirstNameTech1",
     55            lastName:"LastNameTech1").save()
     56        new Person(personGroup:PersonGroup.get(2),
     57                    firstName:"Joe",
     58                    lastName:"Samples").save()
     59   
     60    }
     61   
     62    //---------------------------------------------------------
     63    void configureForTest()
     64    {
     65        println "BootStrap configureForTest() called"
     66    }
     67   
     68    //---------------------------------------------------------
     69    void configureForProduction()
     70    {
     71        println "BootStrap configureForProduction() called"
     72    }
     73
    2174}
  • trunk/src/grails-app/controllers/EntryController.groovy

    r16 r21  
    11class EntryController {
     2   
     3    def index = { redirect(action:list,params:params) }
    24
    3     def scaffold = Entry
     5    // the delete, save and update actions only accept POST requests
     6    def allowedMethods = [delete:'POST', save:'POST', update:'POST']
     7
     8    def list = {
     9        if(!params.max) params.max = 10
     10        [ entryInstanceList: Entry.list( params ) ]
     11    }
     12
     13    def show = {
     14        def entryInstance = Entry.get( params.id )
     15
     16        if(!entryInstance) {
     17            flash.message = "Entry not found with id ${params.id}"
     18            redirect(action:list)
     19        }
     20        else { return [ entryInstance : entryInstance ] }
     21    }
     22
     23    def delete = {
     24        def entryInstance = Entry.get( params.id )
     25        if(entryInstance) {
     26            entryInstance.delete()
     27            flash.message = "Entry ${params.id} deleted"
     28            redirect(action:list)
     29        }
     30        else {
     31            flash.message = "Entry not found with id ${params.id}"
     32            redirect(action:list)
     33        }
     34    }
     35
     36    def edit = {
     37        def entryInstance = Entry.get( params.id )
     38
     39        if(!entryInstance) {
     40            flash.message = "Entry not found with id ${params.id}"
     41            redirect(action:list)
     42        }
     43        else {
     44            return [ entryInstance : entryInstance ]
     45        }
     46    }
     47
     48    def update = {
     49        def entryInstance = Entry.get( params.id )
     50        if(entryInstance) {
     51            entryInstance.properties = params
     52            if(!entryInstance.hasErrors() && entryInstance.save()) {
     53                flash.message = "Entry ${params.id} updated"
     54                redirect(action:show,id:entryInstance.id)
     55            }
     56            else {
     57                render(view:'edit',model:[entryInstance:entryInstance])
     58            }
     59        }
     60        else {
     61            flash.message = "Entry not found with id ${params.id}"
     62            redirect(action:edit,id:params.id)
     63        }
     64    }
     65
     66    def create = {
     67        def entryInstance = new Entry()
     68        entryInstance.properties = params
     69        return ['entryInstance':entryInstance]
     70    }
     71
     72    def save = {
     73        def entryInstance = new Entry(params)
     74        if(!entryInstance.hasErrors() && entryInstance.save()) {
     75            flash.message = "Entry ${entryInstance.id} created"
     76            redirect(action:show,id:entryInstance.id)
     77        }
     78        else {
     79            render(view:'create',model:[entryInstance:entryInstance])
     80        }
     81    }
    482}
  • trunk/src/grails-app/controllers/ModificationController.groovy

    r16 r21  
    11class ModificationController {
     2   
     3    def index = { redirect(action:list,params:params) }
    24
    3     def scaffold = Modification
     5    // the delete, save and update actions only accept POST requests
     6    def allowedMethods = [delete:'POST', save:'POST', update:'POST']
     7
     8    def list = {
     9        if(!params.max) params.max = 10
     10        [ modificationInstanceList: Modification.list( params ) ]
     11    }
     12
     13    def show = {
     14        def modificationInstance = Modification.get( params.id )
     15
     16        if(!modificationInstance) {
     17            flash.message = "Modification not found with id ${params.id}"
     18            redirect(action:list)
     19        }
     20        else { return [ modificationInstance : modificationInstance ] }
     21    }
     22
     23    def delete = {
     24        def modificationInstance = Modification.get( params.id )
     25        if(modificationInstance) {
     26            modificationInstance.delete()
     27            flash.message = "Modification ${params.id} deleted"
     28            redirect(action:list)
     29        }
     30        else {
     31            flash.message = "Modification not found with id ${params.id}"
     32            redirect(action:list)
     33        }
     34    }
     35
     36    def edit = {
     37        def modificationInstance = Modification.get( params.id )
     38
     39        if(!modificationInstance) {
     40            flash.message = "Modification not found with id ${params.id}"
     41            redirect(action:list)
     42        }
     43        else {
     44            return [ modificationInstance : modificationInstance ]
     45        }
     46    }
     47
     48    def update = {
     49        def modificationInstance = Modification.get( params.id )
     50        if(modificationInstance) {
     51            modificationInstance.properties = params
     52            if(!modificationInstance.hasErrors() && modificationInstance.save()) {
     53                flash.message = "Modification ${params.id} updated"
     54                redirect(action:show,id:modificationInstance.id)
     55            }
     56            else {
     57                render(view:'edit',model:[modificationInstance:modificationInstance])
     58            }
     59        }
     60        else {
     61            flash.message = "Modification not found with id ${params.id}"
     62            redirect(action:edit,id:params.id)
     63        }
     64    }
     65
     66    def create = {
     67        def modificationInstance = new Modification()
     68        modificationInstance.properties = params
     69        return ['modificationInstance':modificationInstance]
     70    }
     71
     72    def save = {
     73        def modificationInstance = new Modification(params)
     74        if(!modificationInstance.hasErrors() && modificationInstance.save()) {
     75            flash.message = "Modification ${modificationInstance.id} created"
     76            redirect(action:show,id:modificationInstance.id)
     77        }
     78        else {
     79            render(view:'create',model:[modificationInstance:modificationInstance])
     80        }
     81    }
    482}
  • trunk/src/grails-app/controllers/PersonController.groovy

    r16 r21  
    11class PersonController {
     2   
     3    def index = { redirect(action:list,params:params) }
    24
    3     def scaffold = Person
     5    // the delete, save and update actions only accept POST requests
     6    def allowedMethods = [delete:'POST', save:'POST', update:'POST']
     7
     8    def list = {
     9        if(!params.max) params.max = 10
     10        [ personInstanceList: Person.list( params ) ]
     11    }
     12
     13    def show = {
     14        def personInstance = Person.get( params.id )
     15
     16        if(!personInstance) {
     17            flash.message = "Person not found with id ${params.id}"
     18            redirect(action:list)
     19        }
     20        else { return [ personInstance : personInstance ] }
     21    }
     22
     23    def delete = {
     24        def personInstance = Person.get( params.id )
     25        if(personInstance) {
     26            personInstance.delete()
     27            flash.message = "Person ${params.id} deleted"
     28            redirect(action:list)
     29        }
     30        else {
     31            flash.message = "Person not found with id ${params.id}"
     32            redirect(action:list)
     33        }
     34    }
     35
     36    def edit = {
     37        def personInstance = Person.get( params.id )
     38
     39        if(!personInstance) {
     40            flash.message = "Person not found with id ${params.id}"
     41            redirect(action:list)
     42        }
     43        else {
     44            return [ personInstance : personInstance ]
     45        }
     46    }
     47
     48    def update = {
     49        def personInstance = Person.get( params.id )
     50        if(personInstance) {
     51            personInstance.properties = params
     52            if(!personInstance.hasErrors() && personInstance.save()) {
     53                flash.message = "Person ${params.id} updated"
     54                redirect(action:show,id:personInstance.id)
     55            }
     56            else {
     57                render(view:'edit',model:[personInstance:personInstance])
     58            }
     59        }
     60        else {
     61            flash.message = "Person not found with id ${params.id}"
     62            redirect(action:edit,id:params.id)
     63        }
     64    }
     65
     66    def create = {
     67        def personInstance = new Person()
     68        personInstance.properties = params
     69        return ['personInstance':personInstance]
     70    }
     71
     72    def save = {
     73        def personInstance = new Person(params)
     74        if(!personInstance.hasErrors() && personInstance.save()) {
     75            flash.message = "Person ${personInstance.id} created"
     76            redirect(action:show,id:personInstance.id)
     77        }
     78        else {
     79            render(view:'create',model:[personInstance:personInstance])
     80        }
     81    }
    482}
  • trunk/src/grails-app/controllers/TaskController.groovy

    r16 r21  
    11class TaskController {
     2   
     3    def index = { redirect(action:list,params:params) }
    24
    3     def scaffold = Task
     5    // the delete, save and update actions only accept POST requests
     6    def allowedMethods = [delete:'POST', save:'POST', update:'POST']
     7
     8    def list = {
     9        if(!params.max) params.max = 10
     10        [ taskInstanceList: Task.list( params ) ]
     11    }
     12
     13    def show = {
     14        def taskInstance = Task.get( params.id )
     15
     16        if(!taskInstance) {
     17            flash.message = "Task not found with id ${params.id}"
     18            redirect(action:list)
     19        }
     20        else { return [ taskInstance : taskInstance ] }
     21    }
     22
     23    def delete = {
     24        def taskInstance = Task.get( params.id )
     25        if(taskInstance) {
     26            taskInstance.delete()
     27            flash.message = "Task ${params.id} deleted"
     28            redirect(action:list)
     29        }
     30        else {
     31            flash.message = "Task not found with id ${params.id}"
     32            redirect(action:list)
     33        }
     34    }
     35
     36    def edit = {
     37        def taskInstance = Task.get( params.id )
     38
     39        if(!taskInstance) {
     40            flash.message = "Task not found with id ${params.id}"
     41            redirect(action:list)
     42        }
     43        else {
     44            return [ taskInstance : taskInstance ]
     45        }
     46    }
     47
     48    def update = {
     49        def taskInstance = Task.get( params.id )
     50        if(taskInstance) {
     51            taskInstance.properties = params
     52            if(!taskInstance.hasErrors() && taskInstance.save()) {
     53                flash.message = "Task ${params.id} updated"
     54                redirect(action:show,id:taskInstance.id)
     55            }
     56            else {
     57                render(view:'edit',model:[taskInstance:taskInstance])
     58            }
     59        }
     60        else {
     61            flash.message = "Task not found with id ${params.id}"
     62            redirect(action:edit,id:params.id)
     63        }
     64    }
     65
     66    def create = {
     67        def taskInstance = new Task()
     68        taskInstance.properties = params
     69        return ['taskInstance':taskInstance]
     70    }
     71
     72    def save = {
     73        def taskInstance = new Task(params)
     74        if(!taskInstance.hasErrors() && taskInstance.save()) {
     75            flash.message = "Task ${taskInstance.id} created"
     76            redirect(action:show,id:taskInstance.id)
     77        }
     78        else {
     79            render(view:'create',model:[taskInstance:taskInstance])
     80        }
     81    }
    482}
  • trunk/src/grails-app/controllers/TaskGroupController.groovy

    r16 r21  
    11class TaskGroupController {
     2   
     3    def index = { redirect(action:list,params:params) }
    24
    3     def scaffold = TaskGroup
     5    // the delete, save and update actions only accept POST requests
     6    def allowedMethods = [delete:'POST', save:'POST', update:'POST']
     7
     8    def list = {
     9        if(!params.max) params.max = 10
     10        [ taskGroupInstanceList: TaskGroup.list( params ) ]
     11    }
     12
     13    def show = {
     14        def taskGroupInstance = TaskGroup.get( params.id )
     15
     16        if(!taskGroupInstance) {
     17            flash.message = "TaskGroup not found with id ${params.id}"
     18            redirect(action:list)
     19        }
     20        else { return [ taskGroupInstance : taskGroupInstance ] }
     21    }
     22
     23    def delete = {
     24        def taskGroupInstance = TaskGroup.get( params.id )
     25        if(taskGroupInstance) {
     26            taskGroupInstance.delete()
     27            flash.message = "TaskGroup ${params.id} deleted"
     28            redirect(action:list)
     29        }
     30        else {
     31            flash.message = "TaskGroup not found with id ${params.id}"
     32            redirect(action:list)
     33        }
     34    }
     35
     36    def edit = {
     37        def taskGroupInstance = TaskGroup.get( params.id )
     38
     39        if(!taskGroupInstance) {
     40            flash.message = "TaskGroup not found with id ${params.id}"
     41            redirect(action:list)
     42        }
     43        else {
     44            return [ taskGroupInstance : taskGroupInstance ]
     45        }
     46    }
     47
     48    def update = {
     49        def taskGroupInstance = TaskGroup.get( params.id )
     50        if(taskGroupInstance) {
     51            taskGroupInstance.properties = params
     52            if(!taskGroupInstance.hasErrors() && taskGroupInstance.save()) {
     53                flash.message = "TaskGroup ${params.id} updated"
     54                redirect(action:show,id:taskGroupInstance.id)
     55            }
     56            else {
     57                render(view:'edit',model:[taskGroupInstance:taskGroupInstance])
     58            }
     59        }
     60        else {
     61            flash.message = "TaskGroup not found with id ${params.id}"
     62            redirect(action:edit,id:params.id)
     63        }
     64    }
     65
     66    def create = {
     67        def taskGroupInstance = new TaskGroup()
     68        taskGroupInstance.properties = params
     69        return ['taskGroupInstance':taskGroupInstance]
     70    }
     71
     72    def save = {
     73        def taskGroupInstance = new TaskGroup(params)
     74        if(!taskGroupInstance.hasErrors() && taskGroupInstance.save()) {
     75            flash.message = "TaskGroup ${taskGroupInstance.id} created"
     76            redirect(action:show,id:taskGroupInstance.id)
     77        }
     78        else {
     79            render(view:'create',model:[taskGroupInstance:taskGroupInstance])
     80        }
     81    }
    482}
  • trunk/src/grails-app/domain/Entry.groovy

    r18 r21  
    88    static hasMany = [persons: Person]
    99
    10     static belongsTo = [TypeOfEntry, Task, Person]
     10    static belongsTo = [EntryType, Task, Person]
    1111
    1212    static constraints = {
  • trunk/src/grails-app/domain/Modification.groovy

    r18 r21  
    11class Modification {
    22    Person person
    3     TypeOfModification typeOfModification
     3    ModificationType modificationType
    44    Task task
    55    Date dateTime
    66    String comments
    77
    8     static belongsTo = [Person, TypeOfModification, Task]
     8    static belongsTo = [Person, ModificationType, Task]
    99
    1010    static constraints = {
    1111        person()
    12         typeOfModification()
     12        modificationType()
    1313        task()
    1414        dateTime()
  • trunk/src/grails-app/domain/Person.groovy

    r19 r21  
    77
    88    static hasMany = [modifications : Modification,
    9                         entries : Entry, tasks : Task,
     9                        entries : Entry,
     10                        tasks : Task,
    1011                        personGroups : PersonGroup]
    1112
  • trunk/src/grails-app/domain/PersonGroup.groovy

    r19 r21  
    11class PersonGroup {
    2     TypeOfPersonGroup typeOfPersonGroup
     2    PersonGroupType personGroupType
    33    String name
    44    String description = ""
     
    77    static hasMany = [persons : Person]
    88
    9     static belongsTo = TypeOfPersonGroup
     9    static belongsTo = PersonGroup
    1010
    1111    String toString() {
  • trunk/src/grails-app/views/layouts/main.gsp

    r17 r21  
    11<html>
    22    <head>
    3         <title><g:layoutTitle default="Grails" /></title>
     3        <title><g:layoutTitle default="openMim" /></title>
    44        <link rel="stylesheet" href="${createLinkTo(dir:'css',file:'main.css')}" />
    5         <link rel="shortcut icon" href="${createLinkTo(dir:'images',file:'favicon.ico')}" type="image/x-icon" />
     5        <link rel="shortcut icon" href="${createLinkTo(dir:'images',file:'openMimIcon.jpg')}" type="image/x-icon" />
    66        <g:layoutHead />
    77        <g:javascript library="application" />                         
     
    1111            <img src="${createLinkTo(dir:'images',file:'spinner.gif')}" alt="Spinner" />
    1212        </div> 
    13         <div class="logo"><img src="${createLinkTo(dir:'images',file:'grails_logo.jpg')}" alt="Grails" /></div>
     13        <div class="logo"><img src="${createLinkTo(dir:'images',file:'openMimLogo.jpg')}" alt="openMim" /></div>
    1414        <g:layoutBody />               
    1515    </body>     
Note: See TracChangeset for help on using the changeset viewer.