Changeset 965


Ignore:
Timestamp:
Oct 21, 2010, 3:38:30 PM (6 years ago)
Author:
business@…
Message:

fix Study.deleteEventGroup to correctly delete samples (still TODO: assays), added 'published' property to Study for data quality verification

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r959 r965  
    2828        List samples
    2929        List assays
     30        boolean published = false // Determines whether a study is private (only accessable by the owner and writers) or published (also visible to readers)
    3031
    3132        static hasMany = [             
     
    341342                                                })
    342343                                        )
    343                                 }.each() {
     344                                }.each() { sample ->
    344345                                        // remove sample from study
    345346
     
    349350                                        // -------
    350351
    351                                         println ".removing sample '${it.name}' from study '${this.title}'"
    352                                         msg += ", sample '${it.name}' was deleted"
    353                                         this.removeFromSamples( it )
     352                                        println ".removing sample '${sample.name}' from study '${this.title}'"
     353                                        msg += ", sample '${sample.name}' was deleted"
     354                                        this.removeFromSamples( sample )
     355
     356                                        // remove the sample from any sampling events it belongs to
     357                                        this.samplingEvents.findAll { it.samples.any { it == sample }} .each {
     358                                                println ".removed sample ${sample.name} from sampling event ${it} at ${it.getStartTimeString()}"
     359                                                it.removeFromSamples(sample)
     360                                        }
     361
     362                                        // TODO: remove the sample from any assays it belongs to
    354363
    355364                                        // Also here, contrary to documentation, an extra delete() is needed
    356365                                        // otherwise date is not properly deleted!
    357                                         it.delete()
     366                                        sample.delete()
    358367                                }
    359368                        }
  • trunk/test/integration/gscf/SampleTests.groovy

    r964 r965  
    274274                def msg = study.deleteEventGroup(group)
    275275                println msg
     276                assert Sample.count() == 0 // trigger (if any) e.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)
    276277                if (!study.validate()) {
    277278                        study.errors.each { println it}
Note: See TracChangeset for help on using the changeset viewer.