Changeset 798 for trunk/grails-app/services
- Timestamp:
- Feb 8, 2011, 11:00:27 PM (14 years ago)
- Location:
- trunk/grails-app/services
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/AssetService.groovy
r689 r798 22 22 } 23 23 } 24 } 25 26 /** 27 * Determines and returns a list of assemblies for an asset. 28 * This is purely a 'load from database' type method since a new hibernateSession is used. 29 * @params Asset to get the subItems for. 30 * @returns A list of the assemblies. 31 */ 32 def getAssemblies(asset) { 33 def assemblies = [] 34 if(!(asset instanceof Asset)) 35 return assemblies 36 // Database efficiency: 37 // The asset is configured to batch fetch assetSubItems which 38 // in turn are configured to batch fetch subItems. 39 Asset.withNewSession { 40 Asset.get(asset.id).assetSubItems.each { 41 assemblies.addAll(it.subItems) 42 } 43 } 44 assemblies.sort { p1, p2 -> p1.name.compareToIgnoreCase(p2.name) } 45 return assemblies 24 46 } 25 47 -
trunk/grails-app/services/CreateDataService.groovy
r751 r798 3 3 /** 4 4 * Provides a data service to create base and demo data. 5 * Beware that most, if not all, basedata is referenced by "Id" throughout the program.5 * Beware that most, if not all, BASE data is referenced by "Id" throughout the program. 6 6 * This allows changing the text of the 'name' property to something of the same meaning. 7 7 * But be sure to maintain the correct Id during creation, indicated by #1, #2 etc. 8 * Task.list()[0] is used to allow integration testing with DEMO data, where Id's may change due to create-delete. 8 9 */ 9 10 class CreateDataService { … … 846 847 //Task #1 847 848 p = [taskGroup:TaskGroup.findByName("Engineering Activites"), 848 taskPriority:TaskPriority.get( 2),849 taskPriority:TaskPriority.get(1), 849 850 taskType:TaskType.get(1), 850 851 leadPerson:Person.get(2), … … 1097 1098 //TaskProcedure 1098 1099 def taskProcedureInstance 1099 1100 taskProcedureInstance = new TaskProcedure(name: "Daily check") 1100 def taskInstance 1101 def person = Person.get(3) 1102 1103 taskInstance = Task.list()[6] 1104 taskProcedureInstance = new TaskProcedure(linkedTask: taskInstance, 1105 createdBy: person, 1106 lastUpdatedBy: person) 1101 1107 saveAndTest(taskProcedureInstance) 1102 taskProcedureInstance.addToTasks(Task.list()[0]) 1103 1104 taskProcedureInstance = new TaskProcedure(name: "100hr Service") 1108 taskProcedureInstance.addToTasks(taskInstance) 1109 1110 taskInstance = Task.list()[4] 1111 taskProcedureInstance = new TaskProcedure(linkedTask: taskInstance, 1112 createdBy: person, 1113 lastUpdatedBy: person) 1105 1114 saveAndTest(taskProcedureInstance) 1106 taskProcedureInstance.addToTasks( Task.list()[6])1115 taskProcedureInstance.addToTasks(taskInstance) 1107 1116 } 1108 1117 … … 1111 1120 //MaintenanceAction 1112 1121 def maintenanceActionInstance 1122 def taskProcedure = TaskProcedure.get(1) 1123 def assetSubItem = AssetSubItem.get(6) 1113 1124 1114 1125 //MaintenanceAction #1 1115 1126 maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", 1116 1127 procedureStepNumber: 10, 1117 maintenancePolicy: MaintenancePolicy.get(1),1118 taskProcedure: TaskProcedure.get(1))1119 saveAndTest(maintenanceActionInstance)1128 assetSubItem: assetSubItem, 1129 taskProcedure: taskProcedure) 1130 taskProcedure.addToMaintenanceActions(maintenanceActionInstance) 1120 1131 1121 1132 //MaintenanceAction #2 1122 1133 maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", 1123 1134 procedureStepNumber: 20, 1124 maintenancePolicy: MaintenancePolicy.get(1),1125 taskProcedure: TaskProcedure.get(1))1126 saveAndTest(maintenanceActionInstance)1135 assetSubItem: assetSubItem, 1136 taskProcedure: taskProcedure) 1137 taskProcedure.addToMaintenanceActions(maintenanceActionInstance) 1127 1138 1128 1139 //MaintenanceAction #3 1129 1140 maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", 1130 1141 procedureStepNumber: 30, 1131 maintenancePolicy: MaintenancePolicy.get(1), 1132 taskProcedure: TaskProcedure.get(1)) 1133 saveAndTest(maintenanceActionInstance) 1142 assetSubItem: assetSubItem, 1143 taskProcedure: taskProcedure) 1144 taskProcedure.addToMaintenanceActions(maintenanceActionInstance) 1145 1146 saveAndTest(taskProcedure) 1134 1147 } 1135 1148 … … 1475 1488 section: Section.get(1)) 1476 1489 saveAndTest(assetInstance1) 1477 // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1))1478 1490 1479 1491 //Asset #2
Note: See TracChangeset
for help on using the changeset viewer.