- Timestamp:
- Jun 4, 2010, 11:42:05 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r520 r526 82 82 success() 83 83 } 84 on("next").to "study" 84 on("next") { 85 // clean the flow scope 86 flow.remove('study') 87 flow.remove('subjects') 88 flow.remove('subjectTemplates') 89 flow.remove('event') 90 flow.remove('events') 91 flow.remove('eventGroups') 92 flow.remove('eventTemplates') 93 }.to "study" 85 94 on("modify").to "modify" 86 95 } … … 100 109 }.to "start" 101 110 on("next") { 102 // TODO: loading a study is not yet implemented 103 // create a error stating this feature is 104 // not yet implemented 105 flash.errors = [:] 106 this.appendErrorMap( 107 ['study': 'Loading a study and modifying it has not yet been implemented. Please press \'cancel\' to go back to the initial page...'], 108 flash.errors 109 ) 110 111 error() 112 }.to "modify" 111 // load study 112 try { 113 flow.study = Study.findByTitle(params.study) 114 115 // recreate subjects 116 flow.subjects = [:] 117 flow.subjectTemplates = [:] 118 flow.study.subjects.each() { subject -> 119 def subjectIncrement = flow.subjects.size() 120 flow.subjects[ subjectIncrement ] = subject 121 122 // add subject template? 123 if (!flow.subjectTemplates[ subject.template.name ]) { 124 flow.subjectTemplates[ subject.template.name ] = [ 125 name: subject.template.name, 126 template: subject.template, 127 subjects: [:] 128 ] 129 } 130 131 // reference subject in template 132 flow.subjectTemplates[ subject.template.name ].subjects[ flow.subjectTemplates[ subject.template.name ].subjects.size() ] = subjectIncrement 133 } 134 135 // recreate events 136 flow.events = [] 137 flow.eventGroups = [] 138 flow.eventTemplates = [:] 139 flow.study.events.each() { event -> 140 def eventIncrement = flow.events.size() 141 flow.events[ eventIncrement ] = event 142 143 // add event template? 144 if (!flow.eventTemplates[ event.template.name ]) { 145 flow.eventTemplates[ event.template.name ] = [ 146 name: event.template.name, 147 template: event.template, 148 events: new ArrayList() 149 ] 150 } 151 152 // reference event in template 153 flow.eventTemplates[ event.template.name ].events[ flow.eventTemplates[ event.template.name ].events.size() ] = eventIncrement 154 155 // set dummy event 156 flow.event = event 157 } 158 159 // recreate sample events 160 flow.study.samplingEvents.each() { event -> 161 def eventIncrement = flow.events.size() 162 flow.events[ eventIncrement ] = event 163 164 // add event template? 165 if (!flow.eventTemplates[ event.template.name ]) { 166 flow.eventTemplates[ event.template.name ] = [ 167 name: event.template.name, 168 template: event.template, 169 events: new ArrayList() 170 ] 171 } 172 173 // reference event in template 174 flow.eventTemplates[ event.template.name ].events[ flow.eventTemplates[ event.template.name ].events.size() ] = eventIncrement 175 176 // set dummy event 177 flow.event = event 178 } 179 180 // recreate eventGroups 181 flow.study.eventGroups.each() { eventGroup -> 182 flow.eventGroups[ flow.eventGroups.size() ] = eventGroup 183 } 184 185 success() 186 } catch (Exception e) { 187 error() 188 } 189 }.to "study" 113 190 } 114 191 … … 176 253 flow.subjectTemplates = [:] 177 254 } 255 178 256 success() 179 257 } … … 670 748 */ 671 749 def handleSubjects(flow, flash, params) { 672 def names = [:]; 673 def errors = false; 674 def id = 0; 675 750 def names = [:] 751 def errors = false 752 def id = 0 753 754 println flow.subjects 676 755 // iterate through subject templates 677 756 flow.subjectTemplates.each() { subjectTemplate -> 678 757 // iterate through subjects 679 subjectTemplate. getValue().subjects.each() { subjectIncrement, subjectId ->758 subjectTemplate.value.subjects.each() { subjectIncrement, subjectId -> 680 759 // iterate through fields (= template fields and domain properties) 681 760 flow.subjects[ subjectId ].giveFields().each() { subjectField ->
Note: See TracChangeset
for help on using the changeset viewer.