Ignore:
Timestamp:
Mar 23, 2010, 1:57:18 PM (13 years ago)
Author:
tabma
Message:
  • templatefieldtypes chosen in the preview page are used as a filter for the properties page (so only matches between the columns/properties can be made if they are of the equal templatefieldtype)
  • columns in the preview which are not imported and/or entities which are not used are not shown anymore in the properties-assignment step in the wizard
File:
1 edited

Legend:

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

    r299 r305  
    1919import org.apache.poi.hssf.usermodel.HSSFCell
    2020import org.apache.poi.ss.usermodel.DataFormatter
     21import dbnp.studycapturing.Study
     22import dbnp.studycapturing.Subject
     23import dbnp.studycapturing.Event
     24import dbnp.studycapturing.Protocol
     25import dbnp.studycapturing.Sample
    2126
    2227class ImporterTagLib {
     
    7277     *
    7378     * @param importtemplate_id template identifier where fields are retrieved from
    74      * @param columnindex column in the header we're talking about
     79     * @param MappingColumn object containing all required information
    7580     * @return chooser object
    7681     * */
    7782    def propertyChooser = { attrs ->
    78         // TODO: this should be changed to retrieving fields per entity
    79         def t = Template.get(session.importtemplate_id)
    80         def columnindex = attrs['columnindex']
     83        // TODO: this should be changed to retrieving fields per entity instead of from one template
     84        //       and session variables should not be used inside the service, migrate to controller
    8185
    82         switch (attrs['entitytype']) {
    83             case 0  : createPropertySelect(attrs['name'], t.fields, columnindex)
    84                       break
    85             case 1  : break
    86             case 2  : break
    87             case 3  : break
    88             default : out << createPropertySelect(attrs['name'], t.fields, columnindex)
    89                      break
    90         }
     86        def t = Template.get(session.importtemplate_id)
     87        def mc = attrs['mappingcolumn']
     88       
     89        out << createPropertySelect(attrs['name'], t.fields.findAll { it.type == mc.templatefieldtype }, mc.index)
    9190    }
    9291
    9392    /**
    9493     * @param name name of the HTML select object
    95      * @param options list of options to be used
     94     * @param options list of options (fields) to be used
    9695     * @param columnIndex column identifier (corresponding to position in header of the Excel sheet)
    9796     * @return HTML select object
    9897     */
    99     def createPropertySelect(String name, options, String columnIndex)
    100     {
     98    def createPropertySelect(String name, options, Integer columnIndex)
     99    {   
    101100        def res = "<select style=\"font-size:10px\" name=\"${name}\">"
    102101
    103         options.each { f ->
     102        options.each { f ->         
    104103            res += "<option value=\"${columnIndex}:${f.id}\""
    105104            //res += (e.type.toInteger() == selected) ? " selected" : ""
Note: See TracChangeset for help on using the changeset viewer.