Changeset 489
- Timestamp:
- May 27, 2010, 4:26:44 PM (11 years ago)
- Location:
- trunk/grails-app
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy
r485 r489 73 73 def upload_simple = { 74 74 def wb = handleUpload('importfile') 75 def selectedentities = [] 75 76 def entity = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity 76 def entityClass = Class.forName(entity, true, this.getClass().getClassLoader()) 77 def entityClass = Class.forName(entity, true, this.getClass().getClassLoader()) 77 78 78 79 session.importer_header = ImporterService.getHeader(wb, 0, entityClass) … … 80 81 session.importer_workbook = wb 81 82 83 session.importer_header.each { 84 selectedentities.add([name:params.entity, columnindex:it.key.toInteger()]) 85 } 86 82 87 //import workbook 83 88 //session.importer_importeddata = ImporterService.importdata(session.importer_template_id, session.importer_workbook, 0, 1, session.importer_header) … … 88 93 def templates = Template.get(session.importer_template_id) 89 94 90 render(view:"step2", model:[entities: entities, header:session.importer_header, templates:templates])95 render(view:"step2", model:[entities: selectedentities, header:session.importer_header, templates:templates]) 91 96 } 92 97 -
trunk/grails-app/services/dbnp/importer/ImporterService.groovy
r485 r489 68 68 switch (datamatrix_celltype) { 69 69 case HSSFCell.CELL_TYPE_STRING: 70 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING, index:index, entity:theEntity, property:property); 70 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), 71 templatefieldtype:TemplateFieldType.STRING, 72 index:index, 73 entity:theEntity, 74 property:property); 71 75 break 72 76 case HSSFCell.CELL_TYPE_NUMERIC: 73 77 if (HSSFDateUtil.isCellDateFormatted(c)) { 74 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.DATE, index:index, entity:theEntity, property:property) 78 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), 79 templatefieldtype:TemplateFieldType.DATE, 80 index:index, 81 entity:theEntity, 82 property:property) 75 83 } 76 84 else 77 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.INTEGER,index:index, entity:theEntity, property:property); 85 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), 86 templatefieldtype:TemplateFieldType.INTEGER, 87 index:index, 88 entity:theEntity, 89 property:property); 78 90 break 79 91 case HSSFCell.CELL_TYPE_BLANK: 80 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING, index:index, entity:theEntity, property:property); 92 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), 93 templatefieldtype:TemplateFieldType.STRING, 94 index:index, 95 entity:theEntity, 96 property:property); 81 97 break 82 98 default: 83 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), templatefieldtype:TemplateFieldType.STRING,index:index, entity:theEntity, property:property); 99 header[index] = new dbnp.importer.MappingColumn(name:df.formatCellValue(headercell), 100 templatefieldtype:TemplateFieldType.STRING, 101 index:index, 102 entity:theEntity, 103 property:property); 84 104 break 85 105 } -
trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy
r485 r489 56 56 def header = attrs['header'] 57 57 def entities = attrs['entities'] 58 def allfieldtypes = (attrs['allfieldtypes']==null) ? "false" : "true" 59 println attrs['allfieldtypes'] 58 60 59 61 out << render ( template:"common/properties", 60 62 model:[selectedentities:entities, 61 63 standardentities:grailsApplication.config.gscf.domain.importableEntities, 62 header:header]) 64 header:header, 65 allfieldtypes:allfieldtypes] 66 ) 63 67 } 64 68 … … 69 73 * @param importtemplate_id template identifier where fields are retrieved from 70 74 * @param MappingColumn object containing all required information 75 * @param allfieldtypes boolean true if all templatefields should be listed, otherwise only show filtered templatefields 71 76 * @return chooser object 72 77 * */ … … 77 82 def t = Template.get(session.importer_template_id) 78 83 def mc = attrs['mappingcolumn'] 84 def allfieldtypes = attrs['allfieldtypes'] 85 86 def templatefields = (allfieldtypes=="true") ? t.fields.list() : t.fields.findAll { it.type == mc.templatefieldtype } 79 87 80 88 (mc.identifier) ? out << "<select style=\"font-size:10px\" name=\"\" disabled><option>Identifier</option></select>": 81 out << createPropertySelect(attrs['name'], t .fields.findAll { it.type == mc.templatefieldtype }, mc.index)89 out << createPropertySelect(attrs['name'], templatefields, mc.index) 82 90 } 83 91 -
trunk/grails-app/views/importer/common/_properties.gsp
r485 r489 16 16 <p><g:select name="study.id" from="${dbnp.studycapturing.Study.list()}" optionKey="id" class="selectsmall"/></p> 17 17 <table> 18 <g:each var="stdentity" in ="${standardentities}"> 19 <% if (selectedentities.any { it.name == stdentity.value.name } && stdentity.value.name!="") { %> 18 <g:each var="stdentity" in ="${standardentities}"> 19 20 <% if (selectedentities.any { it.name.toLowerCase() == stdentity.value.name.toLowerCase() } && stdentity.value.name!="") { %> 20 21 <tr><td colspan="2"><h4>${stdentity.value.name}</h4></td></tr> 21 22 <tr> … … 24 25 </tr> 25 26 <g:each var="selentity" in="${selectedentities}"> 26 <g:if test="${selentity.name==stdentity.value.name}"> 27 28 <g:if test="${selentity.name.toLowerCase()==stdentity.value.name.toLowerCase()}"> 27 29 <tr> 28 30 <td class="header" width="200px"> 29 31 <b>${header[selentity.columnindex.toInteger()].name}</b> 30 32 </td> 31 <td> 32 <importer:propertyChooser name="columnproperty" mappingcolumn="${header[selentity.columnindex.toInteger()]}" />33 <td> 34 <importer:propertyChooser name="columnproperty" mappingcolumn="${header[selentity.columnindex.toInteger()]}" allfieldtypes="${allfieldtypes}"/> 33 35 </td> 34 36 </tr> -
trunk/grails-app/views/importer/step2_simple.gsp
r485 r489 27 27 <p>The next step is to assign properties to the columns. Below you see the columns, please assign every column to 28 28 a property.</p> 29 <importer:properties entities="${entities}" header="${header}" templates="${templates}" />29 <importer:properties entities="${entities}" header="${header}" templates="${templates}" allfieldtypes="true"/> 30 30 </body> 31 31 </html>
Note: See TracChangeset
for help on using the changeset viewer.