Changeset 253
- Timestamp:
- Mar 10, 2010, 2:40:58 PM (13 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 4 deleted
- 5 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/conf/BootStrap.groovy
r247 r253 152 152 enabled: true 153 153 ))*/ 154 154 155 155 156 156 def genderField = new TemplateField( … … 158 158 listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female')]) 159 159 .with { if (!validate()) { errors.each { println it} } else save()} 160 160 161 161 def ageField = new TemplateField( 162 162 name: 'Age',type: TemplateFieldType.INTEGER) … … 235 235 236 236 237 237 def fastingTreatment = new EventDescription( 238 238 name: 'Fasting treatment', 239 239 description: 'Fasting Protocol NuGO PPSH', … … 379 379 .with { if (!validate()) { errors.each { println it} } else save()} 380 380 381 381 // Add subjects and samples and compose EventGroups 382 382 383 383 def x=1 … … 450 450 rootGroup.save() 451 451 452 def y=1 453 11.times { 454 def currentSubject = new Subject( 455 name: "" + y++, 456 species: humanTerm, 457 template: humanTemplate) 458 .setFieldValue("Gender", (boolean)(x/2) ? "Male" : "Female") 459 .setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19"+(10+(int)(Math.random()*80)))) 460 .setFieldValue("Age", 30) 461 .setFieldValue("Height",Math.random()*2F) 462 .setFieldValue("Weight",Math.random()*150F) 463 .setFieldValue("BMI",20 + Math.random()*10F) 464 .with { if (!validate()) { errors.each { println it} } else save()} 465 466 def currentSample = new Sample( 467 name: currentSubject.name + '_B', 468 material: bloodTerm, 469 parentSubject: currentSubject, 470 parentEvent: bloodSamplingEvent); 471 472 rootGroup.addToSubjects currentSubject 473 rootGroup.save() 474 475 humanStudy.addToSubjects(currentSubject) 476 .addToSamples(currentSample) 477 .addToEventGroups rootGroup 478 .with { if (!validate()) { errors.each { println it} } else save()} 479 } 480 481 humanStudy.addToEventGroups(rootGroup).save() 482 483 // new Study(title:"example",code:"Excode",researchQuestion:"ExRquestion",description:"Exdescription",ecCode:"ExecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save() 484 // new Study(title:"testAgain",code:"testcode",researchQuestion:"testRquestion",description:"testdescription",ecCode:"testCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save() 485 // new Study(title:"Exampletest",code:"Examplecode",researchQuestion:"ExampleRquestion",description:"Exampledescription",ecCode:"ExampleecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save() 452 def y = 1 453 11.times { 454 def currentSubject = new Subject( 455 name: "" + y++, 456 species: humanTerm, 457 template: humanTemplate).setFieldValue("Gender", (boolean) (x / 2) ? "Male" : "Female").setFieldValue("DOB", new java.text.SimpleDateFormat("dd-mm-yy").parse("01-02-19" + (10 + (int) (Math.random() * 80)))).setFieldValue("Age", 30).setFieldValue("Height", Math.random() * 2F).setFieldValue("Weight", Math.random() * 150F).setFieldValue("BMI", 20 + Math.random() * 10F).with { if (!validate()) { errors.each { println it} } else save()} 458 459 rootGroup.addToSubjects currentSubject 460 rootGroup.save() 461 462 def currentSample = new Sample( 463 name: currentSubject.name + '_B', 464 material: bloodTerm, 465 parentSubject: currentSubject, 466 parentEvent: bloodSamplingEvent); 467 468 469 humanStudy.addToSubjects(currentSubject).addToSamples(currentSample).with { if (!validate()) { errors.each { println it} } else save()} 470 } 471 472 humanStudy.addToEventGroups rootGroup 473 humanStudy.save() 486 474 487 475 // Add clinical data -
trunk/grails-app/controllers/SandboxController.groovy
r247 r253 13 13 // Get the example study in a lazy way 14 14 def st = Study.get(1) 15 def f = st.template.subjectFields 16 17 //println st.giveAllFields() 15 def fieldsAll = st.giveSubjectTemplates().fields 16 def f = fieldsAll[0] 17 println fieldsAll.class 18 println f.class 19 f.each { 20 println "" + it + "-" + it.class 21 } 22 //println st.giveAllFields() 18 23 19 24 // This is a way to iterate over the fields in your controller … … 21 26 // Most of the time, you would just iterate over them in the view using <g:each> 22 27 // See also views/sandbox/index.gsp 23 f.each { field ->28 f.each { field -> 24 29 println field.name + "(" + field.type + ")" 25 30 } … … 42 47 43 48 // Specify which variables we want to be available in the controller (implicit return statement) 44 [fields: f, subjects: st.subjects ]49 [fields: f, subjects: st.subjects, studyInstance: st] 45 50 } 46 51 } -
trunk/grails-app/controllers/dbnp/data/OntologyController.groovy
r252 r253 1 import dbnp.data.Ontology 1 package dbnp.data 2 2 3 3 class OntologyController { -
trunk/grails-app/controllers/dbnp/studycapturing/ProtocolController.groovy
r247 r253 1 1 package dbnp.studycapturing 2 import dbnp.data.Term3 2 4 3 class ProtocolController { 5 6 static allowedMethods = [save: "POST", update: "POST", delete: "POST"] 7 8 9 def index = { 10 redirect(action: "list", params: params) 11 } 12 13 def list = { 14 params.max = Math.min(params.max ? params.int('max') : 10, 100) 15 [protocolInstanceList: Protocol.list(params), protocolInstanceTotal: Protocol.count()] 16 } 17 18 def create = { 19 def protocolInstance = new Protocol() 20 protocolInstance.properties = params 21 return [protocolInstance: protocolInstance] 22 } 23 24 def save = { 25 26 def protocolInstance = new Protocol(params) 27 28 if (protocolInstance.save(flush: true)) { 29 flash.message = "${message(code: 'default.created.message', args: [message(code: 'protocol.label', default: 'Protocol'), protocolInstance.id])}" 30 redirect(action:show, id: protocolInstance.id) 31 } 32 else { 33 render(view: "create", model: [protocolInstance: protocolInstance]) 34 } 35 } 36 37 def show = { 38 39 println params 40 41 def protocolInstance = Protocol.get(params.id) 42 if (!protocolInstance) { 43 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'protocol.label', default: 'Protocol'), params.id])}" 44 redirect(action: "list") 45 } 46 else { [protocolInstance: protocolInstance] } 47 } 48 49 def edit = { 50 def protocolInstance = Protocol.get(params.id) 51 if (!protocolInstance) { 52 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'protocol.label', default: 'Protocol'), params.id])}" 53 redirect(action: "list") 54 } 55 else { 56 return [protocolInstance: protocolInstance] 57 } 58 } 59 60 def update = { 61 def protocolInstance = Protocol.get(params.id) 62 if (protocolInstance) { 63 if (params.version) { 64 def version = params.version.toLong() 65 if (protocolInstance.version > version) { 66 67 protocolInstance.errors.rejectValue("version", "default.optimistic.locking.failure", [message(code: 'protocol.label', default: 'Protocol')] as Object[], "Another user has updated this Protocol while you were editing") 68 render(view: "edit", model: [protocolInstance: protocolInstance]) 69 return 70 } 71 } 72 protocolInstance.properties = params 73 if (!protocolInstance.hasErrors() && protocolInstance.save(flush: true)) { 74 flash.message = "${message(code: 'default.updated.message', args: [message(code: 'protocol.label', default: 'Protocol'), protocolInstance.id])}" 75 redirect(action: "show", id: protocolInstance.id) 76 } 77 else { 78 render(view: "edit", model: [protocolInstance: protocolInstance]) 79 } 80 } 81 else { 82 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'protocol.label', default: 'Protocol'), params.id])}" 83 redirect(action: "list") 84 } 85 } 86 87 def delete = { 88 def protocolInstance = Protocol.get(params.id) 89 if (protocolInstance) { 90 try { 91 protocolInstance.delete(flush: true) 92 flash.message = "${message(code: 'default.deleted.message', args: [message(code: 'protocol.label', default: 'Protocol'), params.id])}" 93 redirect(action: "list") 94 } 95 catch (org.springframework.dao.DataIntegrityViolationException e) { 96 flash.message = "${message(code: 'default.not.deleted.message', args: [message(code: 'protocol.label', default: 'Protocol'), params.id])}" 97 redirect(action: "show", id: params.id) 98 } 99 } 100 else { 101 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'protocol.label', default: 'Protocol'), params.id])}" 102 redirect(action: "list") 103 } 104 } 105 106 def createDummies = 107 { 108 def newInstance = new Protocol() 109 newInstance.name = "Hugo (dummy #1)" 110 newInstance.reference = Term.find("from Term t") 111 112 if( newInstance.save() ) 113 { redirect( action:show, id: newInstance.id ) } 114 else { chain( action:list ) } 115 } 116 4 def scaffold = Protocol 117 5 } -
trunk/grails-app/controllers/dbnp/studycapturing/ProtocolParameterController.groovy
r252 r253 1 package dbnp.studycapturing 1 2 class ProtocolParameterController { 2 3 -
trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy
r252 r253 1 /** 2 * Home Controler 3 * 4 * My Description 5 * 6 * @author Kees van Bochove 7 * @since 20091028 8 * @package studycapturing 9 * 10 * Revision information: 11 * $Rev$ 12 * $Author$ 13 * $Date$ 14 */ 15 class StudyController extends BaseController { 16 def scaffold = dbnp.studycapturing.Study 1 package dbnp.studycapturing 17 2 18 def list_extended = { 19 3 class StudyController { 4 5 //static allowedMethods = [save: "POST", update: "POST", delete: "POST"] 6 7 def index = { 8 redirect(action: "list", params: params) 20 9 } 21 10 22 def see = { 23 render params 11 def list = { 12 params.max = Math.min(params.max ? params.int('max') : 10, 100) 13 [studyInstanceList: Study.list(params), studyInstanceTotal: Study.count()] 24 14 } 15 16 /*def create = { 17 def studyInstance = new Study() 18 studyInstance.properties = params 19 return [studyInstance: studyInstance] 20 } 21 22 def save = { 23 def studyInstance = new Study(params) 24 if (studyInstance.save(flush: true)) { 25 flash.message = "${message(code: 'default.created.message', args: [message(code: 'study.label', default: 'Study'), studyInstance.id])}" 26 redirect(action: "show", id: studyInstance.id) 27 } 28 else { 29 render(view: "create", model: [studyInstance: studyInstance]) 30 } 31 }*/ 32 33 def show = { 34 def studyInstance = Study.get(params.id) 35 if (!studyInstance) { 36 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}" 37 redirect(action: "list") 38 } 39 else { 40 [studyInstance: studyInstance] 41 } 42 } 43 44 /*def edit = { 45 def studyInstance = Study.get(params.id) 46 if (!studyInstance) { 47 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}" 48 redirect(action: "list") 49 } 50 else { 51 return [studyInstance: studyInstance] 52 } 53 } 54 55 def update = { 56 def studyInstance = Study.get(params.id) 57 if (studyInstance) { 58 if (params.version) { 59 def version = params.version.toLong() 60 if (studyInstance.version > version) { 61 62 studyInstance.errors.rejectValue("version", "default.optimistic.locking.failure", [message(code: 'study.label', default: 'Study')] as Object[], "Another user has updated this Study while you were editing") 63 render(view: "edit", model: [studyInstance: studyInstance]) 64 return 65 } 66 } 67 studyInstance.properties = params 68 if (!studyInstance.hasErrors() && studyInstance.save(flush: true)) { 69 flash.message = "${message(code: 'default.updated.message', args: [message(code: 'study.label', default: 'Study'), studyInstance.id])}" 70 redirect(action: "show", id: studyInstance.id) 71 } 72 else { 73 render(view: "edit", model: [studyInstance: studyInstance]) 74 } 75 } 76 else { 77 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}" 78 redirect(action: "list") 79 } 80 } 81 82 def delete = { 83 def studyInstance = Study.get(params.id) 84 if (studyInstance) { 85 try { 86 studyInstance.delete(flush: true) 87 flash.message = "${message(code: 'default.deleted.message', args: [message(code: 'study.label', default: 'Study'), params.id])}" 88 redirect(action: "list") 89 } 90 catch (org.springframework.dao.DataIntegrityViolationException e) { 91 flash.message = "${message(code: 'default.not.deleted.message', args: [message(code: 'study.label', default: 'Study'), params.id])}" 92 redirect(action: "show", id: params.id) 93 } 94 } 95 else { 96 flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'study.label', default: 'Study'), params.id])}" 97 redirect(action: "list") 98 } 99 }*/ 25 100 } -
trunk/grails-app/controllers/dbnp/studycapturing/TemplateController.groovy
r247 r253 2 2 3 3 class TemplateController { 4 //def index = { } 5 def scaffold = true 4 def scaffold = Template 6 5 } -
trunk/grails-app/views/sandbox/index.gsp
r247 r253 30 30 </tr> 31 31 </table> 32 <%@ 33 def a = new Column(value:"value", name:"naam") 34 println a.name 35 %> 32 <h2>Events</h2> 33 <% println studyInstance.events.eventDescription.protocol.name %> 36 34 </body> 37 35 </html>
Note: See TracChangeset
for help on using the changeset viewer.