Changeset 951
- Timestamp:
- Oct 20, 2010, 4:48:12 PM (12 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/WizardController.groovy
r863 r951 504 504 onRender { 505 505 flow.page = 5 506 507 // got samples?508 if (!flow.study.samples) {509 // generate samples510 // iterate through eventGroups511 flow.study.eventGroups.each() { eventGroup ->512 // iterate through samplingEvents513 eventGroup.samplingEvents.each() { samplingEvent ->514 println samplingEvent515 println samplingEvent.sampleTemplate516 println samplingEvent.sampleTemplate.getClass()517 518 def samplingEventName = this.ucwords(samplingEvent.template.name)519 520 // iterate through subjects521 eventGroup.subjects.each() { subject ->522 def sampleName = (this.ucwords(subject.name) + '_' + samplingEventName + '_' + new RelTime(samplingEvent.startTime).toString()).replaceAll("([ ]{1,})", "")523 def tempSampleIterator = 0524 def tempSampleName = sampleName525 526 // make sure sampleName is unique527 if (flow.study.samples) {528 while (flow.study.samples.find { it.name == tempSampleName }) {529 tempSampleIterator++530 tempSampleName = sampleName + "_" + tempSampleIterator531 }532 sampleName = tempSampleName533 }534 535 // instantiate a sample536 flow.study.addToSamples(537 new Sample(538 parentSubject: subject,539 parentEvent: samplingEvent,540 name: sampleName,541 template: (samplingEvent.sampleTemplate) ? samplingEvent.sampleTemplate : ''542 )543 )544 }545 }546 547 }548 }549 550 506 success() 551 507 } … … 1193 1149 // add to eventGroup 1194 1150 if (event instanceof SamplingEvent) { 1195 eventGroup.addToSamplingEvents(event) 1151 // check if we are already in this eventGroup 1152 if (!eventGroup.samplingEvents.find { it.equals(event) }) { 1153 // no, add it 1154 eventGroup.addToSamplingEvents(event) 1155 1156 // iterate through subjects for this eventGroup 1157 eventGroup.subjects.each() { subject -> 1158 // instantiate a sample for this subject / event 1159 def samplingEventName = this.ucwords(event.template.name) 1160 def sampleName = (this.ucwords(subject.name) + '_' + samplingEventName + '_' + new RelTime(event.startTime).toString()).replaceAll("([ ]{1,})", "") 1161 def tempSampleIterator = 0 1162 def tempSampleName = sampleName 1163 1164 // make sure sampleName is unique 1165 if (flow.study.samples) { 1166 while (flow.study.samples.find { it.name == tempSampleName }) { 1167 tempSampleIterator++ 1168 tempSampleName = sampleName + "_" + tempSampleIterator 1169 } 1170 sampleName = tempSampleName 1171 } 1172 1173 // instantiate a sample 1174 flow.study.addToSamples( 1175 new Sample( 1176 parentSubject: subject, 1177 parentEvent: event, 1178 name: sampleName, 1179 template: (event.sampleTemplate) ? event.sampleTemplate : '' 1180 ) 1181 ) 1182 } 1183 } 1196 1184 } else { 1197 1185 eventGroup.addToEvents(event) … … 1200 1188 // remove from eventGroup 1201 1189 if (event instanceof SamplingEvent) { 1190 // iterate through subjects (if we have them) 1191 eventGroup.subjects.each() { subject -> 1192 // find all samples for this subject / event 1193 flow.study.samples.findAll { (it.parentEvent.equals(event) && it.parentSubject.equals(subject) ) }.each() { 1194 // delete this sample 1195 flow.study.removeFromSamples( it ) 1196 it.delete() 1197 } 1198 } 1199 1202 1200 eventGroup.removeFromSamplingEvents(event) 1203 1201 } else { … … 1247 1245 flow.study.subjects.each() { subject -> 1248 1246 if (params.get('subject_' + subject.getIdentifier() + '_group_' + eventGroup.getIdentifier() )) { 1249 // add to eventGroup 1250 eventGroup.addToSubjects(subject) 1247 // check if this subject is already part of this eventGroup 1248 if ( !eventGroup.subjects.find { it.equals(subject) } ) { 1249 // add to eventGroup 1250 eventGroup.addToSubjects(subject) 1251 1252 // iterate through samplingEvents 1253 eventGroup.samplingEvents.each() { samplingEvent -> 1254 def samplingEventName = this.ucwords(samplingEvent.template.name) 1255 def sampleName = (this.ucwords(subject.name) + '_' + samplingEventName + '_' + new RelTime(samplingEvent.startTime).toString()).replaceAll("([ ]{1,})", "") 1256 def tempSampleIterator = 0 1257 def tempSampleName = sampleName 1258 1259 // make sure sampleName is unique 1260 if (flow.study.samples) { 1261 while (flow.study.samples.find { it.name == tempSampleName }) { 1262 tempSampleIterator++ 1263 tempSampleName = sampleName + "_" + tempSampleIterator 1264 } 1265 sampleName = tempSampleName 1266 } 1267 1268 // instantiate a sample 1269 flow.study.addToSamples( 1270 new Sample( 1271 parentSubject: subject, 1272 parentEvent: samplingEvent, 1273 name: sampleName, 1274 template: (samplingEvent.sampleTemplate) ? samplingEvent.sampleTemplate : '' 1275 ) 1276 ) 1277 } 1278 } 1251 1279 } else { 1252 1280 // remove from eventGroup 1253 1281 eventGroup.removeFromSubjects(subject) 1282 1283 // iterate through samplingEvents 1284 eventGroup.samplingEvents.each() { samplingEvent -> 1285 flow.study.samples.findAll { ( it.parentEvent.equals(samplingEvent) && it.parentSubject.equals(subject) ) }.each() { 1286 // delete this sample 1287 flow.study.removeFromSamples( it ) 1288 it.delete() 1289 } 1290 } 1254 1291 } 1255 1292 } -
trunk/grails-app/views/wizard/pages/_samples_previous_warning.gsp
r635 r951 46 46 <span class="info"> 47 47 <span class="warning">Warning!</span> 48 Renaming, adding and removing subjects, sample events and / or grouping <i>may</i> result in (some of the) samples to be reset!<br />48 Renaming, adding and removing subjects, sample events and / or grouping <i>may</i> result in loss of samples!<br /> 49 49 Continuing to the groups page in <span id="seconds"></span> seconds... 50 50 </span>
Note: See TracChangeset
for help on using the changeset viewer.