Changeset 20 for trunk/grails-app/domain/nl
- Timestamp:
- Mar 22, 2011, 1:52:56 PM (12 years ago)
- Location:
- trunk/grails-app/domain/nl/tno/metagenomics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/nl/tno/metagenomics/AssaySample.groovy
r12 r20 216 216 otherAssaySample.oligoNumber = oligoNumber; 217 217 otherAssaySample.tagName = tagName; 218 otherAssaySample.run = run;219 218 220 219 // Move attached data 221 def dataList = sequenceData?.toList()220 def dataList = [] + sequenceData?.toList() 222 221 def otherAssay = otherAssaySample.assay; 223 222 224 223 if( dataList && dataList.size() > 0 ) { 225 224 for( def j = dataList.size() - 1; j >= 0; j-- ) { 226 // Copy data 227 dataList[j].sample = otherAssaySample; 228 this.removeFromSequenceData( dataList[j] ); 229 otherAssaySample.addToSequenceData( dataList[j] ); 230 dataList[j].save(); 225 // Copy data to a new sequencedata object. 226 // Just moving the sequencedata object to the other assay sample resulted 227 // in a 'deleted object would be re-saved by cascade' exception 228 229 // Clone the sequencedata object 230 def sd = dataList[ j ]?.clone(); 231 232 if( sd ) 233 otherAssaySample.addToSequenceData( sd ); 234 235 // Remove the old sequencedata object 236 this.removeFromSequenceData( dataList[ j ] ); 231 237 } 232 238 } 239 240 // Copy run properties 241 if( otherAssaySample.run ) { 242 otherAssaySample.run.removeFromAssaySamples( otherAssaySample ); 243 } 244 245 // Remove this sample from the run. 246 if( run ) { 247 def copyRun = run; 248 copyRun.removeFromAssaySamples( this ); 249 copyRun.addToAssaySamples( otherAssaySample ); 250 } else { 251 otherAssaySample.run = null; 252 } 233 253 } 234 254 } -
trunk/grails-app/domain/nl/tno/metagenomics/SequenceData.groovy
r12 r20 57 57 58 58 // Reset statistics of the assay sample, to ensure the deleted files are removed from statistics 59 sample.resetStats(); 59 sample?.resetStats(); 60 } 61 62 public SequenceData clone() { 63 // Copy the files to a new name 64 def permanentDir = fileService.absolutePath( ConfigurationHolder.config.metagenomics.fileDir.toString() ) 65 66 def newSequenceFileName = sequenceFile; 67 if( this.sequenceFile ) { 68 newSequenceFileName = fileService.getUniqueFilename( this.sequenceFile, permanentDir ); 69 fileService.copy( sequenceFile, newSequenceFileName, permanentDir ); 70 } 71 72 def newQualityFileName = qualityFile; 73 if( this.qualityFile ) { 74 newQualityFileName = fileService.getUniqueFilename( this.qualityFile, permanentDir ); 75 fileService.copy( qualityFile, newQualityFileName, permanentDir ); 76 } 77 78 def sd = new SequenceData( 79 sequenceFile: newSequenceFileName, 80 qualityFile: newQualityFileName, 81 numSequences: this.numSequences, 82 averageQuality: this.averageQuality 83 ); 84 85 if( this.sample ) 86 this.sample.addToSequenceData( sd ); 87 88 return sd; 60 89 } 61 90 }
Note: See TracChangeset
for help on using the changeset viewer.