- Timestamp:
- Mar 29, 2011, 2:30:12 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/query/AdvancedQueryController.groovy
r1618 r1678 396 396 criterion.operator = Criterion.parseOperator( formCriterion.operator ); 397 397 } catch( Exception e) { 398 println"Operator " + formCriterion.operator + " could not be parsed: " + e.getMessage();398 log.debug "Operator " + formCriterion.operator + " could not be parsed: " + e.getMessage(); 399 399 flash.error += "Criterion could not be used: operator " + formCriterion.operator + " is not valid.<br />\n"; 400 400 continue; -
trunk/grails-app/controllers/dbnp/studycapturing/SimpleWizardController.groovy
r1621 r1678 22 22 import dbnp.importer.ImportRecord 23 23 import dbnp.importer.MappingColumn 24 import org.hibernate.SessionFactory; 24 25 25 26 @Secured(['IS_AUTHENTICATED_REMEMBERED']) … … 29 30 def importerService 30 31 def gdtService = new GdtService() 32 def sessionFactory 31 33 32 34 /** … … 133 135 def filename = params.get( 'importfile' ); 134 136 137 handleSampleForm( flow.study, params, flow ) 138 135 139 // Handle 'existing*' in front of the filename. This is put in front to make a distinction between 136 140 // an already uploaded file test.txt (maybe moved to some other directory) and a newly uploaded file test.txt … … 142 146 filename = filename[9..-1] 143 147 144 // Refresh the templates, since the template editor has been opened 148 flow.sampleForm.importFile = filename 149 150 // Refresh the templates, since the template editor has been opened. To make this happen 151 // the hibernate session has to be cleared first 152 sessionFactory.getCurrentSession().clear(); 153 145 154 flow.templates = [ 146 155 'Sample': Template.findAllByEntity( Sample.class ), … … 149 158 'SamplingEvent': Template.findAllByEntity( SamplingEvent.class ) 150 159 ]; 151 152 flow.sampleForm = [ importFile: filename ] 160 153 161 }.to "samples" 154 162 on("previous").to "returnFromSamples" … … 256 264 }.to "overview" 257 265 on( "previous" ).to "returnFromAssays" 258 on("refresh") { handleAssays( flow.assay, params, flow ); success() }.to "assays" 266 on("refresh") { 267 // Refresh the templates, since the template editor has been opened. To make this happen 268 // the hibernate session has to be cleared first 269 sessionFactory.getCurrentSession().clear(); 270 271 handleAssays( flow.assay, params, flow ); 272 273 flow.assay?.template?.refresh() 274 success() 275 }.to "assays" 259 276 } 260 277 … … 469 486 filename = filename[9..-1] 470 487 471 def sampleTemplateId = params.long( 'sample_template_id' ) 472 def subjectTemplateId = params.long( 'subject_template_id' ) 473 def eventTemplateId = params.long( 'event_template_id' ) 474 def samplingEventTemplateId = params.long( 'samplingEvent_template_id' ) 475 488 handleSampleForm( study, params, flow ); 489 490 // Check whether the template exists 491 if (!flow.sampleForm.template.Sample ){ 492 log.error ".simple study wizard not all fields are filled in (sample template) " 493 flash.error = "No template was chosen. Please choose a template for the samples you provided." 494 return false 495 } 496 476 497 // These fields have been removed from the form, so will always contain 477 498 // their default value. The code however remains like this for future use. … … 479 500 int dataMatrixStart = (params.int( 'datamatrix_start' ) ?: 2 ) 480 501 int headerRow = (params.int( 'headerrow' ) ?: 1 ) 502 503 flow.sampleForm.sheetIndex = sheetIndex; 504 flow.sampleForm.dataMatrixStart = dataMatrixStart 505 flow.sampleForm.headerRow = headerRow 506 507 def importedfile = fileService.get( filename ) 508 def workbook 509 if (importedfile.exists()) { 510 try { 511 workbook = importerService.getWorkbook(new FileInputStream(importedfile)) 512 } catch (Exception e) { 513 log.error ".simple study wizard could not load file: " + e 514 flash.error = "The given file doesn't seem to be an excel file. Please provide an excel file for entering samples."; 515 return false 516 } 517 } else { 518 log.error ".simple study wizard no file given"; 519 flash.error = "No file was given. Please provide an excel file for entering samples."; 520 return false; 521 } 522 523 if( !workbook ) { 524 log.error ".simple study wizard could not load file into a workbook" 525 flash.error = "The given file doesn't seem to be an excel file. Please provide an excel file for entering samples."; 526 return false 527 } 528 529 def selectedentities = [] 530 531 if( !excelChecks( workbook, sheetIndex, headerRow, dataMatrixStart ) ) 532 return false; 533 534 // Get the header from the Excel file using the arguments given in the first step of the wizard 535 def importerHeader; 536 def importerDataMatrix; 537 538 try { 539 importerHeader = importerService.getHeader(workbook, 540 sheetIndex - 1, // 0 == first sheet 541 headerRow, // 1 == first row :s 542 dataMatrixStart - 1, // 0 == first row 543 Sample.class) 544 545 importerDataMatrix = importerService.getDatamatrix( 546 workbook, 547 importerHeader, 548 sheetIndex - 1, // 0 == first sheet 549 dataMatrixStart - 1, // 0 == first row 550 5) 551 } catch( Exception e ) { 552 // An error occurred while reading the excel file. 553 log.error ".simple study wizard error while reading the excel file"; 554 e.printStackTrace(); 555 556 // Show a message to the user 557 flash.error = "An error occurred while reading the excel file. Have you provided the right sheet number and row numbers. Contact your system administrator if this problem persists."; 558 return false; 559 } 560 561 // Match excel columns with template fields 562 def fieldNames = []; 563 flow.sampleForm.template.each { template -> 564 if( template.value ) { 565 def fields = template.value.entity.giveDomainFields() + template.value.getFields(); 566 fields.each { field -> 567 if( !field.entity ) 568 field.entity = template.value.entity 569 570 fieldNames << field 571 } 572 } 573 } 574 importerHeader.each { mc -> 575 def bestfit = importerService.mostSimilar( mc.name, fieldNames, 0.8); 576 if( bestfit ) { 577 // Remove this fit from the list 578 fieldNames.remove( bestfit ); 579 580 mc.entityclass = bestfit.entity 581 mc.property = bestfit.name 582 } 583 } 584 585 // Save read excel data into session 586 def dataMatrix = []; 587 def df = new DataFormatter(); 588 importerDataMatrix.each { 589 dataMatrix << it.collect{ it ? df.formatCellValue(it) : "" } 590 } 591 592 flow.excel = [ 593 filename: filename, 594 sheetIndex: sheetIndex, 595 dataMatrixStart: dataMatrixStart, 596 headerRow: headerRow, 597 data: [ 598 header: importerHeader, 599 dataMatrix: dataMatrix 600 ] 601 ] 602 603 return true 604 } 605 606 /** 607 * Copies data from the submitted sample form to the flow 608 * @param study 609 * @param params 610 * @param flow 611 * @return 612 */ 613 protected def handleSampleForm( study, params, flow ) { 614 def sampleTemplateId = params.long( 'sample_template_id' ) 615 def subjectTemplateId = params.long( 'subject_template_id' ) 616 def eventTemplateId = params.long( 'event_template_id' ) 617 def samplingEventTemplateId = params.long( 'samplingEvent_template_id' ) 481 618 482 619 // Save form data in session 483 620 flow.sampleForm = [ 484 importFile: filename,485 621 templateId: [ 486 622 'Sample': sampleTemplateId, … … 495 631 'SamplingEvent': samplingEventTemplateId ? Template.get( samplingEventTemplateId ) : null 496 632 ], 497 sheetIndex: sheetIndex,498 dataMatrixStart: dataMatrixStart,499 headerRow: headerRow500 633 ]; 501 502 // Check whether the template exists503 if (!sampleTemplateId || !Template.get( sampleTemplateId ) ){504 log.error ".simple study wizard not all fields are filled in: " + sampleTemplateId505 flash.error = "No template was chosen. Please choose a template for the samples you provided."506 return false507 }508 509 def importedfile = fileService.get( filename )510 def workbook511 if (importedfile.exists()) {512 try {513 workbook = importerService.getWorkbook(new FileInputStream(importedfile))514 } catch (Exception e) {515 log.error ".simple study wizard could not load file: " + e516 flash.error = "The given file doesn't seem to be an excel file. Please provide an excel file for entering samples.";517 return false518 }519 } else {520 log.error ".simple study wizard no file given";521 flash.error = "No file was given. Please provide an excel file for entering samples.";522 return false;523 }524 525 if( !workbook ) {526 log.error ".simple study wizard could not load file into a workbook"527 flash.error = "The given file doesn't seem to be an excel file. Please provide an excel file for entering samples.";528 return false529 }530 531 def selectedentities = []532 533 if( !excelChecks( workbook, sheetIndex, headerRow, dataMatrixStart ) )534 return false;535 536 // Get the header from the Excel file using the arguments given in the first step of the wizard537 def importerHeader;538 def importerDataMatrix;539 540 try {541 importerHeader = importerService.getHeader(workbook,542 sheetIndex - 1, // 0 == first sheet543 headerRow, // 1 == first row :s544 dataMatrixStart - 1, // 0 == first row545 Sample.class)546 547 importerDataMatrix = importerService.getDatamatrix(548 workbook,549 importerHeader,550 sheetIndex - 1, // 0 == first sheet551 dataMatrixStart - 1, // 0 == first row552 5)553 } catch( Exception e ) {554 // An error occurred while reading the excel file.555 log.error ".simple study wizard error while reading the excel file";556 e.printStackTrace();557 558 // Show a message to the user559 flash.error = "An error occurred while reading the excel file. Have you provided the right sheet number and row numbers. Contact your system administrator if this problem persists.";560 return false;561 }562 563 // Match excel columns with template fields564 def fieldNames = [];565 flow.sampleForm.template.each { template ->566 if( template.value ) {567 def fields = template.value.entity.giveDomainFields() + template.value.getFields();568 fields.each { field ->569 if( !field.entity )570 field.entity = template.value.entity571 572 fieldNames << field573 }574 }575 }576 importerHeader.each { mc ->577 def bestfit = importerService.mostSimilar( mc.name, fieldNames, 0.8);578 if( bestfit ) {579 // Remove this fit from the list580 fieldNames.remove( bestfit );581 582 mc.entityclass = bestfit.entity583 mc.property = bestfit.name584 }585 }586 587 // Save read excel data into session588 def dataMatrix = [];589 def df = new DataFormatter();590 importerDataMatrix.each {591 dataMatrix << it.collect{ it ? df.formatCellValue(it) : "" }592 }593 594 flow.excel = [595 filename: filename,596 sheetIndex: sheetIndex,597 dataMatrixStart: dataMatrixStart,598 headerRow: headerRow,599 data: [600 header: importerHeader,601 dataMatrix: dataMatrix602 ]603 ]604 605 return true606 634 } 607 608 635 609 636 /** -
trunk/grails-app/views/simpleWizard/simpleWizard/assays.gsp
r1608 r1678 8 8 </head> 9 9 <body> 10 <div class="simpleWizard ">10 <div class="simpleWizard assayspage"> 11 11 <h1>Assay</h1> 12 12 … … 46 46 47 47 <g:if test="${assay}"> 48 <g:if test="${assay.template?.description}"> 49 <div class="element"> 50 <div class="templatedescription"> 51 ${assay.template?.description?.encodeAsHTML()} 52 </div> 53 </div> 54 </g:if> 48 55 <af:templateElements ignore="externalassayid" entity="${assay}" /> 49 56 </g:if> -
trunk/grails-app/views/simpleWizard/simpleWizard/existingSamples.gsp
r1608 r1678 57 57 <g:if test="${entity.value}"> 58 58 <div class="column">${entity.key} template</div> 59 <af:templateColumnHeaders entity="${entity.value}" class="column" columnWidths="[Name:100]"/>59 <af:templateColumnHeaders includeEntities="${true}" entity="${entity.value}" class="column" columnWidths="[Name:100]"/> 60 60 </g:if> 61 61 </g:each> -
trunk/grails-app/views/simpleWizard/simpleWizard/missingFields.gsp
r1610 r1678 64 64 <g:each var="entity" in="${record}"> 65 65 <g:if test="${entity}"> 66 <af:templateColumnHeaders entity="${entity}" class="column" columnWidths="[Name:100]"/>66 <af:templateColumnHeaders includeEntities="${true}" entity="${entity}" class="column" columnWidths="[Name:100]"/> 67 67 </g:if> 68 68 </g:each> -
trunk/grails-app/views/simpleWizard/simpleWizard/samples.gsp
r1668 r1678 10 10 </head> 11 11 <body> 12 <div class="simpleWizard ">13 <h1>S amples</h1>12 <div class="simpleWizard samplespage"> 13 <h1>Study data</h1> 14 14 15 15 <g:if test="${flash.error}"> … … 29 29 <div id="samplesDialog"> 30 30 <span class="info"> 31 <span class="title">Import s ampledata</span>31 <span class="title">Import study data</span> 32 32 You can import your Excel data to the server by choosing a file from your local harddisk in the form below. The excel sheet should contain 33 33 data on the first sheet, and the sheet should contain one row with headers. … … 36 36 <table border="0"> 37 37 <tr> 38 <td width="100px"> 39 Choose your Excel file to import: 40 </td> 41 <td width="100px"> 42 <af:fileField name="importfile" value="${sampleForm?.importFile}"/> 43 </td> 38 <td width="30%"> 39 Choose your Excel file to import: 40 </td> 41 <td width="25%"> 42 <af:fileField name="importfile" value="${sampleForm?.importFile}"/> 43 </td> 44 <td width="40%"></td> 44 45 </tr> 45 46 <tr> … … 48 49 </td> 49 50 <td> 50 <g:select rel="template" entity="${encodedEntity.Sample}" name="sample_template_id" optionKey="id" optionValue="name" from="${templates.Sample}" value="${sampleForm?.templateId?.Sample}"/> 51 <% /* The select is written manually, since the grails select tag can't handle option titles */ %> 52 <select rel="template" entity="${encodedEntity.Sample}" onChange="showTemplateDescription( 'templateDescription_sample', $( 'option:selected', $(this) ).attr( 'title' ) ); " name="sample_template_id"> 53 <g:each in="${templates.Sample}" var="templ"> 54 <option 55 value="${templ.id}" 56 <g:if test="${templ.id == sampleForm?.templateId?.Sample}">selected="selected"</g:if> 57 title="${templ.description?.encodeAsHTML()}" 58 >${templ.name?.encodeAsHTML()}</option> 59 </g:each> 60 </select> 61 </td> 62 <td> 63 <% 64 def sampleTemplate = sampleForm?.template?.Sample ?: templates.Sample?.getAt(0) 65 def sampleTemplateDescription = sampleTemplate?.description 66 %> 67 <div class="templatedescription" id="templateDescription_sample" <g:if test="${!sampleTemplateDescription}">style="display: none;"</g:if>> 68 ${sampleTemplateDescription?.encodeAsHTML()} 69 </div> 51 70 </td> 52 71 </tr> … … 56 75 </td> 57 76 <td> 58 <g:select rel="template" entity="${encodedEntity.Subject}" name="subject_template_id" noSelection="${[null: '- no subject template -']}" optionKey="id" optionValue="name" from="${templates.Subject}" value="${sampleForm?.templateId?.Subject}" /> 77 <% /* The select is written manually, since the grails select tag can't handle option titles */ %> 78 <select rel="template" entity="${encodedEntity.Subject}" onChange="showTemplateDescription( 'templateDescription_subject', $( 'option:selected', $(this) ).attr( 'title' ) ); " name="subject_template_id"> 79 <option value="">- no subject template -</option> 80 <g:each in="${templates.Subject}" var="templ"> 81 <option 82 value="${templ.id}" 83 <g:if test="${templ.id == sampleForm?.templateId?.Subject}">selected="selected"</g:if> 84 title="${templ.description?.encodeAsHTML()}" 85 >${templ.name?.encodeAsHTML()}</option> 86 </g:each> 87 </select> 59 88 </td> 89 <td> 90 <% 91 def subjectTemplateDescription = sampleForm?.template?.Subject?.description 92 %> 93 <div class="templatedescription" id="templateDescription_subject" <g:if test="${!subjectTemplateDescription}">style="display: none;"</g:if>> 94 ${subjectTemplateDescription?.encodeAsHTML()} 95 </div> 96 </td> 60 97 </tr> 61 98 <tr> … … 64 101 </td> 65 102 <td> 66 <g:select rel="template" entity="${encodedEntity.Event}" name="event_template_id" noSelection="${[null: '- no event template -']}" optionKey="id" optionValue="name" from="${templates.Event}" value="${sampleForm?.templateId?.Event}" /> 103 <% /* The select is written manually, since the grails select tag can't handle option titles */ %> 104 <select rel="template" entity="${encodedEntity.Event}" onChange="showTemplateDescription( 'templateDescription_event', $( 'option:selected', $(this) ).attr( 'title' ) ); " name="event_template_id"> 105 <option value="">- no event template -</option> 106 <g:each in="${templates.Event}" var="templ"> 107 <option 108 value="${templ.id}" 109 <g:if test="${templ.id == sampleForm?.templateId?.Event}">selected="selected"</g:if> 110 title="${templ.description?.encodeAsHTML()}" 111 >${templ.name?.encodeAsHTML()}</option> 112 </g:each> 113 </select> 67 114 </td> 115 <td> 116 <% 117 def eventTemplateDescription = sampleForm?.template?.Event?.description 118 %> 119 <div class="templatedescription" id="templateDescription_event" <g:if test="${!eventTemplateDescription}">style="display: none;"</g:if>> 120 ${eventTemplateDescription?.encodeAsHTML()} 121 </div> 122 </td> 68 123 </tr> 69 124 <tr> … … 72 127 </td> 73 128 <td> 74 <g:select rel="template" entity="${encodedEntity.SamplingEvent}" name="samplingEvent_template_id" noSelection="${[null: '- no sampling event template -']}" optionKey="id" optionValue="name" from="${templates.SamplingEvent}" value="${sampleForm?.templateId?.SamplingEvent}" /> 129 <% /* The select is written manually, since the grails select tag can't handle option titles */ %> 130 <select rel="template" entity="${encodedEntity.SamplingEvent}" onChange="showTemplateDescription( 'templateDescription_samplingEvent', $( 'option:selected', $(this) ).attr( 'title' ) ); " name="samplingEvent_template_id"> 131 <option value="">- no sampling event template -</option> 132 <g:each in="${templates.SamplingEvent}" var="templ"> 133 <option 134 value="${templ.id}" 135 <g:if test="${templ.id == sampleForm?.templateId?.SamplingEvent}">selected="selected"</g:if> 136 title="${templ.description?.encodeAsHTML()}" 137 >${templ.name?.encodeAsHTML()}</option> 138 </g:each> 139 </select> 75 140 </td> 141 <td> 142 <% 143 def samplingEventTemplateDescription = sampleForm?.template?.SamplingEvent?.description 144 %> 145 <div class="templatedescription" id="templateDescription_samplingEvent" <g:if test="${!samplingEventTemplateDescription}">style="display: none;"</g:if>> 146 ${samplingEventTemplateDescription?.encodeAsHTML()} 147 </div> 148 </td> 76 149 </tr> 77 150 </table> -
trunk/grails-app/views/simpleWizard/simpleWizard/study.gsp
r1608 r1678 8 8 </head> 9 9 <body> 10 <div class="simpleWizard ">10 <div class="simpleWizard studypage"> 11 11 <h1>Study</h1> 12 12 … … 82 82 83 83 <g:if test="${study}"> 84 <g:if test="${study.template?.description}"> 85 <div class="element"> 86 <div class="templatedescription"> 87 ${study.template?.description?.encodeAsHTML()} 88 </div> 89 </div> 90 </g:if> 84 91 <af:templateElements ignore="published" entity="${study}" /> 85 92 </g:if> -
trunk/web-app/css/simplewizard.css
r1565 r1678 25 25 .simpleWizard div ul.user_list { margin: -22px 0 0 100px; } 26 26 27 /* template descriptions */ 28 .templatedescription { display: block; padding: 3px; border: 1px solid #4CAAED; /* #006DBA; */ } 29 .studypage .templatedescription, .assayspage .templatedescription{ width: 222px; margin: 5px 0 5px 174px; } 30 .samplespage .templatedescription { width: 300px; } 31 27 32 /* .simpleWizard .publication_list li .authors { overflow: hidden; max-height: 8px; text-overflow:ellipsis; } */ 28 33 … … 38 43 .simpleWizard .importcolumns { position: relative; width: 100%; overflow: auto; border: 1px solid #ccc; } 39 44 .simpleWizard .importcolumns table { border-width: 0; } 45 46 /** MISSING FIELDS PAGE / TABLE EDITOR **/ 47 .simpleWizard .tableEditor .header { height: auto; line-height: 15px; } 48 .simpleWizard .tableEditor .fieldname { display: inline-block; *display: inline; zoom: 1; } -
trunk/web-app/js/simpleWizard.js
r1601 r1678 58 58 element = $("input[name=" + cellname + "]"); 59 59 element.addClass('error') 60 } 61 62 /** 63 * Shows the description of a selected template in a div. The div is hidden if no description is given 64 */ 65 function showTemplateDescription( id, description ) { 66 var el = $( '#' + id ); 60 67 61 68 if( !description || description == "" ) { 69 el.hide(); 70 } else { 71 el.text( description ); 72 el.show(); 73 } 62 74 }
Note: See TracChangeset
for help on using the changeset viewer.