Changeset 1141

Show
Ignore:
Timestamp:
15-11-10 23:10:37 (3 years ago)
Author:
t.w.abma@…
Message:

- added fuzzy matching to importer tag library

Location:
trunk/grails-app
Files:
4 modified

Legend:

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

    r1140 r1141  
    111111 
    112112            def templates = Template.get(session.importer_template_id) 
    113          
     113 
    114114            render(view:"step2_simple", model:[entities: selectedentities, 
    115115                                        header:session.importer_header, 
  • trunk/grails-app/services/dbnp/importer/ImporterService.groovy

    r1126 r1141  
    538538    } 
    539539 
    540     static def stringSimilarity (l_str, r_str, degree=2) { 
     540    static def stringSimilarity (l_str, r_str, degree=2) {         
    541541        similarity(l_str.toLowerCase().toCharArray(), 
    542542            r_str.toLowerCase().toCharArray(), 
  • 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 
  • trunk/grails-app/views/importer/common/_properties_horizontal.gsp

    r959 r1141  
    2424                            <td class="header" width="200px"> 
    2525                                <b>${header[selentity.columnindex.toInteger()].name}</b> 
    26                                 <importer:propertyChooser name="columnproperty" mappingcolumn="${header[selentity.columnindex.toInteger()]}" allfieldtypes="${allfieldtypes}"/> 
     26                                <importer:propertyChooser name="columnproperty" mappingcolumn="${header[selentity.columnindex.toInteger()]}" matchvalue="test" "allfieldtypes="${allfieldtypes}"/> 
    2727                            </td>                                        
    2828                    </g:if>