Ignore:
Timestamp:
Jun 17, 2011, 1:54:56 PM (8 years ago)
Author:
robert@…
Message:
  • Installed templates (in order to extend session lifetime to 2 hours)
  • Implemented background worker to do work outside the HTTP request
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/nl/tno/massSequencing/AssayController.groovy

    r63 r70  
    33import java.util.List;
    44import grails.converters.JSON
     5import nl.tno.massSequencing.classification.*;
    56
    67import org.codehaus.groovy.grails.commons.ConfigurationHolder
     
    4142                   "COUNT( DISTINCT s )",
    4243                   "SUM( s.numSequences ) / COUNT( DISTINCT s )",
     44                   "(SELECT SUM( c.unclassified ) FROM Classification c WHERE c.assaySample.assay = a)",
    4345                   "a.study.studyToken"
    4446           ]
    4547           
    46            def groupColumns = columns[0..2] + columns[ 5 ];
     48           def groupColumns = columns[0..2] + columns[ 6 ];
    4749           def orderByMapping = null;
    4850           
     
    5961                   def numSamples = it[ 3 ];
    6062                   def numSequences = it[ 4 ];
    61                    def studyToken = it[ 5 ];
     63                   def numClassification = it[ 5 ];
     64                   def studyToken = it[ 6 ];
    6265                   
    6366                   // Create buttons in the last three columns
     
    7780                           numSamples > 0 ? g.formatNumber( number: numSamples, format: "###,###,##0" ) : "-",  // it.numSequences(),
    7881                           numSequences > 0 ? g.formatNumber( number: numSequences, format: "###,###,##0" ) : "-",      // it.numQualScores(),
     82                           numClassification > 0 ? g.formatNumber( number: numClassification, format: "###,###,##0" ) : "-",    // it.numClassification(),
    7983                           editButton,
    8084                           chartButton
     
    119123                def otherRuns = Run.list( sort: "name" ).findAll { !it.assays.contains( assay ) }
    120124
     125                // Determine other parameters to show on screen
     126                def numClassified = Classification.executeQuery( "SELECT SUM( c.unclassified ) FROM Classification c WHERE c.assaySample IN (:assaySamples)", [ "assaySamples": assay.assaySamples ] );
     127
    121128                // Send the assay information to the view
    122                 [assay: assay, editable: assay.study.canWrite( session.user ), otherRuns: otherRuns]
     129                [assay: assay, editable: assay.study.canWrite( session.user ), otherRuns: otherRuns, "numClassified": numClassified ? numClassified[ 0 ] : 0]
    123130        }
    124131       
     
    556563         */
    557564        def exportAsFasta = {
    558                 def assaySamples = getAssaySamples( params );
     565                def assaySamples = getAssaySamples( params ).unique();
    559566                def name
    560567
     
    567574                }
    568575
    569                 // Export the sequences and quality scores
    570                 response.setHeader "Content-disposition", "attachment; filename=" + name.trim() + ".zip"
    571                 try {
    572                         fastaService.export( assaySamples.unique(), response.getOutputStream() );
    573                         response.outputStream.flush();
    574                 } catch( Exception e ) {
    575                         log.error( "Exception occurred during export of sequences. Probably the user has cancelled the download." );
    576                         e.printStackTrace();
    577                 }
     576                // Start the export in the background
     577                def returnUrl = params.url ? params.url.toString() : createLink( controller: "assay", action: "index" ).toString()
     578                def finishUrl = createLink( controller: "assaySample", action: 'downloadFasta', params: [ processId: '%s' ] ).toString();
     579                def url = fastaService.startExportProcess( assaySamples, session, name, returnUrl, finishUrl )
     580               
     581                // Show a waiting screen
     582                redirect( url: url );
    578583        }
    579584
     
    602607                                tags << [assaySampleId: assaySample.id, sampleName: assaySample.sample.name, assayName: assaySample.assay.name, studyName: assaySample.assay.study.name, tag: "-"]
    603608                        }
     609                        sampleExcelService.sessionToken = session.sessionToken
    604610                        sampleExcelService.exportExcelSampleData( assaySamples.unique(), tags, response.getOutputStream() );
    605611                        response.outputStream.flush();
Note: See TracChangeset for help on using the changeset viewer.