Changeset 1455


Ignore:
Timestamp:
Jan 28, 2011, 1:41:02 PM (12 years ago)
Author:
s.h.sikkema@…
Message:

Using moduleCommunicationService now to fetch measurement data from module

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/studycapturing/AssayController.groovy

    r1445 r1455  
    160160        } catch (Exception e) {
    161161
    162             flash.errorMessage = e.cause?.message ?: e.message
     162            flash.errorMessage = e.message
    163163            redirect action: 'selectAssay'
    164164
  • trunk/grails-app/services/dbnp/authentication/AuthenticationService.groovy

    r1430 r1455  
    5454    public boolean logOffRemotely( String consumer, String token ) {
    5555        def user = getSessionAuthenticatedUser(consumer, token)
    56        
     56
    5757        if( user ) {
    5858            user.refresh()
  • trunk/grails-app/services/dbnp/modules/ModuleCommunicationService.groovy

    r1446 r1455  
    1515package dbnp.modules
    1616
    17 import nl.grails.plugins.gdt.*
    1817import dbnp.studycapturing.*
    1918import grails.converters.*
     19import javax.servlet.http.HttpServletResponse
    2020
    2121class ModuleCommunicationService implements Serializable {
  • trunk/grails-app/services/dbnp/studycapturing/AssayService.groovy

    r1445 r1455  
    2323    boolean transactional = true
    2424    def authenticationService
     25    def moduleCommunicationService
    2526
    2627    /**
     
    3637     * @return The assay data structure as described above.
    3738     */
    38     def collectAssayData(assay, consumer) {
    39 
    40         def path = "/rest/getMeasurementData?assayToken=$assay.token"
     39    def collectAssayData(assay, consumer) throws Exception {
     40
     41        def path = "/rest/getMeasurementData?assayToken=$assay.assayUUID"
    4142
    4243        // check whether module is reachable
    43         if (!isModuleReachable(consumer, path)) {
     44        if (!moduleCommunicationService.isModuleReachable(consumer)) {
    4445
    4546            throw new Exception('Module is not reachable')
     
    143144    }
    144145
    145     def isModuleReachable(consumer, path) {
    146 
    147         def connection = "$consumer$path".toURL().openConnection()
    148         try {
    149             connection.responseCode == HttpServletResponse.SC_OK
    150         } catch(e) { false }
    151        
    152     }
    153 
    154146    /**
    155147     * Retrieves module measurement data through a rest call to the module
     
    161153    def requestModuleMeasurements(consumer, path) {
    162154
    163         // create a random session token that will be used to allow to module to
    164         // sync with gscf prior to presenting the measurement data
    165         def sessionToken = UUID.randomUUID().toString()
    166 
    167         if (!authenticationService.isLoggedIn()) {
    168             // should not happen because we can only get here when a user is
    169             // logged in...
    170             throw new Exception('User is not logged in.')
    171         }
    172 
    173         // put the session token to work
    174         authenticationService.logInRemotely( consumer, sessionToken, authenticationService.getLoggedInUser() )
    175 
    176         // Gather measurement data from the module
    177         try {
    178 
    179             def restResponse = "$consumer$path&sessionToken=$sessionToken".toURL().text
    180 
    181         } catch (e) {
    182 
    183             throw new Exception("Module did not respond to request for measurements. Cause: $e")
    184            
    185         }
    186 
    187         def (sampleTokens, measurementTokens, moduleData) = JSON.parse( restResponse )
    188 
    189         // Dispose of the ephemeral session token
    190         authenticationService.logOffRemotely(consumer, sessionToken)
     155        def (sampleTokens, measurementTokens, moduleData) = moduleCommunicationService.callModuleRestMethodJSON(consumer, consumer+path)
     156
     157        if (!sampleTokens?.size()) return []
    191158
    192159        def lastDataIndex   = moduleData.size() - 1
     
    242209                data.each { category ->
    243210
    244                     if (category.value != [:]) {
     211                    if (category.value.size()) {
    245212
    246213                        // put category keys into first row separated by null values
  • trunk/grails-app/views/pilot/show.gsp

    r1430 r1455  
    6363                                                                linkDest="${createLink(action:'show', id:studyInstance.id)}"
    6464                                                                linkText='Go back to GSCF'
    65                                                                 frameSource="${assay.module.url}/assay/showByToken?id=${assay.externalAssayID}&sessionToken=${session.id}"
     65                                                                frameSource="${assay.module.url}/assay/showByToken?id=${assay.giveUUID()}&sessionToken=${session.id}"
    6666                                                                pageTitle="Assay View in Module">
    6767                                                                ${assay.name}
  • trunk/test/unit/dbnp/studycapturing/AssayControllerTests.groovy

    r1445 r1455  
    4343        controller.assayService = [
    4444
    45                 collectAssayData:                   {a, b -> def e = new Exception('msga'); e.metaClass.cause = new Exception('msg1'); throw e },
    46                 exportColumnWiseDataToExcelFile:    {a, b -> def e = new Exception('msgb'); e.metaClass.cause = new Exception('msg2'); throw e }
     45                collectAssayData:                   {a, b -> throw new Exception('msg1') },
     46                exportColumnWiseDataToExcelFile:    {a, b -> throw new Exception('msg2') }
    4747
    4848        ]
Note: See TracChangeset for help on using the changeset viewer.