Changeset 1502
- Timestamp:
- Feb 7, 2011, 4:32:07 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r1499 r1502 111 111 112 112 on("refresh") { 113 flash.importer_params = params 113 flash.importer_params = params 114 114 success() 115 115 }.to "pageOne" … … 117 117 on("next") { 118 118 flash.wizardErrors = [:] 119 //flash.importer_params = params 119 120 120 121 // Study selected? … … 123 124 // Trying to import data into an existing study? 124 125 if (flow.importer_study) 125 if (flow.importer_study.canWrite(authenticationService.getLoggedInUser())) { 126 if (fileImportPage(flow, params)) { 127 success() 128 } else { 129 log.error ".importer wizard not all fields are filled in" 130 this.appendErrorMap(['error': "Not all fields are filled in, please fill in or select all fields"], flash.wizardErrors) 131 error() 132 } 133 } else { 126 if (flow.importer_study.canWrite(authenticationService.getLoggedInUser())) 127 fileImportPage(flow, flash, params) ? success() : error() 128 else { 134 129 log.error ".importer wizard wrong permissions" 135 130 this.appendErrorMap(['error': "You don't have the right permissions"], flash.wizardErrors) 136 137 131 error() 138 132 } 139 133 else { 140 if (fileImportPage(flow, params)) { 141 success() 142 } else { 143 log.error ".importer wizard not all fields are filled in" 144 this.appendErrorMap(['error': "Not all fields are filled in, please fill in or select all fields"], flash.wizardErrors) 145 error() 146 } 134 fileImportPage(flow, flash, params) ? success() : error() 147 135 } 148 136 … … 299 287 * @returns boolean true if correctly validated, otherwise false 300 288 */ 301 boolean fileImportPage(flow, params) {289 boolean fileImportPage(flow, flash, params) { 302 290 def importedfile = fileService.get(params['importfile']) 303 291 //fileService.delete(YourFile) 304 292 305 if (params.entity && params.template_id && importedfile.exists()) { 306 // create a workbook instance of the file 307 session.importer_workbook = ImporterService.getWorkbook(new FileInputStream(importedfile)) 293 if (importedfile.exists()) { 294 try { 295 session.importer_workbook = ImporterService.getWorkbook(new FileInputStream(importedfile)) 296 } catch (Exception e) { 297 log.error ".importer wizard could not load file: " + e 298 this.appendErrorMap(['error': "Wrong file (format), the importer requires an Excel file as input"], flash.wizardErrors) 299 return false 300 } 301 } 302 303 if (params.entity && params.template_id) { 304 305 try { 306 session.importer_workbook = ImporterService.getWorkbook(new FileInputStream(importedfile)) 307 } catch (Exception e) { 308 log.error ".importer wizard could not load file: " + e 309 this.appendErrorMap(['error': "Excel file required as input"], flash.wizardErrors) 310 return false 311 } 308 312 309 313 def selectedentities = [] … … 345 349 return true 346 350 } 351 352 log.error ".importer wizard not all fields are filled in" 353 this.appendErrorMap(['error': "Not all fields are filled in, please fill in or select all fields"], flash.wizardErrors) 354 return false 347 355 } 348 356
Note: See TracChangeset
for help on using the changeset viewer.