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.

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.