Changeset 290
- Timestamp:
- Mar 22, 2010, 11:38:25 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/application.properties
r285 r290 1 1 #Grails Metadata file 2 # Thu Mar 18 16:30:01CET 20102 #Fri Mar 19 11:53:03 CET 2010 3 3 app.grails.version=1.2.1 4 4 app.name=gscf … … 10 10 plugins.mail=0.9 11 11 plugins.nimble=0.3-SNAPSHOT 12 plugins.searchable=0.5.5 12 13 plugins.shiro=1.0.1 13 14 plugins.tomcat=1.2.1 -
trunk/grails-app/conf/BootStrap.groovy
r269 r290 198 198 name: '#Mice in cage',type: TemplateFieldType.INTEGER)) 199 199 .addToFields(new TemplateField( 200 name: 'Litter size',type: TemplateFieldType.INTEGER)) 200 name: 'Litter size',type: TemplateFieldType.INTEGER)) 201 201 .addToFields(new TemplateField( 202 202 name: 'Weight (g)', type: TemplateFieldType.DOUBLE, unit: 'gram')) … … 515 515 } 516 516 517 humanStudy.addToEventGroups rootGroup 517 humanStudy.addToEvents(fastingEvent) 518 humanStudy.addToSamplingEvents(bloodSamplingEvent) 519 humanStudy.addToEventGroups rootGroup 518 520 humanStudy.save() 519 521 -
trunk/grails-app/controllers/dbnp/studycapturing/EventDescriptionController.groovy
r289 r290 116 116 description.name=params['name'] 117 117 118 // description.description=params['description'] // has to be a Term118 description.description=params['description'] 119 119 // description.classification=params['classification'] // has to be a Term 120 120 description.isSamplingEvent= params['isSample']=='true'?true:false … … 244 244 245 245 246 // make changes persitant 247 248 if (description.save(flush: true)) { 249 flash.message = "${message(code: 'default.created.message', args: [message(code: 'description.label', default: 'EventDescription'), description.id])}" 250 redirect(action: "show", id: description.id) 251 } 252 else { 253 render(view: "create", model: [description: description]) 254 } 255 256 render( action: 'list' ) 246 // Check for errors in protocol, and if none, persist it 247 protocol.validate() 248 if (protocol.hasErrors()) { 249 render "Errors during save of protool:\n" 250 for (e in description.errors) { 251 render e 252 } 253 } 254 else { 255 protocol.save(flush:true) 256 } 257 258 259 // Important: add protocol to EventDescription 260 description.protocol = protocol 261 262 263 // Check for errors in EventDescription, if no errors, persist the data 264 description.validate() 265 if (description.hasErrors()) { 266 render "Errors during save of event description:\n" 267 for (e in description.errors) { 268 render e 269 } 270 } 271 else { 272 if (description.save(flush: true)) { 273 flash.message = "${message(code: 'default.created.message', args: [message(code: 'description.label', default: 'EventDescription'), description.id])}" 274 redirect(view: "show", id: description.id) 275 276 } 277 else { 278 redirect(view: "create", model: [description: description]) 279 } 280 } 281 257 282 } 258 283 … … 264 289 if (!eventDescriptionInstance) { 265 290 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'eventDescription.label', default: 'EventDescription'), params.id])}" 266 redirect( action: "list")291 redirect(view: "list") 267 292 } 268 293 269 294 else { 270 295 [eventDescriptionInstance: eventDescriptionInstance, params:params] 296 // Since show.gsp is not implemented yet, redirect to edit 297 redirect(action:'edit',id:params.id) 271 298 } 272 299 } -
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r257 r290 70 70 71 71 /** 72 * Find a template field by its name and return its value for this subject73 * @param fieldName The name of the template subjectfield72 * Find a template field by its name and return its value for this entity 73 * @param fieldName The name of the template field 74 74 * @return the value of the field (class depends on the field type) 75 75 * @throws NoSuchFieldException If the field is not found or the field type is not supported … … 81 81 } 82 82 83 /** 84 * Set a template/entity field value 85 * @param fieldName The name of the template or entity field 86 * @param value The value to be set, this should align with the (template) field type, but there are some convenience setters 87 * 88 */ 83 89 def setFieldValue(String fieldName, value) { 90 91 // First, search if there is an entity property with the given name, and if so, set that 84 92 if (this.properties.containsKey(fieldName)) { 85 93 this[fieldName] = value 86 94 } 87 else88 if (template == null) {89 throw new NoSuchFieldException("Field ${fieldName} not found in class properties ")95 // If not the found, then it is a template field, so check if there is a template 96 else if (template == null) { 97 throw new NoSuchFieldException("Field ${fieldName} not found in class properties: template not set") 90 98 } 99 // If there is a template, check the template fields 91 100 else { 101 // Find the target template field, if not found, throw an error 92 102 TemplateField field = this.template.fields.find { it.name == fieldName} 93 103 if (field == null) { 94 104 throw new NoSuchFieldException("Field ${fieldName} not found in class properties or template fields") 95 105 } 106 // Set the value of the found template field 96 107 else { 108 // Convenience setter for template string list fields: find TemplateFieldListItem by name 97 109 if (field.type == TemplateFieldType.STRINGLIST && value.class == String) { 98 // Convenience setter: find template item by name99 110 value = field.listEntries.find { it.name == value } 100 111 } 101 112 102 // handle string values for date fields113 // Convenience setter for dates: handle string values for date fields 103 114 if (field.type == TemplateFieldType.DATE && value.class == String) { 104 115 // a string was given, attempt to transform it into a date instance … … 119 130 } 120 131 121 // Caution: this assumes that all template...Field Maps are already initialized 122 // Otherwise, the results are pretty much unpredictable! 132 // Set the field value 133 // Caution: this assumes that all template...Field Maps are already initialized (as is done now above as [:]) 134 // If that is ever changed, the results are pretty much unpredictable (random Java object pointers?)! 123 135 getStore(field.type)[fieldName] = value 124 136 return this -
trunk/grails-app/domain/dbnp/studycapturing/TemplateField.groovy
r247 r290 13 13 TemplateFieldType type 14 14 String unit 15 String comment // help string for the user interface 15 16 16 17 static hasMany = [listEntries : TemplateFieldListItem] // to store the entries to choose from when the type is 'item from predefined list' … … 19 20 name(unique: true) 20 21 unit(nullable: true, blank: true) 22 comment(nullable:true, blank: true) 23 } 24 25 static mapping = { 26 comment type: 'text' 21 27 } 22 28 -
trunk/grails-app/views/common/_topnav.gsp
r247 r290 3 3 <ul class="topnav"> 4 4 <li><g:link url="/${meta(name: 'app.name')}/">Home</g:link></li> 5 <li> 5 <n:isLoggedIn> 6 <li><g:link controller="study" action="list">My studies</g:link></li> 7 </n:isLoggedIn> <li> 6 8 <a href="#">Studies</a> 7 9 <ul class="subnav"> … … 10 12 </ul> 11 13 </li> 12 <li><g:link controller="load" action="index">Loading data</g:link></li> 14 <li> 15 <a href="#">Events</a> 16 <ul class="subnav"> 17 <li><g:link controller="protocol" action="list">View protocols</g:link></li> 18 <li><g:link controller="eventDescription" action="list">View event descriptions</g:link></li> 19 </ul> 20 </li> 21 <li><g:link controller="importer" action="index">Import data</g:link></li> 22 <g:if env="development"> 13 23 <li><g:link controller="query" action="index">Query database</g:link></li> 14 <n:isLoggedIn> 15 <li><g:link controller="study" action="list">My studies</g:link></li> 16 </n:isLoggedIn> 17 <li> 24 <li> 18 25 <a href="#">Scaffolded controllers</a> 19 26 <ul class="subnav"><g:each var="c" in="${grailsApplication.controllerClasses}"> … … 21 28 </ul> 22 29 </li> 30 </g:if> 23 31 <n:isAdministrator> 24 32 <li> -
trunk/grails-app/views/eventDescription/showMyProtocolFilled.gsp
r289 r290 255 255 256 256 <% def protocols = dbnp.studycapturing.Protocol.list() %> 257 <td>Name</td> 258 </tr> 259 <tr class="prop"> 257 260 <td> 258 261 <g:if test="${protocol==null}">
Note: See TracChangeset
for help on using the changeset viewer.