Changeset 1552


Ignore:
Timestamp:
Feb 23, 2011, 1:25:46 PM (12 years ago)
Author:
t.w.abma@…
Message:
  • duplicate fuzzymatched properties fixed, when a fuzzy match has been used for a property, the next properties having the same fuzzy match will be put on "don't import"
Location:
trunk/grails-app
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/taglib/dbnp/importer/ImporterTagLib.groovy

    r1548 r1552  
    111111        def selected = (attrs['selected']) ? attrs['selected'] : ""
    112112                def fuzzyTreshold = attrs[ 'treshold' ] && attrs[ 'treshold' ].toString().isNumber() ? Float.valueOf( attrs[ 'treshold' ] ) : 0.1;
    113 
     113        def returnmatchonly = attrs['returnmatchonly']
     114       
    114115        def domainfields = mc.entityclass.giveDomainFields().findAll { it.type == mc.templatefieldtype }
    115116                domainfields = domainfields.findAll { it.preferredIdentifier != mc.identifier}
     
    126127                /*(mc.identifier) ? out << createPropertySelect(attrs['name'], prefcolumn, matchvalue, mc.index) :
    127128                        out << createPropertySelect(attrs['name'], templatefields, matchvalue, mc.index)*/
    128                
    129          out << createPropertySelect(attrs['name'], templatefields, matchvalue, selected, mc.index, fuzzyTreshold)
     129
     130        //  Just return the matched value only
     131        if (returnmatchonly)
     132            out << ImporterService.mostSimilar(matchvalue, templatefields, fuzzyTreshold)
     133        else // Return a selectbox
     134            out << createPropertySelect(attrs['name'], templatefields, matchvalue, selected, mc.index, fuzzyTreshold)
     135
    130136        }
    131137
  • trunk/grails-app/views/importer/common/_properties_horizontal.gsp

    r1525 r1552  
    3636                <g:select name="importmapping_id" from="${importer_importmappings}" noSelection="['':'-Select mapping-']" optionValue="name" optionKey="id"/>
    3737              </div>
    38             </td>           
     38            </td>
     39           
     40            <g:set var="usedfuzzymatches" value="${'-'}"/>
     41
    3942            <g:each var="mappingcolumn" in="${importer_header}">
    4043              <!-- set selected values based on submitted columnproperties, actually refresh -->
     
    4649              </g:else>
    4750
     51              <g:set var="matchvalue" value="${mappingcolumn.name}"/>
     52
    4853                          <td class="header" width="200px">
    4954                                <b>${mappingcolumn.name}</b>
    50                   <importer:propertyChooser name="columnproperty" mappingcolumn="${mappingcolumn}" matchvalue="${mappingcolumn.name}" selected="${selected}" fuzzymatching="${importer_fuzzymatching}" template_id="${importer_template_id}" "allfieldtypes="true"/>
    51                           </td>                                 
     55
     56                <!-- store the found match -->
     57                <g:set var="fuzzymatch" value="${importer.propertyChooser(name:columnproperty, mappingcolumn:mappingcolumn, matchvalue:mappingcolumn.name, selected:selected, fuzzymatching:importer_fuzzymatching, template_id:importer_template_id, returnmatchonly:'true')}"/>
     58 
     59                  <g:if test="${usedfuzzymatches.contains( fuzzymatch.toString() ) }">                       
     60                       <g:set var="matchvalue" value=""/>
     61                  </g:if>                 
     62               
     63                  <importer:propertyChooser name="columnproperty" mappingcolumn="${mappingcolumn}" matchvalue="${matchvalue}" selected="${selected}" fuzzymatching="${importer_fuzzymatching}" template_id="${importer_template_id}" allfieldtypes="true"/>
     64                          </td>
     65
     66              <!-- build up a string with fuzzy matches used, to prevent duplicate fuzzy matching -->
     67              <g:set var="usedfuzzymatches" value="${usedfuzzymatches + ',' + fuzzymatch.toString() }"/>
     68
    5269            </g:each>
    5370                </tr>
Note: See TracChangeset for help on using the changeset viewer.