Changeset 1830 for trunk/grails-app/services
- Timestamp:
- May 10, 2011, 3:44:15 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/dbnp/studycapturing/AssayService.groovy
r1828 r1830 18 18 import org.codehaus.groovy.grails.web.json.JSONObject 19 19 import org.dbnp.gdt.RelTime 20 import org.dbnp.gdt.TemplateFieldType; 20 import org.dbnp.gdt.TemplateFieldType 21 import java.text.DecimalFormat 22 import java.text.NumberFormat 21 23 22 24 class AssayService { … … 244 246 def moduleUrl = assay.module.url 245 247 246 def path = moduleUrl + "/rest/getMeasurements/query?assayToken=$assay.assayUUID" 247 248 def jsonArray = moduleCommunicationService.callModuleRestMethodJSON(moduleUrl, path) 248 def path = moduleUrl + "/rest/getMeasurements/query" 249 def query = "assayToken=$assay.assayUUID" 250 def jsonArray 251 252 try { 253 jsonArray = moduleCommunicationService.callModuleMethod(moduleUrl, path, query) 254 } catch (e) { 255 throw new Exception("An error occured while trying to get the measurement tokens from the $assay.module.name. \ 256 This means the module containing the measurement data is not available right now. Please try again \ 257 later or notify the system administrator if the problem persists. URL: $path?$query.") 258 } 249 259 250 260 jsonArray.collect { … … 275 285 } 276 286 277 def path = moduleUrl + "/rest/getMeasurementData/query?assayToken=$assay.assayUUID" + tokenString 278 279 def (sampleTokens, measurementTokens, moduleData) = moduleCommunicationService.callModuleRestMethodJSON(moduleUrl, path) 287 def path = moduleUrl + "/rest/getMeasurementData/query" 288 289 def query = "assayToken=$assay.assayUUID$tokenString" 290 291 def sampleTokens = [], measurementTokens = [], moduleData = [] 292 293 try { 294 (sampleTokens, measurementTokens, moduleData) = moduleCommunicationService.callModuleMethod(moduleUrl, path, query) 295 } catch (e) { 296 throw new Exception("An error occured while trying to get the measurement data from the $assay.module.name. \ 297 This means the module containing the measurement data is not available right now. Please try again \ 298 later or notify the system administrator if the problem persists. URL: $path?$query.") 299 } 280 300 281 301 if (!sampleTokens?.size()) return [] … … 307 327 measurements << null 308 328 } else { 309 measurements << ( moduleData[ valueIndex ] == JSONObject.NULL ? "" : moduleData[ valueIndex ].to String() );329 measurements << ( moduleData[ valueIndex ] == JSONObject.NULL ? "" : moduleData[ valueIndex ].toDouble() ); 310 330 } 311 331 } else { … … 520 540 * @return 521 541 */ 522 def exportRowWiseDataToCSVFile(rowData, outputStream, outputDelimiter = '\t') { 542 def exportRowWiseDataToCSVFile(rowData, outputStream, outputDelimiter = '\t', locale = java.util.Locale.US) { 543 544 def formatter = NumberFormat.getNumberInstance(locale) 545 formatter.setGroupingUsed false // we don't want grouping (thousands) separators 523 546 524 547 outputStream << rowData.collect { row -> 525 548 row.collect{ 526 549 527 // omit quotes in case of numeric values 528 if (it instanceof Number) return it550 // omit quotes in case of numeric values and format using chosen locale 551 if (it instanceof Number) return formatter.format(it) 529 552 530 553 def s = it?.toString() ?: ''
Note: See TracChangeset
for help on using the changeset viewer.