Changeset 116 for trunk/grails-app/conf


Ignore:
Timestamp:
Apr 14, 2009, 10:16:05 PM (16 years ago)
Author:
gav
Message:

First commit of Inventory domain, including domain-classes, controllers, views and bootstrap. Also double check/adjust as required security extends in controllers.

File:
1 edited

Legend:

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

    r114 r116  
    3333        println "BootStrapping demo data..."
    3434   
    35         //TypeOfPersonGroup
     35//TypeOfPersonGroup
    3636        def personGroupTypeInstance
    3737        personGroupTypeInstance = new PersonGroupType(name:"Department")
     
    4242        BootStrapSaveAndTest(personGroupTypeInstance)
    4343   
    44         //PersonGroup
     44//PersonGroup
    4545        def personGroupInstance
    4646        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"),
     
    6060        BootStrapSaveAndTest(personGroupInstance)
    6161
    62         //Authority
     62//Authority
    6363        def authInstance
    6464
     
    7575        BootStrapSaveAndTest(authInstance)
    7676           
    77         //Person
     77//Person
    7878        def passClearText = "pass"
    7979        def passwordEncoded = authenticateService.encodePassword(passClearText)
     
    149149        personInstance.addToPersonGroups(PersonGroup.findByName("Production"))
    150150
    151         //TaskGroup
     151//TaskGroup
    152152        def taskGroupInstance
    153153
     
    164164        BootStrapSaveAndTest(taskGroupInstance)
    165165
    166         //TaskStatus
     166//TaskStatus
    167167        def taskStatusInstance
    168168   
     
    176176        BootStrapSaveAndTest(taskStatusInstance)
    177177
    178         //TaskPriority
     178//TaskPriority
    179179        def taskPriorityInstance
    180180
     
    191191        BootStrapSaveAndTest(taskPriorityInstance)
    192192
    193         //TaskType
     193//TaskType
    194194        def taskTypeInstance
    195195
     
    209209        BootStrapSaveAndTest(taskTypeInstance)
    210210
    211         //Task
     211//Task
    212212        def taskInstance
    213213
     214        //Task #1
    214215        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
    215216                 taskStatus:TaskStatus.findByName("Not Started"),
     
    221222        BootStrapSaveAndTest(taskInstance)
    222223
     224        //Task #2
    223225        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
    224226                taskStatus:TaskStatus.findByName("Not Started"),
     
    231233        BootStrapSaveAndTest(taskInstance)
    232234
     235        //Task #3
    233236        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
    234237                taskStatus:TaskStatus.findByName("Not Started"),
     
    241244        BootStrapSaveAndTest(taskInstance)
    242245
     246        //Task #4
    243247        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
    244248                 taskStatus:TaskStatus.findByName("Not Started"),
     
    251255        BootStrapSaveAndTest(taskInstance)
    252256
     257        //Task #5
    253258        taskInstance = new Task(taskGroup:TaskGroup.findByName("Production Activites"),
    254259                 taskStatus:TaskStatus.findByName("Not Started"),
     
    260265        BootStrapSaveAndTest(taskInstance)
    261266
     267        //Task #6
    262268        taskInstance = new Task(taskGroup:TaskGroup.findByName("New Projects"),
    263269                 taskStatus:TaskStatus.findByName("Not Started"),
     
    269275        BootStrapSaveAndTest(taskInstance)
    270276
    271         //EntryType
     277//EntryType
    272278        def entryTypeInstance
    273279
     
    284290        BootStrapSaveAndTest(entryTypeInstance)
    285291
    286         //Entry
     292//Entry
    287293        def entryInstance
    288294
     295        //Entry #1
    289296        entryInstance = new Entry(enteredBy: Person.get(6),
    290297                                                    task: Task.get(1),
     
    294301        BootStrapSaveAndTest(entryInstance)
    295302
     303        //Entry #2
    296304        entryInstance = new Entry(enteredBy: Person.get(4),
    297305                                                    task: Task.get(1),
     
    301309        BootStrapSaveAndTest(entryInstance)
    302310
     311        //Entry #3
    303312        entryInstance = new Entry(enteredBy: Person.get(4),
    304313                                                    task: Task.get(1),
     
    308317        BootStrapSaveAndTest(entryInstance)
    309318
    310         //ModificationType
     319//ModificationType
    311320        def taskModificationTypeInstance
    312321        taskModificationTypeInstance = new TaskModificationType(name:"Created").save()
     
    320329        taskModificationTypeInstance = new TaskModificationType(name:"NameModified").save()
    321330   
    322         //AssignedPerson
     331//AssignedPerson
    323332        def assignedPersonInstance
    324333
     334        //AssignedPerson #1
    325335        assignedPersonInstance = new AssignedPerson(person: Person.get(4),
    326336                                                                                        task: Task.get(1),
     
    329339        BootStrapSaveAndTest(assignedPersonInstance)
    330340
     341        //AssignedPerson #2
    331342        assignedPersonInstance = new AssignedPerson(person: Person.get(5),
    332343                                                                                        task: Task.get(1),
     
    335346        BootStrapSaveAndTest(assignedPersonInstance)
    336347
    337 
    338         //Finally did it all work.       
     348//Site
     349        def siteInstance
     350
     351        siteInstance = new Site(name: "Commercial Site")
     352        BootStrapSaveAndTest(siteInstance)
     353
     354//Asset
     355        def assetInstance
     356
     357        assetInstance = new Asset(name: "RockCrusher1")
     358        BootStrapSaveAndTest(assetInstance)
     359
     360
     361//InventoryStore
     362        def inventoryStoreInstance = new InventoryStore(site: Site.get(1),
     363                                                                                            name: "Store #1")
     364        BootStrapSaveAndTest(inventoryStoreInstance)
     365
     366//StoreLocation
     367        def storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1),
     368                                                                            bin: "A1-2")
     369        BootStrapSaveAndTest(storeLocation)
     370
     371//UnitOfMeasure
     372        def unitOfMeasureInstance
     373
     374        unitOfMeasureInstance = new UnitOfMeasure(name: "each")
     375        BootStrapSaveAndTest(unitOfMeasureInstance)
     376
     377        unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)")
     378        BootStrapSaveAndTest(unitOfMeasureInstance)
     379
     380        unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)")
     381        BootStrapSaveAndTest(unitOfMeasureInstance)
     382
     383        unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)")
     384        BootStrapSaveAndTest(unitOfMeasureInstance)
     385
     386        unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)")
     387        BootStrapSaveAndTest(unitOfMeasureInstance)
     388
     389//InventoryGroup
     390        def inventoryGroupInstance
     391
     392        inventoryGroupInstance = new InventoryGroup(name: "Misc")
     393        BootStrapSaveAndTest(inventoryGroupInstance)
     394
     395//InventoryType
     396        def inventoryTypeInstance
     397
     398        inventoryTypeInstance = new InventoryType(name: "Consumable")
     399        BootStrapSaveAndTest(inventoryTypeInstance)
     400
     401        inventoryTypeInstance = new InventoryType(name: "Repairable")
     402        BootStrapSaveAndTest(inventoryTypeInstance)
     403
     404//InventoryItem
     405        def inventoryItemInstance
     406
     407        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1),
     408                                                                                    inventoryType: InventoryType.get(1),
     409                                                                                    unitOfMeasure: UnitOfMeasure.get(1),
     410                                                                                    name: "1051 Bearing",
     411                                                                                    reorderPoint: 0)
     412        BootStrapSaveAndTest(inventoryItemInstance)
     413
     414//StoredItem
     415        def storedItemInstance
     416
     417        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1),
     418                                                                            storeLocation: StoreLocation.get(1),
     419                                                                            quantity: 8)
     420        BootStrapSaveAndTest(storedItemInstance)
     421
     422//Finally did it all work.       
    339423        if(BootStrapDemoDataSuccessful) {
    340424            println "BootStrapping demo data...successful."
     
    342426        else println "BootStrapping demo data...failed."
    343427    }
    344    
     428
     429//Call this function instead of .save()
    345430    void BootStrapSaveAndTest(object) {
    346431        if(!object.save()) {
Note: See TracChangeset for help on using the changeset viewer.