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

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

Location:
trunk/grails-app/domain/dbnp/studycapturing
Files:
3 edited

Legend:

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

    r1430 r1440  
    11package dbnp.studycapturing
    22import nl.grails.plugins.gdt.*
     3import java.util.UUID;
    34
    45/**
     
    1718        // This ID is generated in GSCF, but is used in the submodules to refer to this particular Assay.
    1819        String externalAssayID
     20
     21        /**
     22        * UUID of this assay
     23        */
     24    String assayUUID
    1925
    2026        /**
     
    5056        static constraints = {
    5157                externalAssayID(nullable:false, blank:false, unique: true)
     58                assayUUID(nullable:true, unique: true)
    5259        }
    5360
     
    6471
    6572    def getToken() {
    66                 return externalAssayID
     73                return giveUUID()
    6774    }
     75       
     76        /**
     77         * Returns the UUID of this sample and generates one if needed
     78         */
     79        public String giveUUID() {
     80                if( !this.assayUUID ) {
     81                        this.assayUUID = UUID.randomUUID().toString();
     82                        this.save();
     83                }
     84               
     85                return this.assayUUID;
     86        }
    6887}
  • trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy

    r1430 r1440  
    22
    33import nl.grails.plugins.gdt.*
     4import java.util.UUID;
    45
    56/**
     
    3435        String name             // should be unique with respect to the parent study (which can be inferred)
    3536        Term material           // material of the sample (should normally be bound to the BRENDA ontology)
    36 
     37       
     38        /**
     39         * UUID of this sample
     40         */
     41        String sampleUUID
     42       
    3743        /**
    3844         * return the domain fields for this domain class
     
    6975                // The material domain field is optional
    7076                material(nullable: true)
     77               
     78                sampleUUID(nullable: true, unique: true)
    7179
    7280                // Check if the externalSampleId (currently defined as name) is really unique within each parent study of this sample.
     
    123131                return name
    124132        }
     133       
     134        /**
     135         * Returns the UUID of this sample and generates one if needed
     136         */
     137        public String giveUUID() {
     138                if( !this.sampleUUID ) {
     139                        this.sampleUUID = UUID.randomUUID().toString();
     140                        this.save();
     141                }
     142               
     143                return this.sampleUUID;
     144        }
    125145}
  • 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.