Changeset 966


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

also added assays check in Study.deleteEventGroup, added test to check whether a study with orphan events cannot be published (functionality is still to be implemented)

Location:
trunk
Files:
2 edited

Legend:

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

    r965 r966  
    4444                owner(nullable: true, blank: true)
    4545                code(nullable:false, blank:true,unique:true)
     46
     47                // TODO: add custom validator for 'published' to assess whether the study meets all quality criteria for publication
     48                // tested by SampleTests.testStudyPublish
    4649        }
    4750
     
    360363                                        }
    361364
    362                                         // TODO: remove the sample from any assays it belongs to
     365                                        // remove the sample from any assays it belongs to
     366                                        this.assays.findAll { it.samples.any { it == sample }} .each {
     367                                                println ".removed sample ${sample.name} from assay ${it.name}"
     368                                                it.removeFromSamples(sample)
     369                                        }
    363370
    364371                                        // Also here, contrary to documentation, an extra delete() is needed
  • trunk/test/integration/gscf/SampleTests.groovy

    r965 r966  
    112112        }
    113113
     114        private void addParentSubject() {
     115
     116                def sampleDB = Sample.findByName(testSampleName)
     117                assert sampleDB
     118
     119                // Retrieve the parent study
     120                def study = Study.findByTitle(testStudyName)
     121                assert study
     122
     123                def subject = SubjectTests.createSubject(study)
     124                assert subject
     125
     126                sampleDB.parentSubject = subject
     127                assert sampleDB.validate()
     128                assert sampleDB.save()
     129
     130        }
     131
     132        /**
     133         * Test whether a study which has orphan (without parent subject/event) samples cannot be published
     134         */
    114135        void testStudyPublish() {
    115136                def sampleDB = Sample.findByName(testSampleName)
     
    124145
    125146                // Try to publish the study, should fail as it has a sample without a parent sampling event
    126                 //study.published = true
     147                study.published = true
    127148                assert !study.validate()
    128149
     
    131152
    132153                // Add parent subject
     154                addParentSubject()
    133155
    134156                // Now the study should validate
     
    184206                assert study
    185207
    186                 def subject = SubjectTests.createSubject(study)
    187                 assert subject
    188 
    189                 sampleDB.parentSubject = subject
    190                 assert sampleDB.validate()
    191                 assert sampleDB.save()
     208                // Add parent subject
     209                addParentSubject()
     210                Subject subject = sampleDB.parentSubject
    192211
    193212                // Use the deleteSubject method
     
    250269                assert event
    251270
    252                 // Create a subject and add it at the sample's parent
    253                 def subject = SubjectTests.createSubject(study)
    254                 assert subject
    255                 sampleDB.parentSubject = subject
    256                 assert sampleDB.validate()
    257                 assert sampleDB.save()
    258 
    259                 // Create an event group in this study with the sample's sampling event
     271                // Add parent subject
     272                addParentSubject()
     273                Subject subject = sampleDB.parentSubject
     274
     275                // Create an event group in this study with the sample's sampling event and subject
    260276                def group = new EventGroup(
    261277                    name: testEventGroupName
     
    264280                assert group.validate()
    265281
    266 
    267282                group.addToSubjects(subject)
    268283                group.addToSamplingEvents(event)
     284
    269285                assert study.eventGroups.find { it.name == group.name}
    270286                assert group.validate()
Note: See TracChangeset for help on using the changeset viewer.