Changeset 534


Ignore:
Timestamp:
May 16, 2010, 3:49:30 PM (14 years ago)
Author:
gav
Message:

Refactor CreateDataService so that demo asset tree is created first, thus allowing assets to be assigned to demo tasks.
Also some adjustmets so that Demo Manager has some recurring tasks to view.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/CreateDataService.groovy

    r529 r534  
    6363        createBaseAddressTypes()
    6464        createBaseContactTypes()
     65        createBaseMaintenancePolicies()
    6566        createBaseInventoryItemPurchaseTypes()
     67
     68        // Assets
     69        createBaseExtenededAttributeTypes()
     70
     71        // Inventory
     72        createBaseInventoryTypes()
     73        createBaseInventoryMovementTypes()
    6674
    6775        // Tasks
     
    7482        createBaseEntryTypes()
    7583
    76         // Inventory
    77         createBaseInventoryTypes()
    78         createBaseInventoryMovementTypes()
    79 
    80         // Assets
    81         createBaseExtenededAttributeTypes()
    82         createBaseMaintenancePolicies()
    83 
    8484        // Record that data has been created.
    8585        appConfigService.set("baseDataCreated")
     
    117117        createDemoCostCodes()
    118118
     119        // Assets
     120        createDemoLifePlan()
     121        createDemoSections()
     122        createDemoAssetTree()
     123        createDemoAssetExtenedAttributes()
     124
     125        // Inventory
     126        createDemoInventoryStores()  /// @todo: Perhaps a 'createQuickStartData' method?
     127        createDemoInventoryLocations()
     128        createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method?
     129        createDemoInventoryItems()
     130
    119131        // Tasks
    120132        createDemoTasks()
     
    122134        createDemoAssignedGroups()
    123135        createDemoAssignedPersons()
    124         createDemoTaskRecurringSchedules()
    125 
    126         // Inventory
    127         createDemoInventoryStores()  /// @todo: Perhaps a 'createQuickStartData' method?
    128         createDemoInventoryLocations()
    129         createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method?
    130         createDemoInventoryItems()
    131 
    132         // Assets
    133         createDemoLifePlan()
    134136        createDemoTaskProcedure()
    135137        createDemoMaintenanceActions()
    136         createDemoSections()
    137         createDemoAssetTree()
    138         createDemoAssetExtenedAttributes()
     138        createDemoTaskRecurringSchedules()
    139139
    140140        // Record that data has been created.
     
    829829                taskType:TaskType.get(1),
    830830                leadPerson:Person.get(2),
     831                primaryAsset:Asset.get(4),
    831832                description:"Level sensor not working",
    832833                comment:"Has been noted as problematic, try recalibrating.",
     
    841842                taskType:TaskType.get(3),
    842843                leadPerson:Person.get(5),
     844                primaryAsset:Asset.get(4),
    843845                description:"Some follow-up work",
    844846                comment:"Some help required",
     
    854856                taskType:TaskType.get(3),
    855857                leadPerson:Person.get(5),
     858                primaryAsset:Asset.get(4),
    856859                description:"A Sub Task can be created from the 'Sub Task' tab.",
    857860                comment:"Some help required",
     
    864867        //Task #4
    865868        p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
    866                  taskPriority:TaskPriority.get(2),
    867                  taskType:TaskType.get(2),
    868                  leadPerson:Person.get(4),
    869                  description:"Please replace sensor at next available opportunity.",
    870                  comment:"Nothing else has worked. So we now require the part to be replaced.",
     869                taskPriority:TaskPriority.get(2),
     870                taskType:TaskType.get(2),
     871                leadPerson:Person.get(4),
     872                primaryAsset:Asset.get(4),
     873                description:"Please replace sensor at next available opportunity.",
     874                comment:"Nothing else has worked. So we now require the part to be replaced.",
    871875                targetStartDate: dateUtilService.today,
    872876                targetCompletionDate: dateUtilService.oneWeekFromNow,
     
    877881        //Task #5
    878882        p = [taskGroup:TaskGroup.findByName("Production Activites"),
    879                  taskPriority:TaskPriority.get(2),
    880                  taskType:TaskType.get(3),
    881                  leadPerson:Person.get(6),
    882                  description:"Production Task",
    883                  comment:"Production task for specific production run or shift",
     883                taskPriority:TaskPriority.get(2),
     884                taskType:TaskType.get(3),
     885                leadPerson:Person.get(6),
     886                primaryAsset:Asset.get(1),
     887                description:"Production Task",
     888                comment:"Production task for specific production run or shift",
    884889                targetStartDate: dateUtilService.today - 6,
    885890                targetCompletionDate: dateUtilService.today - 6]
     
    889894        //Task #6
    890895        p = [taskGroup:TaskGroup.findByName("Engineering Activites"),
    891                  taskPriority:TaskPriority.get(4),
    892                  taskType:TaskType.get(3),
    893                  leadPerson:Person.get(4),
    894                  description:"This is a recurring preventative maintenance task.",
    895                  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.",
     896                taskPriority:TaskPriority.get(4),
     897                taskType:TaskType.get(4),
     898                leadPerson:Person.get(4),
     899                primaryAsset:Asset.get(2),
     900                description:"This is a recurring preventative maintenance task.",
     901                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.",
    896902                targetStartDate: dateUtilService.today,
    897903                targetCompletionDate: dateUtilService.today + 30]
    898904
    899905        taskResult = taskService.save(p)
     906        taskService.approve(taskResult.taskInstance)
    900907    }
    901908
     
    947954                comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.",
    948955                durationMinute: 20]
     956
     957        entryResult = taskService.saveEntry(p)
     958
     959        //Entry #4
     960        p = [task: Task.list()[5],
     961                entryType: EntryType.get(3),
     962                comment: "Recurring work done as per procedure.",
     963                durationMinute: 55]
    949964
    950965        entryResult = taskService.saveEntry(p)
     
    977992
    978993        //AssignedPerson #1
    979         p = [person: Person.get(4),
    980                 task: Task.list()[0],
     994        p = [person: Person.get(3), // Demo Manager.
     995                task: Task.list()[5],
    981996                estimatedHour: 1,
    982997                estimatedMinute: 20]
     
    984999
    9851000        //AssignedPerson #2
    986         p = [person: Person.get(5),
     1001        p = [person: Person.get(4), // Demo User.
    9871002                task: Task.list()[0],
    9881003                estimatedHour: 3,
    9891004                estimatedMinute: 30]
    9901005        result = assignedPersonService.save(p)
     1006    }
     1007
     1008    def createBaseMaintenancePolicies() {
     1009
     1010        //MaintenancePolicy
     1011        def maintenancePolicyInstance
     1012
     1013        //MaintenancePolicy #1
     1014        maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time")
     1015        saveAndTest(maintenancePolicyInstance)
     1016
     1017        //MaintenancePolicy #2
     1018        maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online")
     1019        saveAndTest(maintenancePolicyInstance)
     1020
     1021        //MaintenancePolicy #3
     1022        maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline")
     1023        saveAndTest(maintenancePolicyInstance)
     1024
     1025        //MaintenancePolicy #4
     1026        maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out")
     1027        saveAndTest(maintenancePolicyInstance)
     1028
     1029        //MaintenancePolicy #5
     1030        maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure")
     1031        saveAndTest(maintenancePolicyInstance)
     1032
     1033        //MaintenancePolicy #6
     1034        maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement")
     1035        saveAndTest(maintenancePolicyInstance)
     1036
     1037        //MaintenancePolicy #7
     1038        maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test")
     1039        saveAndTest(maintenancePolicyInstance)
     1040    }
     1041
     1042    def createDemoTaskProcedure() {
     1043
     1044        //TaskProcedure
     1045        def taskProcedureInstance
     1046
     1047        taskProcedureInstance = new TaskProcedure(name: "Daily check")
     1048        saveAndTest(taskProcedureInstance)
     1049        taskProcedureInstance.addToTasks(Task.list()[0])
     1050    }
     1051
     1052    def createDemoMaintenanceActions() {
     1053
     1054        //MaintenanceAction
     1055        def maintenanceActionInstance
     1056
     1057        //MaintenanceAction #1
     1058        maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run",
     1059                                                                                                        procedureStepNumber: 10,
     1060                                                                                                        maintenancePolicy: MaintenancePolicy.get(1),
     1061                                                                                                        taskProcedure: TaskProcedure.get(1))
     1062        saveAndTest(maintenanceActionInstance)
     1063
     1064        //MaintenanceAction #2
     1065        maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups",
     1066                                                                                                        procedureStepNumber: 20,
     1067                                                                                                        maintenancePolicy: MaintenancePolicy.get(1),
     1068                                                                                                        taskProcedure: TaskProcedure.get(1))
     1069        saveAndTest(maintenanceActionInstance)
     1070
     1071        //MaintenanceAction #3
     1072        maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup",
     1073                                                                                                        procedureStepNumber: 30,
     1074                                                                                                        maintenancePolicy: MaintenancePolicy.get(1),
     1075                                                                                                        taskProcedure: TaskProcedure.get(1))
     1076        saveAndTest(maintenanceActionInstance)
    9911077    }
    9921078
     
    10081094
    10091095        //TaskRecurringSchedule #2
    1010         taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[0],
     1096        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[5],
    10111097                                                                                                    recurEvery: 1,
    10121098                                                                                                    recurPeriod: Period.get(1),
     
    12291315    }
    12301316
    1231     def createBaseMaintenancePolicies() {
    1232 
    1233         //MaintenancePolicy
    1234         def maintenancePolicyInstance
    1235 
    1236         //MaintenancePolicy #1
    1237         maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time")
    1238         saveAndTest(maintenancePolicyInstance)
    1239 
    1240         //MaintenancePolicy #2
    1241         maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online")
    1242         saveAndTest(maintenancePolicyInstance)
    1243 
    1244         //MaintenancePolicy #3
    1245         maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline")
    1246         saveAndTest(maintenancePolicyInstance)
    1247 
    1248         //MaintenancePolicy #4
    1249         maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out")
    1250         saveAndTest(maintenancePolicyInstance)
    1251 
    1252         //MaintenancePolicy #5
    1253         maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure")
    1254         saveAndTest(maintenancePolicyInstance)
    1255 
    1256         //MaintenancePolicy #6
    1257         maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement")
    1258         saveAndTest(maintenancePolicyInstance)
    1259 
    1260         //MaintenancePolicy #7
    1261         maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test")
    1262         saveAndTest(maintenancePolicyInstance)
    1263     }
    1264 
    1265     def createDemoTaskProcedure() {
    1266 
    1267         //TaskProcedure
    1268         def taskProcedureInstance
    1269 
    1270         taskProcedureInstance = new TaskProcedure(name: "Daily check")
    1271         saveAndTest(taskProcedureInstance)
    1272         taskProcedureInstance.addToTasks(Task.list()[0])
    1273     }
    1274 
    1275     def createDemoMaintenanceActions() {
    1276 
    1277         //MaintenanceAction
    1278         def maintenanceActionInstance
    1279 
    1280         //MaintenanceAction #1
    1281         maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run",
    1282                                                                                                         procedureStepNumber: 1,
    1283                                                                                                         maintenancePolicy: MaintenancePolicy.get(1),
    1284                                                                                                         taskProcedure: TaskProcedure.get(1))
    1285         saveAndTest(maintenanceActionInstance)
    1286 
    1287         //MaintenanceAction #2
    1288         maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups",
    1289                                                                                                         procedureStepNumber: 2,
    1290                                                                                                         maintenancePolicy: MaintenancePolicy.get(1),
    1291                                                                                                         taskProcedure: TaskProcedure.get(1))
    1292         saveAndTest(maintenanceActionInstance)
    1293 
    1294         //MaintenanceAction #3
    1295         maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup",
    1296                                                                                                         procedureStepNumber: 3,
    1297                                                                                                         maintenancePolicy: MaintenancePolicy.get(1),
    1298                                                                                                         taskProcedure: TaskProcedure.get(1))
    1299         saveAndTest(maintenanceActionInstance)
    1300     }
    1301 
    13021317    def createDemoSections() {
    13031318
Note: See TracChangeset for help on using the changeset viewer.