Changeset 1455
- Timestamp:
- Jan 28, 2011, 1:41:02 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/studycapturing/AssayController.groovy
r1445 r1455 160 160 } catch (Exception e) { 161 161 162 flash.errorMessage = e. cause?.message ?: e.message162 flash.errorMessage = e.message 163 163 redirect action: 'selectAssay' 164 164 -
trunk/grails-app/services/dbnp/authentication/AuthenticationService.groovy
r1430 r1455 54 54 public boolean logOffRemotely( String consumer, String token ) { 55 55 def user = getSessionAuthenticatedUser(consumer, token) 56 56 57 57 if( user ) { 58 58 user.refresh() -
trunk/grails-app/services/dbnp/modules/ModuleCommunicationService.groovy
r1446 r1455 15 15 package dbnp.modules 16 16 17 import nl.grails.plugins.gdt.*18 17 import dbnp.studycapturing.* 19 18 import grails.converters.* 19 import javax.servlet.http.HttpServletResponse 20 20 21 21 class ModuleCommunicationService implements Serializable { -
trunk/grails-app/services/dbnp/studycapturing/AssayService.groovy
r1445 r1455 23 23 boolean transactional = true 24 24 def authenticationService 25 def moduleCommunicationService 25 26 26 27 /** … … 36 37 * @return The assay data structure as described above. 37 38 */ 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" 41 42 42 43 // check whether module is reachable 43 if (! isModuleReachable(consumer, path)) {44 if (!moduleCommunicationService.isModuleReachable(consumer)) { 44 45 45 46 throw new Exception('Module is not reachable') … … 143 144 } 144 145 145 def isModuleReachable(consumer, path) {146 147 def connection = "$consumer$path".toURL().openConnection()148 try {149 connection.responseCode == HttpServletResponse.SC_OK150 } catch(e) { false }151 152 }153 154 146 /** 155 147 * Retrieves module measurement data through a rest call to the module … … 161 153 def requestModuleMeasurements(consumer, path) { 162 154 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 [] 191 158 192 159 def lastDataIndex = moduleData.size() - 1 … … 242 209 data.each { category -> 243 210 244 if (category.value != [:]) {211 if (category.value.size()) { 245 212 246 213 // put category keys into first row separated by null values -
trunk/grails-app/views/pilot/show.gsp
r1430 r1455 63 63 linkDest="${createLink(action:'show', id:studyInstance.id)}" 64 64 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}" 66 66 pageTitle="Assay View in Module"> 67 67 ${assay.name} -
trunk/test/unit/dbnp/studycapturing/AssayControllerTests.groovy
r1445 r1455 43 43 controller.assayService = [ 44 44 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') } 47 47 48 48 ]
Note: See TracChangeset
for help on using the changeset viewer.