Ignore:
Timestamp:
Nov 15, 2010, 11:10:37 PM (10 years ago)
Author:
t.w.abma@…
Message:
  • added fuzzy matching to importer tag library
File:
1 edited

Legend:

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

    r1087 r1141  
    2222class ImporterTagLib {
    2323    static namespace = 'importer'
     24    def ImporterService
    2425
    2526    /**
     
    100101     * @param name name for the property chooser element
    101102     * @param importtemplate_id template identifier where fields are retrieved from
     103     * @param matchvalue value which will be looked up via fuzzy matching against the list of options and will be selected
    102104     * @param MappingColumn object containing all required information
    103105     * @param allfieldtypes boolean true if all templatefields should be listed, otherwise only show filtered templatefields
     
    111113        def mc = attrs['mappingcolumn']
    112114        def allfieldtypes = attrs['allfieldtypes']
     115        def matchvalue = attrs['matchvalue']
    113116        def domainfields = mc.entity.giveDomainFields().findAll { it.type == mc.templatefieldtype }
    114117            domainfields = domainfields.findAll { it.preferredIdentifier != mc.identifier}
     
    122125        def prefcolumn = mc.entity.giveDomainFields().findAll { it.preferredIdentifier == true }
    123126
    124         (mc.identifier) ? out << createPropertySelect(attrs['name'], prefcolumn, mc.index) :
    125             out << createPropertySelect(attrs['name'], templatefields, mc.index)
     127        (mc.identifier) ? out << createPropertySelect(attrs['name'], prefcolumn, matchvalue, mc.index) :
     128            out << createPropertySelect(attrs['name'], templatefields, matchvalue, mc.index)
    126129    }
    127130
     
    131134     * @param name name of the HTML select object
    132135     * @param options list of options (fields) to be used
     136     * @param matchvalue value which will be looked up via fuzzy matching against the list of options and will be selected
    133137     * @param columnIndex column identifier (corresponding to position in header of the Excel sheet)
    134138     * @return HTML select object
    135139     */
    136     def createPropertySelect(String name, options, Integer columnIndex)
    137     {   
     140    def createPropertySelect(String name, options, matchvalue, Integer columnIndex)
     141    {
     142        //String.metaClass.mostSimilarTo = { ImporterService.mostSimilar(delegate, it) }
     143        //println "mostsimilar="+ImporterService.mostSimilar(matchvalue, options)
     144
    138145        def res = "<select style=\"font-size:10px\" name=\"${name}.index.${columnIndex}\">"
    139146
Note: See TracChangeset for help on using the changeset viewer.