Changeset 1103 for trunk/grails-app
- Timestamp:
- Nov 9, 2010, 10:14:23 AM (10 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r1093 r1103 41 41 //session.import_referer = request.forwardURI 42 42 // should do a check what is in the url, strip it? 43 session.import_referer = params.redirectTo 43 session.import_referer = params.redirectTo 44 render(view:"index_simple", 45 model:[studies:Study.findAllWhere(owner:AuthenticationService.getLoggedInUser()), 46 entities: grailsApplication.config.gscf.domain.importableEntities]) 44 47 } 45 48 46 49 def simpleWizard = { 47 render(view:"index_simple", model:[studies:Study.findAllWhere(owner:AuthenticationService.getLoggedInUser()), entities: grailsApplication.config.gscf.domain.importableEntities])50 //render(view:"index_simple", model:[studies:Study.findAllWhere(owner:AuthenticationService.getLoggedInUser()), entities: grailsApplication.config.gscf.domain.importableEntities]) 48 51 } 49 52 50 53 def advancedWizard = { 51 render(view:"index_advanced", model:[templates:Template.list()])54 //render(view:"index_advanced", model:[templates:Template.list()]) 52 55 } 53 56 … … 85 88 session.importer_workbook = wb 86 89 session.importer_study = Study.get(params.study.id.toInteger()) 87 session.importer_template_id = params.template_id 88 session.importer_sheetindex = params.sheetindex.toInteger() -1 // 0 == first sheet 89 session.importer_datamatrix_start = params.datamatrix_start.toInteger() -1 // 0 == first row 90 session.importer_headerrow = params.headerrow.toInteger() 91 92 // Get the header from the Excel file using the arguments given in the first step of the wizard 93 session.importer_header = ImporterService.getHeader(wb, 94 session.importer_sheetindex, 95 session.importer_headerrow, 96 session.importer_datamatrix_start, 97 entityClass) 90 91 if (session.importer_study.canWrite(AuthenticationService.getLoggedInUser())) { 92 session.importer_template_id = params.template_id 93 session.importer_sheetindex = params.sheetindex.toInteger() -1 // 0 == first sheet 94 session.importer_datamatrix_start = params.datamatrix_start.toInteger() -1 // 0 == first row 95 session.importer_headerrow = params.headerrow.toInteger() 96 97 // Get the header from the Excel file using the arguments given in the first step of the wizard 98 session.importer_header = ImporterService.getHeader(wb, 99 session.importer_sheetindex, 100 session.importer_headerrow, 101 session.importer_datamatrix_start, 102 entityClass) 98 103 99 100 101 102 103 104 104 // Initialize 'selected entities', used to show entities above the columns 105 session.importer_header.each { 106 selectedentities.add([name:params.entity, columnindex:it.key.toInteger()]) 107 } 108 109 def templates = Template.get(session.importer_template_id) 105 110 106 render(view:"step2_simple", model:[entities: selectedentities, 107 header:session.importer_header, 108 datamatrix:ImporterService.getDatamatrix( 109 wb, session.importer_header, 110 session.importer_sheetindex, 111 session.importer_datamatrix_start, 112 5), 113 templates:templates]) 111 render(view:"step2_simple", model:[entities: selectedentities, 112 header:session.importer_header, 113 datamatrix:ImporterService.getDatamatrix( 114 wb, session.importer_header, 115 session.importer_sheetindex, 116 session.importer_datamatrix_start, 117 5), 118 templates:templates]) 119 } // end of if 120 else { 121 render (template:"common/error", 122 model:[error:"Wrong permissions: you are not allowed to write to the study you selected (${session.importer_study})."]) 123 } 114 124 } 115 125 … … 139 149 session.importer_importeddata.each { table -> 140 150 table.each { entity -> 141 entity.giveFields().each { field -> 142 //print ":" + params["entity_" + entity.hashCode() + "_" + field.escapedName()] 151 entity.giveFields().each { field -> 143 152 entity.setFieldValue (field.toString(), params["entity_" + entity.hashCode() + "_" + field.escapedName()]) 144 153 } … … 171 180 correctedcells) 172 181 173 //render("failed cells saved")174 175 182 render(view:"step3_simple", model:[datamatrix:session.importer_importeddata]) 176 183 … … 296 303 session.importer_failedcells = failedcells 297 304 298 render(view:"step2a_simple", model:[failedcells:session.importer_failedcells]) 299 300 /*if (params.layout=="horizontal") 301 render(view:"step3_simple", model:[datamatrix:session.importer_importeddata]) 302 else if (params.layout=="vertical") 303 render(view:"step3", model:[datamatrix:session.importer_importeddata])*/ 305 if (failedcells.size()!=0) 306 render(view:"step2a_simple", model:[failedcells:session.importer_failedcells]) 307 else { 308 if (params.layout=="horizontal") 309 render(view:"step3_simple", model:[datamatrix:session.importer_importeddata]) 310 else if (params.layout=="vertical") 311 render(view:"step3", model:[datamatrix:session.importer_importeddata]) 312 } 304 313 } 305 314 -
trunk/grails-app/domain/dbnp/importer/MappingColumn.groovy
r959 r1103 22 22 Boolean dontimport 23 23 24 static transients = [ "templatefieldtype", "entity" ] 25 24 26 static constraints = { 25 27 name(unique: true) -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1093 r1103 258 258 def saveCorrectedCells(datamatrix, failedcells, correctedcells) { 259 259 // Loop through all failed cells 260 260 261 failedcells.each { mcrecord -> 261 262 mcrecord.each { mappingcolumn -> … … 265 266 // Find the record in the table which the mappingcolumn belongs to 266 267 def tablerecord = datamatrix.find { it.hashCode() == mcrecord.key } 267 268 268 269 // Loop through all entities in the record 269 270 tablerecord.each { rec -> 270 rec.each { entity -> 271 rec.each { entity -> 271 272 try { 272 273 // Update the entity field … … 280 281 } // end of table record 281 282 } // end of mapping record 282 } // end of failed cells loop 283 } // end of failed cells loop 283 284 } 284 285 … … 425 426 def df = new DataFormatter() 426 427 def template = Template.get(template_id) 428 def tft = TemplateFieldType 427 429 def record = [] // list of entities and the read values 428 430 def failed = [] // list of failed columns [mappingcolumn] with the value which couldn't be mapped into the entity … … 449 451 } 450 452 453 454 //println "temateplfedielfdtype=" + mc.templatefieldtype 455 // Are we trying to map an ontology term which is empty? Then it is a failed cell 456 /*if (value=="") { 457 println "empty term" 458 def temp = new MappingColumn() 459 //temp.properties = mc.properties 460 temp.value = "undefined" 461 failed.add(temp) 462 }*/ 463 464 451 465 try { 466 /*if ((mc.templatefieldtype == TemplateFieldType.ONTOLOGYTERM) && (value == "")) 467 { 468 def temp = new MappingColumn() 469 temp.properties = mc.properties 470 temp.value="unknown" 471 failed.add(temp) 472 }*/ 452 473 453 474 // which entity does the current cell (field) belong to? … … 476 497 def temp = new MappingColumn() 477 498 temp.properties = mc.properties 478 temp.value = value 499 temp.value = value 479 500 failed.add(temp) 480 501 } -
trunk/grails-app/views/importer/common/_failedcells.gsp
r1093 r1103 50 50 <tr> 51 51 <td colspan="4"> 52 <input type="submit" value=" Accept changes">52 <input type="submit" value="Next"> 53 53 </td> 54 54 </tr> -
trunk/grails-app/views/importer/common/_missingproperties.gsp
r959 r1103 25 25 <g:set var="showHeader" value="${true}"/> 26 26 <g:each status="index" var="table" in="${datamatrix}"> 27 <g:each status="i" var="entity" in="${table}"> 27 <g:each status="i" var="entity" in="${table}"> 28 28 <g:if test="${showHeader}"> 29 29 <g:set var="showHeader" value="${false}"/> -
trunk/grails-app/views/importer/index_simple.gsp
r959 r1103 75 75 </head> 76 76 <body> 77 <h1>Importer wizard (simple)</h1>77 <h1>Importer wizard</h1> 78 78 <p>You can import your Excel data to the server by choosing a file from your local harddisk in the form below.</p> 79 79 <form id="simplewizardform" controller="importer" method="post" action="upload_simple" enctype="multipart/form-data"> -
trunk/grails-app/views/importer/step1_simple.gsp
r959 r1103 20 20 <meta name="layout" content="main"/> 21 21 <link rel="stylesheet" href="${resource(dir: 'css', file: 'importer.css')}"/> 22 <title>Step 1: import wizard preview (simple)</title>22 <title>Step 1: import wizard preview</title> 23 23 </head> 24 24 <body> 25 <h1>Step 1: import wizard preview (simple)</h1>25 <h1>Step 1: import wizard preview</h1> 26 26 <p>Below you see a preview of your imported file, please correct the automatically detected types.</p> 27 27 <importer:preview header="${header}" datamatrix="${datamatrix}"/> -
trunk/grails-app/views/importer/step3_simple.gsp
r959 r1103 1 1 <% 2 2 /** 3 * Third sstep in the importer, showing the imported data3 * Third step in the importer, showing the imported data 4 4 * 5 5 * @author Tjeerd Abma
Note: See TracChangeset
for help on using the changeset viewer.