Changeset 4 for trunk/grails-app/domain


Ignore:
Timestamp:
Jan 17, 2011, 3:49:20 PM (13 years ago)
Author:
robert@…
Message:

Implemented trash in order to prevent deletion of data

Location:
trunk/grails-app/domain/nl/tno/metagenomics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/nl/tno/metagenomics/AssaySample.groovy

    r3 r4  
    142142                _averageQuality = -1;
    143143        }
     144       
     145        /**
     146         * Check whether this assay-sample combination contains information that should be saved in trash on a delete
     147         * @return
     148         */
     149        public boolean containsData() {
     150                return tagSequence || oligoNumber || numFiles() > 0;
     151        }
     152       
     153        /**
     154         * Move information that should be kept on delete to another assaySample object.
     155         *
     156         * N.B. The sequencedata objects are really moved, so removed from the original object!
     157         *
     158         * @param otherAssaySample      Object to move
     159         */
     160        public void moveValuableDataTo( AssaySample otherAssaySample ) {
     161                // Copy properties
     162                otherAssaySample.tagSequence = tagSequence;
     163                otherAssaySample.oligoNumber = oligoNumber;
     164               
     165                // Move attached data
     166                def dataList = sequenceData?.toList()
     167                def otherAssay = otherAssaySample.assay;
     168               
     169                if( dataList && dataList.size() > 0 ) {
     170                        for( def j = dataList.size() - 1; j >= 0; j-- ) {
     171                                // Check whether the run of this sequenceData object is also connected to the assay
     172                                def run = dataList[j].run;
     173                               
     174                                if( !otherAssay.runs || !otherAssay.runs.contains( run ) ) {
     175                                        otherAssay.addToRuns( run );
     176                                }
     177                               
     178                                // Copy data
     179                                dataList[j].sample = otherAssaySample;
     180                                this.removeFromSequenceData( dataList[j] );
     181                                otherAssaySample.addToSequenceData( dataList[j] );
     182                                dataList[j].save();
     183                        }
     184                }
     185        }
    144186}
  • trunk/grails-app/domain/nl/tno/metagenomics/Study.groovy

    r2 r4  
    1313        String studyToken
    1414        String name
     15
     16        // Set to true only on the specific study object that acts as
     17        // a trash can for deleted objects. If objects are deleted in GSCF but still
     18        // contain data in this module, they will be moved to the trashcan.
     19        Boolean trashcan = false
    1520       
    1621        // If a study is set to be dirty, it should be updated
     
    3136        static constraints = {
    3237                studyToken(unique:true)
     38                trashcan(nullable:true)
     39                isDirty(nullable:true)
    3340        }
    3441       
     
    7077                return authorization.isOwner
    7178        }
     79
    7280}
Note: See TracChangeset for help on using the changeset viewer.