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