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/RunController.groovy

    r67 r70  
    44import grails.converters.JSON
    55import nl.tno.massSequencing.auth.*
     6import nl.tno.massSequencing.classification.*;
    67
    78import org.codehaus.groovy.grails.commons.ConfigurationHolder
     
    3334                        "r.name",
    3435                        "COUNT( DISTINCT a )",
    35                         "SUM( a.numSequences )"
     36                        "SUM( a.numSequences )",
     37                        "(SELECT SUM( c.unclassified ) FROM Classification c WHERE c.assaySample.run = r)"
    3638                ]
    3739
     
    4143                // Retrieve data from assaySample table
    4244                def from = "Run r LEFT JOIN r.assaySamples a"
    43 
     45               
    4446                // This closure determines what to do with a row that is retrieved from the database.
    4547                def convertClosure = {
     
    4850                        def numSamples = it[ 2 ];
    4951                        def numSequences = it[ 3 ];
     52                        def numClassified = it[ 4 ];
    5053
    5154                        // Create buttons in the last three columns
     
    7174                                numSamples > 0 ? g.formatNumber( number: numSamples, format: "###,###,##0" ) : "-",     // it.numSequences(),
    7275                                numSequences > 0 ? g.formatNumber( number: numSequences, format: "###,###,##0" ) : "-", // it.numQualScores(),
     76                                numClassified > 0 ? g.formatNumber( number: numClassified, format: "###,###,##0" ) : "-", // it.percentageClassified
    7377                                editButton,
    7478                                deleteButton,
     
    107111
    108112                // Determine several parameters to show on screen
    109                
     113                def numClassified = Classification.executeQuery( "SELECT SUM( c.unclassified ) FROM Classification c WHERE c.assaySample IN (:assaySamples)", [ "assaySamples": run.assaySamples ] );
    110114               
    111115                // Send the assay information to the view
    112                 [run: run, allRuns: Run.list(), otherAssays: otherAssays, editable: true]
     116                [run: run, allRuns: Run.list(), otherAssays: otherAssays, editable: true, "numClassified": numClassified ? numClassified[ 0 ] : 0 ]
    113117        }
    114118       
     
    817821                        name = "runs";
    818822
    819                 // Export the sequences and quality scores
    820                 response.setHeader "Content-disposition", "attachment; filename=${name}.zip"
    821                 try {
    822                         fastaService.export( assaySamples.unique(), response.getOutputStream() );
    823                         response.outputStream.flush();
    824                 } catch( Exception e ) {
    825                         log.error( "Exception occurred during export of sequences. Probably the user has cancelled the download." );
    826                         e.printStackTrace();
    827                 }
     823                       
     824                // Start the export in the background
     825                def returnUrl = createLink( controller: "run", action: "index" ).toString()
     826                def finishUrl = createLink( controller: "assaySample", action: 'downloadFasta', params: [ processId: '%s' ] ).toString();
     827                def url = fastaService.startExportProcess( assaySamples, session, name, returnUrl, finishUrl )
     828               
     829                // Show a waiting screen
     830                redirect( url: url );
    828831        }
    829832       
     
    858861                        response.setHeader "Content-disposition", "attachment; filename=${name}.xls"
    859862
     863                        sampleExcelService.sessionToken = session.sessionToken
     864                       
    860865                        if( !sampleExcelService.exportExcelSampleData( assaySamples.unique(), tags, response.outputStream ) ) {
    861866                                flash.error = "An error occurred while fetching sample data. Maybe the session has timed out.";
Note: See TracChangeset for help on using the changeset viewer.