Ignore:
Timestamp:
Jan 25, 2011, 5:57:37 PM (12 years ago)
Author:
robert@…
Message:

Made the studytoken, assaytoken and sampletoken stable identifiers, as explained in #255.

File:
1 edited

Legend:

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

    r1430 r1440  
    33import dbnp.authentication.SecUser
    44import nl.grails.plugins.gdt.*
     5import java.util.UUID;
    56
    67/**
     
    3334        boolean publicstudy = false  // Determines whether anonymous users are allowed to see this study. This has only effect when published = true
    3435
     36        /**
     37        * UUID of this study
     38        */
     39        String studyUUID
     40
     41       
    3542        static hasMany = [
    3643                subjects: Subject,
     
    4956                owner(nullable: true, blank: true)
    5057                code(nullable: false, blank: true, unique: true)
    51 
     58                studyUUID(nullable:true, unique:true)
    5259                // TODO: add custom validator for 'published' to assess whether the study meets all quality criteria for publication
    5360                // tested by SampleTests.testStudyPublish
     
    6875        // It is used from within dbNP submodules to refer to particular study in this GSCF instance.
    6976
    70         def getToken() { code }
     77        def getToken() { return giveUUID() }
    7178
    7279        /**
     
    502509                }
    503510        }
     511       
     512        /**
     513         * Returns the UUID of this study and generates one if needed
     514         */
     515        public String giveUUID() {
     516                if( !this.studyUUID ) {
     517                        this.studyUUID = UUID.randomUUID().toString();
     518                        this.save();
     519                }
     520               
     521                return this.studyUUID;
     522        }
    504523
    505524        // Send messages to modules about changes in this study
Note: See TracChangeset for help on using the changeset viewer.