Changeset 192
- Timestamp:
- Feb 11, 2010, 5:47:49 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r191 r192 239 239 } 240 240 241 println 'Adding PPSH study ... --> DISABLED due to bootstrapping errors'242 /* 241 println 'Adding PPSH study' 242 243 243 def humanStudy = new Study( 244 244 title:"NuGO PPS human study", … … 355 355 humanStudy.addToAssays(lipidAssayRef); 356 356 humanStudy.save() 357 */358 357 } 359 358 } -
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r189 r192 127 127 flash.errors = new LinkedHashMap() 128 128 129 // handle form data 130 if (!this.handleSubjects(flow, flash, params)) { 129 // check if we have at least one subject 130 // and check form data 131 if (flow.subjects.size() < 1) { 132 // append error map 133 this.appendErrorMap(['subjects': 'You need at least to create one subject for your study'], flash.errors) 134 error() 135 } else if (!this.handleSubjects(flow, flash, params)) { 131 136 error() 132 137 } else { … … 182 187 /** 183 188 * re-usable code for handling subject form data in a web flow 184 * @param Map 185 * @param Map 186 * @param Map 189 * @param Map LocalAttributeMap (the flow scope) 190 * @param Map localAttributeMap (the flash scope) 191 * @param Map GrailsParameterMap (the flow parameters = form data) 187 192 * @returns boolean 188 193 */ 189 194 def handleSubjects(flow, flash, params) { 190 if (flow.subjects.size() < 1) { 191 return false 192 } else { 193 def names = new LinkedHashMap(); 194 def errors = false; 195 def id = 0; 196 197 // iterate through subjects 198 flow.subjects.each() { 199 // store subject properties 200 def name = params.get('subject_' + id + '_name') 201 it.name = params.get('subject_' + id + '_name') 202 it.species = Term.findByName(params.get('subject_' + id + '_species')) 203 204 // remember name and check for duplicates 205 if (!names[ it.name ]) { 206 names[ it.name ] = [count: 1, first: 'subject_' + id + '_name'] 207 } else { 208 // duplicate name found, set error flag 209 names[ it.name ]['count']++ 210 211 // second occurence? 212 if (names[ it.name ]['count'] == 2) { 213 // yeah, also mention the first 214 // occurrence in the error message 215 this.appendErrorMap([[names[ it.name ]['first']]: 'The subject name needs to be unique!'], flash.errors) 195 def names = new LinkedHashMap(); 196 def errors = false; 197 def id = 0; 198 199 // iterate through subjects 200 flow.subjects.each() { 201 // store subject properties 202 def name = params.get('subject_' + id + '_name') 203 it.name = params.get('subject_' + id + '_name') 204 it.species = Term.findByName(params.get('subject_' + id + '_species')) 205 206 // remember name and check for duplicates 207 if (!names[it.name]) { 208 names[it.name] = [count: 1, first: 'subject_' + id + '_name'] 209 } else { 210 // duplicate name found, set error flag 211 names[it.name]['count']++ 212 213 // second occurence? 214 if (names[it.name]['count'] == 2) { 215 // yeah, also mention the first 216 // occurrence in the error message 217 this.appendErrorMap([[names[it.name]['first']]: 'The subject name needs to be unique!'], flash.errors) 218 } 219 220 // add to error map 221 this.appendErrorMap([['subject_' + id + '_name']: 'The subject name needs to be unique!'], flash.errors) 222 errors = true 223 } 224 225 // clear lists 226 def stringList = new LinkedHashMap(); 227 def intList = new LinkedHashMap(); 228 def floatList = new LinkedHashMap(); 229 def termList = new LinkedHashMap(); 230 231 // get all template fields 232 flow.study.template.subjectFields.each() { 233 // valid type? 234 if (!it.type) throw new NoSuchFieldException("Field name ${fieldName} not recognized") 235 236 // get value 237 def value = params.get('subject_' + id + '_' + it.name); 238 if (value) { 239 // add to template parameters 240 switch (it.type) { 241 case 'STRINGLIST': 242 stringList[it.name] = value 243 break; 244 case 'INTEGER': 245 intList[it.name] = value 246 break; 247 case 'FLOAT': 248 floatList[it.name] = value 249 break; 250 default: 251 // unsupported type? 252 throw new NoSuchFieldException("Field type ${it.type} not recognized") 253 break; 216 254 } 217 218 // add to error map 219 this.appendErrorMap([['subject_' + id + '_name']: 'The subject name needs to be unique!'], flash.errors) 220 errors = true 221 } 222 223 // clear lists 224 def stringList = new LinkedHashMap(); 225 def intList = new LinkedHashMap(); 226 def floatList = new LinkedHashMap(); 227 def termList = new LinkedHashMap(); 228 229 // get all template fields 230 flow.study.template.subjectFields.each() { 231 // valid type? 232 if (!it.type) throw new NoSuchFieldException("Field name ${fieldName} not recognized") 233 234 // get value 235 def value = params.get('subject_' + id + '_' + it.name); 236 if (value) { 237 // add to template parameters 238 switch (it.type) { 239 case 'STRINGLIST': 240 stringList[it.name] = value 241 break; 242 case 'INTEGER': 243 intList[it.name] = value 244 break; 245 case 'FLOAT': 246 floatList[it.name] = value 247 break; 248 default: 249 // unsupported type? 250 throw new NoSuchFieldException("Field type ${it.type} not recognized") 251 break; 252 } 253 } 254 } 255 256 // set field data 257 it.templateStringFields = stringList 258 it.templateIntegerFields = intList 259 it.templateFloatFields = floatList 260 it.templateTermFields = termList 261 262 // validate subject 263 if (!it.validate()) { 264 errors = true 265 println id + ' :: ' + it.errors.getAllErrors() 266 this.appendErrors(it, flash.errors) 267 } 268 269 id++; 270 } 271 272 return !errors 273 } 255 } 256 } 257 258 // set field data 259 it.templateStringFields = stringList 260 it.templateIntegerFields = intList 261 it.templateFloatFields = floatList 262 it.templateTermFields = termList 263 264 // validate subject 265 if (!it.validate()) { 266 errors = true 267 println id + ' :: ' + it.errors.getAllErrors() 268 this.appendErrors(it, flash.errors) 269 } 270 271 id++; 272 } 273 274 return !errors 274 275 } 275 276 -
trunk/grails-app/domain/dbnp/studycapturing/AssayType.groovy
r190 r192 3 3 /** 4 4 * Enum describing the different assay types (aka omics submodules). 5 * 6 * Revision information: 7 * $Rev$ 8 * $Author$ 9 * $Date$ 5 10 */ 6 11 public enum AssayType { 7 8 9 12 TRANSCRIPTOMICS('Transcriptomics'), 13 METABOLOMICS('Metabolomics'), 14 CLINICAL_DATA('Clinical data') 10 15 11 16 String name 12 17 13 14 15 18 AssayType(String name) { 19 this.name = name 20 } 16 21 17 18 19 22 static list() { 23 [TRANSCRIPTOMICS, METABOLOMICS, CLINICAL_DATA] 24 } 20 25 21 /*def String toString() { 22 return this.name 23 }*/ 24 26 /* 27 def String toString() { 28 return this.name 29 } 30 */ 25 31 } -
trunk/web-app/css/wizard.css
r178 r192 217 217 } 218 218 219 .wizard .grouping .subjects {220 display: block;221 float: left;222 }223 219 .wizard .grouping .ui-selected { 224 220 background-color: red; … … 228 224 } 229 225 226 .wizard .grouping .subjects { 227 display: block; 228 float: left; 229 } 230 .wizard .grouping .subjects .subject { 231 margin: 1px; 232 padding: 0.2em; 233 font-size: .8em; 234 height: 14px; 235 } 230 236 .wizard .grouping .right { 231 237 display: inline-block; … … 252 258 .wizard .grouping .group .subjects { 253 259 display: inline-block; 260 height: auto; 254 261 } 255 262 .wizard .grouping .group .subject { 256 display: block;263 display: inline-block; 257 264 width: 100%; 258 265 font-size: 10px; -
trunk/web-app/js/grouping.js
r189 r192 29 29 30 30 this.initItems(); 31 this.initGroupItems(); 32 this.initGroups(); 33 //this.initGroups(); 34 35 console.log('bla') 31 36 }, 32 37 33 38 initItems: function() { 39 var that = this; 40 34 41 //$(this.itemsIdentifier). 42 $(this.itemsIdentifier).first().selectable({ 43 filter: that.itemIdentifier, 44 stop: function() { 45 // done selecting, make all selected items draggable 46 //that.makeDraggable(this); 47 } 48 }); 49 }, 50 51 initGroups: function() { 52 this.initGroupItems(); 53 }, 54 55 initGroupItems: function() { 56 var that = this; 57 58 $(this.groupsIdentifier).selectable({ 59 filter: that.itemIdentifier 60 }) 35 61 } 36 62 } … … 156 182 } 157 183 */ 184 185 // for debugging purposes this is here 186 // TODO: to be be migrated to wizard.js.... 187 $(document).ready(function() { 188 new Grouping().init('div.subjects', 'div.subject', 'div.groups', 'div.group'); 189 }); -
trunk/web-app/js/wizard.js
r189 r192 43 43 44 44 // GROUPING PAGE 45 new Grouping().init('div.subjects', 'div.subject', 'div.groups', 'div.group');45 //new Grouping().init('div.subjects', 'div.subject', 'div.groups', 'div.group'); 46 46 } 47 47
Note: See TracChangeset
for help on using the changeset viewer.