Changeset 1505


Ignore:
Timestamp:
Feb 8, 2011, 3:53:49 PM (7 years ago)
Author:
t.w.abma@…
Message:
  • fuzzy matching and don't import improved in the properties step of the importer wizard, by default properties are not matched against the Excel fields, but one can now manually apply fuzzy matching
  • added initial fields to ImportMapping? domain
Location:
trunk/grails-app
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy

    r1502 r1505  
    106106                                flow.page = 1
    107107                                flow.studies = Study.findAllWhere(owner: authenticationService.getLoggedInUser())
     108                flow.importer_fuzzymatching="false"
    108109
    109110                                success()
     
    150151                                success()
    151152                        }
     153            on("refresh") {
     154                flow.importer_fuzzymatching="true"
     155                                success()
     156                        }.to "pageTwo"
     157
    152158                        on("next") {
    153159                                if (propertiesPage(flow, flash, params)) {
  • trunk/grails-app/domain/dbnp/importer/ImportMapping.groovy

    r1430 r1505  
    11package dbnp.importer
     2import org.dbnp.gdt.*
    23
    34class ImportMapping implements Serializable {
    45
    5         static hasMany = [columns: MappingColumn]
    6         static String t
     6        static hasMany = [columns: MappingColumn]   
     7    Template template
     8    Class entity
     9        String name
     10
    711
    812        static constraints = {
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r1481 r1505  
    9494         * @param matchvalue value which will be looked up via fuzzy matching against the list of options and will be selected
    9595         * @param MappingColumn object containing all required information
     96     * @param fuzzymatching boolean true if fuzzy matching should be used, otherwise false
    9697         * @param allfieldtypes boolean true if all templatefields should be listed, otherwise only show filtered templatefields
    9798         * @return chooser object
     
    103104                def t = Template.get(attrs['template_id'])
    104105                def mc = attrs['mappingcolumn']
    105                 def allfieldtypes = attrs['allfieldtypes']
    106                 def matchvalue = attrs['matchvalue']
    107                 def domainfields = mc.entity.giveDomainFields().findAll { it.type == mc.templatefieldtype }
     106                def allfieldtypes = attrs['allfieldtypes']             
     107        def matchvalue = (attrs['fuzzymatching']=="true") ? attrs['matchvalue'] : ""
     108
     109        def domainfields = mc.entity.giveDomainFields().findAll { it.type == mc.templatefieldtype }
    108110                domainfields = domainfields.findAll { it.preferredIdentifier != mc.identifier}
    109111
     
    133135        def createPropertySelect(String name, options, matchvalue, Integer columnIndex) {
    134136                // Determine which field in the options list matches the best with the matchvalue
    135                 def mostsimilar = ImporterService.mostSimilar(matchvalue, options)
     137                def mostsimilar = (matchvalue) ? ImporterService.mostSimilar(matchvalue, options) : ""
    136138
    137139                def res = "<select style=\"font-size:10px\" id=\"${name}.index.${columnIndex}\" name=\"${name}.index.${columnIndex}\">"
  • trunk/grails-app/views/importer/common/_on_page.gsp

    r1489 r1505  
    4343                        return false;
    4444                });
     45
     46         $('#fuzzymatchselect').click(function() {
     47            refreshFlow()
     48          });
     49
     50          // attach function to clear button to reset all selects to "don't import"
     51          $('#clearselect').click(function() {
     52            // for each select field on the page
     53            $("select").each( function(){
     54            // set its value to its first option
     55            $(this).val($('option:first', this).val());
     56            });
     57          });
    4558        }
    4659
  • trunk/grails-app/views/importer/common/_properties_horizontal.gsp

    r1480 r1505  
    4141});
    4242
    43 $('#clearselect').click(function() {
    44 
    45   // for each select field on the page
    46   $("select").each( function(){
    47     // set its value to its first option
    48     $(this).val($('option:first', this).val());
    49   });
    50 
    51 });
    5243
    5344
    5445});
    5546</script>
    56 <!-- saveproperties action was defined in the form --> 
     47<!-- saveproperties action was defined in the form -->
    5748    <table>
    5849          <g:each var="stdentity" in ="${GdtService.cachedEntities}">
     
    6152              <tr><td colspan="3"><h4>${stdentity.name}</h4></td></tr>
    6253                <tr>
    63             <td class="header" width="25px"><input id="clearselect" type="button" value="clear" name="clearselect"></td>
     54            <td class="header" width="25px"><input id="clearselect" type="button" value="Clear" name="clearselect">
     55              <input id="fuzzymatchselect" type="button" value="Match" name="fuzzymatchselect">
     56            </td>
    6457            <g:each var="selentity" in="${importer_selectedentities}">
    6558              <g:if test="${selentity.name.toLowerCase()==stdentity.entity.toLowerCase()}">
    6659                            <td class="header" width="200px">
    6760                                <b>${importer_header[selentity.columnindex.toInteger()].name}</b>
    68                   <importer:propertyChooser name="columnproperty" mappingcolumn="${importer_header[selentity.columnindex.toInteger()]}" matchvalue="${importer_header[selentity.columnindex.toInteger()].name}" template_id="${importer_template_id}" allfieldtypes="true"/>
     61                  <importer:propertyChooser name="columnproperty" mappingcolumn="${importer_header[selentity.columnindex.toInteger()]}" matchvalue="${importer_header[selentity.columnindex.toInteger()].name}" fuzzymatching="${importer_fuzzymatching}" template_id="${importer_template_id}" allfieldtypes="true"/>
    6962                            </td>                                       
    7063              </g:if>
Note: See TracChangeset for help on using the changeset viewer.