Changeset 1367 for trunk/grails-app
- Timestamp:
- Jan 12, 2011, 11:50:56 AM (10 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r1358 r1367 148 148 } 149 149 } 150 151 152 150 153 151 // put your bussiness logic (if applicable) in here … … 214 212 success() 215 213 } else { 216 log.error ".import wizard mapping error, could not validate all entities" 217 error() 214 log.error ".import wizard mapping error, could not validate all entities" 215 error() 218 216 } 219 217 }.to "pageFour" … … 284 282 285 283 // render errors 286 error { 287 //println "error?" 284 error { 288 285 render(view: "_error") 289 286 onRender { … … 303 300 on("toPageFour").to "pageFour" 304 301 on("toPageFive").to "save" 305 306 302 } 307 303 … … 466 462 // field of type ontology and value "#invalidterm"? 467 463 if (field.type == dbnp.studycapturing.TemplateFieldType.ONTOLOGYTERM && 468 params["entity_" + entity.getIdentifier() + "_" + field.escapedName()] == "#invalidterm" 464 params["entity_" + entity.getIdentifier() + "_" + field.escapedName()] == "#invalidterm" 469 465 ) { 470 466 invalidontologies++ 471 467 } else 472 entity.setFieldValue (field.toString(), params["entity_" + entity.getIdentifier() + "_" + field.escapedName()]) 468 if (field.type == dbnp.studycapturing.TemplateFieldType.ONTOLOGYTERM && 469 params["entity_" + entity.getIdentifier() + "_" + field.escapedName()] != "#invalidterm") { 470 removeFailedCell(flow.importer_failedcells, entity) 471 entity.setFieldValue (field.toString(), params["entity_" + entity.getIdentifier() + "_" + field.escapedName()]) 472 } 473 else 474 entity.setFieldValue (field.toString(), params["entity_" + entity.getIdentifier() + "_" + field.escapedName()]) 473 475 } 474 476 … … 482 484 flow.importer_invalidentities++ 483 485 484 // add errors to map 485 this.appendErrors(entity, flash.wizardErrors, 'subject_' + entity.getIdentifier() + '_')486 // add errors to map 487 this.appendErrors(entity, flash.wizardErrors, "entity_"+entity.getIdentifier() + "_") 486 488 487 489 entity.errors.getAllErrors().each() { … … 489 491 } 490 492 } else { 491 // Valid entity, remove it from failedcells 492 flow.importer_failedcells.each { record -> 493 record.importcells.each { cell -> 494 // remove the cell from the failed cells session 495 if (cell.entityidentifier == entity.getIdentifier()) { 496 record.removeFromImportcells(cell) 497 } 498 } // end of importcells 499 } // end of failedcells 493 removeFailedCell(flow.importer_failedcells, entity) 500 494 } // end else if 501 495 … … 505 499 return (flow.importer_invalidentities == 0) ? true : false 506 500 } // end of method 501 502 /** 503 * @param failedcell failed ontology cells 504 * @param entity entity 505 */ 506 def removeFailedCell(failedcells, entity) { 507 // Valid entity, remove it from failedcells 508 failedcells.each { record -> 509 record.importcells.each { cell -> 510 // remove the cell from the failed cells session 511 if (cell.entityidentifier == entity.getIdentifier()) { 512 record.removeFromImportcells(cell) 513 } 514 } // end of importcells 515 } // end of failedcells 516 } 507 517 508 518 /** … … 537 547 def appendErrors(object, map) { 538 548 this.appendErrorMap(getHumanReadableErrors(object), map) 539 549 } 540 550 541 551 def appendErrors(object, map, prepend) { … … 551 561 def appendErrorMap(map, mapToExtend) { 552 562 map.each() {key, value -> 553 mapToExtend[key] = ['key': key, 'value': value, 'dynamic': false] 563 mapToExtend[key] = ['key': key, 'value': value, 'dynamic': false] 554 564 } 555 565 } … … 571 581 object.errors.getAllErrors().each() { error -> 572 582 // error.codes.each() { code -> println code } 583 println "errors is " + error 573 584 574 585 // generally speaking g.message(...) should work, -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r1326 r1367 388 388 */ 389 389 boolean persistEntity(entity) { 390 println "persisting ${entity}" 391 // if not validated 392 if (entity.validate()) { 393 if (entity.save(flush:true)) { //.merge? 394 return true 395 } 396 else { // if save was unsuccesful 397 entity.errors.allErrors.each { 398 println it 399 } 400 return false 401 } 402 } 403 else { // if not validated 404 entity.errors.each { 405 println it 406 } 407 return false 408 } 390 log.info ".import wizard persisting ${entity}" 391 392 if (entity.save(flush:true)) 393 return true 394 else { // if save was unsuccesful 395 entity.errors.allErrors.each { 396 log.error ".import wizard: " + it 397 } 398 return false 399 } 409 400 } 410 401 -
trunk/grails-app/views/importer/common/_error.gsp
r1281 r1367 1 1 <% 2 /** 3 * Error template 4 * 5 * @author Tjeerd Abma 6 * @since 20101008 7 * @package importer 8 * 9 * Revision information: 10 * $Rev$ 11 * $Author$ 12 * $Date$ 13 */ 2 /** 3 * Import Wizard error template 4 * 5 * @author Jeroen Wesbeek 6 * @since 20100114 7 * @package wizard 8 * @see dbnp.studycapturing.ImporterTagLib 9 * @see dbnp.studycapturing.ImporterController 10 * 11 * Revision information: 12 * $Rev$ 13 * $Author$ 14 * $Date$ 15 */ 14 16 %> 15 <html> 16 <head> 17 <meta name="layout" content="main"/> 18 <title>Importer wizard - error</title> 19 </head> 20 <body> 21 The following went wrong:<br/> 22 <p>${error}</p> 23 </body> 24 </html> 17 <g:if test="${wizardErrors}"> 18 <div id="wizardError" class="error" title="Import wizard errors"> 19 <g:each in="${wizardErrors}" var="error" status="e"> 20 <p> 21 <g:if test="${!e}"><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 50px 0;"></span></g:if> 22 ${error.value['key']} → ${error.value['value']} 23 </p> 24 </g:each> 25 </div> 26 <script type="text/javascript"> 27 // mark error fields 28 <g:each in="${wizardErrors}" var="error"> 29 var element = $("input:[name='${error.key}'], input:[name='${error.key.toLowerCase().replaceAll("([^a-z0-9])","_")}'], select:[name='${error.key}'], select:[name='${error.key.toLowerCase().replaceAll("([^a-z0-9])","_")}'], textarea:[name='${error.key}'], textarea:[name='${error.key.toLowerCase().replaceAll("([^a-z0-9])","_")}']"); 30 <g:if test="${error.value['dynamic']}"> 31 element.addClass('error'); 32 </g:if><g:else> 33 element.parent().parent().removeClass('required'); 34 element.parent().parent().addClass('error'); 35 </g:else> 36 </g:each> 37 38 // show error dialog 39 var we = $("div#wizardError"); 40 we.dialog({ 41 modal: true, 42 width: 600, 43 buttons: { 44 Ok: function() { 45 $(this).dialog('close'); 46 we.remove(); 47 } 48 } 49 }); 50 </script> 51 </g:if> -
trunk/grails-app/views/importer/pages/_page_three.gsp
r1277 r1367 17 17 <importer:missingProperties datamatrix="${importer_importeddata}" failedcells="${importer_failedcells}"/> 18 18 </af:page> 19 20 <g:render template="common/error"/>
Note: See TracChangeset
for help on using the changeset viewer.