コード例 #1
0
 def check(my):
     #search_type_obj = SearchType.get(my.search_type)
     columns = SearchType.get_columns(my.search_type)
     if my.attr_name not in columns:
         raise TacticException('[%s] does not exist in this table [%s]' %
                               (my.attr_name, my.search_type))
     return True
コード例 #2
0
    def copy_sobject(my,
                     sobject,
                     dst_search_type,
                     context=None,
                     checkin_mode='inplace'):

        new_sobject = SearchType.create(dst_search_type)
        search_type = SearchType.get(dst_search_type)
        columns = SearchType.get_columns(dst_search_type)

        data = sobject.get_data()
        for name, value in data.items():
            if name in ['id', 'code', 'pipeline_code']:
                continue

            if name not in columns:
                continue

            if not value:
                continue
            new_sobject.set_value(name, value)

        new_sobject.commit()

        # get all of the current snapshots and file paths associated
        if not context:
            snapshots = Snapshot.get_all_current_by_sobject(sobject)
        else:
            snapshots = [Snapshot.get_current_by_sobject(sobject, context)]

        if not snapshots:
            return

        msgs = []
        for snapshot in snapshots:
            #file_paths = snapshot.get_all_lib_paths()
            file_paths_dict = snapshot.get_all_paths_dict()
            file_types = file_paths_dict.keys()
            if not file_types:
                continue

            # make sure the paths match the file_types
            file_paths = [file_paths_dict.get(x)[0] for x in file_types]

            mode = checkin_mode

            # checkin the files (inplace)
            try:
                context = snapshot.get_value('context')
                checkin = FileCheckin(new_sobject,
                                      context=context,
                                      file_paths=file_paths,
                                      file_types=file_types,
                                      mode=mode)
                checkin.execute()

                #print "done: ", context, new_sobject.get_related_sobjects("sthpw/snapshot")
            except CheckinException, e:
                msgs.append('Post-process Check-in Error for %s: %s ' %
                            (context, e.__str__()))
コード例 #3
0
ファイル: sobject_copy_cmd.py プロジェクト: 0-T-0/TACTIC
    def copy_sobject(my, sobject, dst_search_type, context=None, checkin_mode='inplace'):

        new_sobject = SearchType.create(dst_search_type)
        search_type = SearchType.get(dst_search_type)
        columns = SearchType.get_columns(dst_search_type)

        data = sobject.get_data()
        for name, value in data.items():
            if name in ['id','pipeline_code']:
                continue

            if name not in columns:
                continue

            if not value:
                continue

            if name == "code":
                value = Common.get_next_sobject_code(sobject, 'code')
                if not value:
                    continue
            new_sobject.set_value(name, value)
        if SearchType.column_exists(dst_search_type, "project_code"):
            project_code = Project.get_project_code()
            new_sobject.set_value("project_code", project_code)
        new_sobject.commit()



        # get all of the current snapshots and file paths associated
        if not context:
            snapshots = Snapshot.get_all_current_by_sobject(sobject)
        else:
            snapshots = [Snapshot.get_current_by_sobject(sobject, context)]

        if not snapshots:
            return

        msgs = []
        for snapshot in snapshots:
            #file_paths = snapshot.get_all_lib_paths()
            file_paths_dict = snapshot.get_all_paths_dict()
            file_types = file_paths_dict.keys()
            if not file_types:
                continue

            # make sure the paths match the file_types
            file_paths = [file_paths_dict.get(x)[0] for x in file_types]

            mode = checkin_mode

            # checkin the files (inplace)
            try:
                context = snapshot.get_value('context')
                checkin = FileCheckin(new_sobject, context=context, file_paths=file_paths, file_types=file_types, mode=mode)
                checkin.execute()

                #print "done: ", context, new_sobject.get_related_sobjects("sthpw/snapshot")
            except CheckinException, e:
                msgs.append('Post-process Check-in Error for %s: %s ' %(context, e.__str__()))
コード例 #4
0
ファイル: pipeline.py プロジェクト: zieglerm/TACTIC
    def update_dependencies(self):
        '''Function that should be run on insert/update. It's already automatically called during insert.
        On update, the caller needs to call this explicitly. It checks the search type
        this pipeline is associated with and if there is no pipeline code
        column, then update it.  It updates the process table also.'''
        search_type = self.get_value('search_type')
        self.update_process_table(search_type=search_type)

        # don't do anything for task sType
        if search_type == 'sthpw/task':
            return

        if not search_type:
            return

        if ProdSetting.get_value_by_key('autofill_pipeline_code') != 'false':
            try:
                columns = SearchType.get_columns(search_type)
                if not 'pipeline_code' in columns:
                    # add the pipeline code column
                    from pyasm.command import ColumnAddCmd
                    cmd = ColumnAddCmd(search_type, "pipeline_code", "varchar")
                    cmd.execute()
            except SqlException as e:
                print("Error creating column [pipeline_code] for %" %
                      search_type)
                pass

            # go through all of the sobjects and set all the empty ones
            # to the new pipeline
            search = Search(search_type)
            search.add_op("begin")
            search.add_filter("pipeline_code", "NULL", op='is', quoted=False)
            search.add_filter("pipeline_code", "")
            search.add_op("or")
            sobject_ids = search.get_sobject_ids()

            if sobject_ids:
                # this is much faster and memory efficient
                db_resource = SearchType.get_db_resource_by_search_type(
                    search_type)
                sql = DbContainer.get(db_resource)
                tbl = search.get_table()
                sobject_ids = [str(x) for x in sobject_ids]
                pipeline_code = self.get_value("code")
                sql.do_update(
                    '''UPDATE "%s" SET "pipeline_code" = '%s' WHERE id in (%s) '''
                    % (tbl, pipeline_code, ','.join(sobject_ids)))
            """
コード例 #5
0
ファイル: pipeline.py プロジェクト: 0-T-0/TACTIC
    def on_insert(my):
        '''Function that should be run on insert/update. It's already automatically called during insert.
        On update, the caller needs to call this explicitly. It checks the search type
        this pipeline is associated with and if there is no pipeline code
        column, then update it.  It updates the process table also.'''
        search_type = my.get_value('search_type')
        my.update_process_table(search_type=search_type)

        # don't do anything for task sType
        if search_type =='sthpw/task':
            return


        if not search_type:
            return

        if ProdSetting.get_value_by_key('autofill_pipeline_code') != 'false':
            try:
                columns = SearchType.get_columns(search_type)
                if not 'pipeline_code' in columns:
                    # add the pipeline code column
                    from pyasm.command import ColumnAddCmd
                    cmd = ColumnAddCmd(search_type, "pipeline_code", "varchar")
                    cmd.execute()
            except SqlException, e:
                print "Error creating column [pipeline_code] for %" %search_type 
                pass

            # go through all of the sobjects and set all the empty ones
            # to the new pipeline
            search = Search(search_type)
            search.add_op("begin")
            search.add_filter("pipeline_code", "NULL", op='is', quoted=False)
            search.add_filter("pipeline_code", "")
            search.add_op("or")
            sobject_ids = search.get_sobject_ids()
            
            if sobject_ids:
                # this is much faster and memory efficient
                db_resource = SearchType.get_db_resource_by_search_type(search_type)
                sql = DbContainer.get(db_resource)
                tbl = search.get_table()
                sobject_ids = [str(x) for x in sobject_ids]
                pipeline_code =  my.get_value("code")
                sql.do_update('''UPDATE "%s" SET "pipeline_code" = '%s' WHERE id in (%s) ''' %(tbl, pipeline_code, ','.join(sobject_ids)))
            """
コード例 #6
0
ファイル: database_cmd.py プロジェクト: davidsouthpaw/TACTIC
 def check(my):
     #search_type_obj = SearchType.get(my.search_type)
     columns =  SearchType.get_columns(my.search_type)
     if my.attr_name not in columns:
         raise TacticException('[%s] does not exist in this table [%s]'%(my.attr_name, my.search_type))
     return True
コード例 #7
0
    def get_first_row_wdg(my):

        # read the csv file
        #my.file_path = ""

        div = DivWdg(id='csv_import_main')
        div.add_class('spt_panel')
        
        div.add( my.get_upload_wdg() )
        if not my.search_type:
            return div

        if not my.file_path:
            return div


        if not my.file_path.endswith(".csv"):
            div.add('<br>')
            div.add( "Uploaded file [%s] is not a csv file. Refreshing in 3 seconds. . ."% os.path.basename(my.file_path))
            div.add_behavior( {'type': 'load', \
                                  'cbjs_action': "setTimeout(function() {spt.panel.load('csv_import_main','%s', {}, {\
                                    'search_type_filter': '%s'});}, 3000);" %(Common.get_full_class_name(my), my.search_type) } )
            return div

        if not os.path.exists(my.file_path):
            raise TacticException("Path '%s' does not exist" % my.file_path)

        
        div.add(HtmlElement.br(2))



        # NOT NEEDED:  clear the widget settings before drawing
        #expr = "@SOBJECT(sthpw/wdg_settings['key','EQ','pyasm.widget.input_wdg.CheckboxWdg|column_enabled_']['login','$LOGIN']['project_code','$PROJECT'])"
        #sobjs = Search.eval(expr)
        #for sobj in sobjs:
        #    sobj.delete(log=False)


        div.add( HtmlElement.b("The following is taken from the first line in the uploaded csv file.  Select the appropriate column to match.") )
        div.add(HtmlElement.br())
        """
        text =  HtmlElement.b("Make sure you have all the required columns** in the csv.")
        text.add_style('text-align: left')
        div.add(text)
        """
        div.add(HtmlElement.br(2))
        option_div_top = DivWdg()
        option_div_top.add_color('color','color')
        option_div_top.add_color('background','background', -5)
        option_div_top.add_style("padding: 10px")
        option_div_top.add_border()
        option_div_top.add_style("width: 300px")

        swap = SwapDisplayWdg(title="Parsing Options")
        option_div_top.add(swap)

        option_div_top.add_style("margin-right: 30px")

        my.search_type_obj = SearchType.get(my.search_type)

        option_div = DivWdg()
        swap.set_content_id(option_div.set_unique_id() )
        option_div.add_style("display: none")
        option_div.add_style('margin-left: 14px')
        option_div.add_style('margin-top: 10px')
        option_div.add_style("font-weight: bold")
        option_div_top.add(option_div)

        # first row and second row
        #option_div.add( HtmlElement.br() )
        option_div.add(SpanWdg("Use Title Row: ", css='small'))
        title_row_checkbox = CheckboxWdg("has_title")
        title_row_checkbox.set_default_checked()

        title_row_checkbox.add_behavior({'type' : 'click_up',
                    'propagate_evt': 'true',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(title_row_checkbox)
        option_div.add( HintWdg("Set this to use the first row as a title row to match up columns in the database") )
        

        option_div.add( HtmlElement.br(2) )
        option_div.add(SpanWdg("Use Lowercase Title: ", css='small'))
        lower_title_checkbox = CheckboxWdg("lowercase_title")

        lower_title_checkbox.add_behavior({'type' : 'click_up',
                    'propagate_evt': 'true',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(lower_title_checkbox)
        option_div.add( HtmlElement.br(2) )

        option_div.add(SpanWdg("Sample Data Row: ", css='small'))
        data_row_text = SelectWdg("data_row")
        data_row_text.set_option('values', '1|2|3|4|5')
        data_row_text.set_value('1')
        data_row_text.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(data_row_text)
        option_div.add( HintWdg("Set this as a sample data row for display here") )

        option_div.add( HtmlElement.br(2) )
      
        # encoder
        option_div.add(SpanWdg("Encoder: ", css='small'))
        select_wdg = SelectWdg('encoder')
        select_wdg.set_option('values', ['','utf-8', 'iso_8859-1']) 
        select_wdg.set_option('labels', ['ASCII (default)','UTF-8','Excel ISO 8859-1']) 
        select_wdg.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(select_wdg)
        option_div.add( HtmlElement.br(2) )


        option_div.add(SpanWdg("Identifying Column: ", css='small'))
        select_wdg = SelectWdg('id_col')
        select_wdg.set_option('empty','true')
        #columns = my.search_type_obj.get_columns()
        columns = SearchType.get_columns(my.search_type)
        
        # make sure it starts off with id, code where applicable
        if 'code' in columns:
            columns.remove('code')
            columns.insert(0, 'code')
        if 'id' in columns:
            columns.remove('id')
            columns.insert(0, 'id')

        select_wdg.set_option('values', columns) 
        option_div.add(select_wdg)
        option_div.add( HintWdg("Set which column to use for identifying an item to update during CSV Import") )
        option_div.add( HtmlElement.br(2) )

        

        div.add(option_div_top)

        my.has_title = title_row_checkbox.is_checked()
        
        
        # need to somehow specify defaults for columns
        div.add(my.get_preview_wdg())


        return div          
コード例 #8
0
ファイル: data_export_wdg.py プロジェクト: hellios78/TACTIC
class PreviewDataWdg(BaseRefreshWdg):

    
    def init(my):

        my.is_refresh = my.kwargs.get('is_refresh') 
        my.file_path = my.kwargs.get('file_path') 
        my.search_type = my.kwargs.get('search_type')
        my.search_type_obj = SearchType.get(my.search_type)
        web = WebContainer.get_web()
        my.encoder = web.get_form_value('encoder')
        title_row_checkbox = CheckboxWdg("has_title")

        my.has_title = title_row_checkbox.is_checked()

        lowercase_title_checkbox = CheckboxWdg("lowercase_title")

        my.lowercase_title = lowercase_title_checkbox.is_checked()

    def get_column_preview(my, div):
        # parse the first fow
        csv_parser = CsvParser(my.file_path)
        if my.has_title:
            csv_parser.set_has_title_row(True)
        else:
            csv_parser.set_has_title_row(False)

        if my.lowercase_title:
            csv_parser.set_lowercase_title(True)
        if my.encoder:
            csv_parser.set_encoder(my.encoder)
        try:    
            csv_parser.parse()
        # that can be all kinds of encoding/decoding exception
        except Exception, e:
            # possibly incompatible encoder selected, use the default instead.
            # Let the user pick it.
            span = SpanWdg('WARNING: The selected encoder is not compatible with your csv file. Please choose the proper one (e.g. UTF-8). Refer to the documentation/tutorial on how to save your csv file with UTF-8 encoding if you have special characters in it.', css='warning')
            div.add(SpanWdg(e.__str__()))
            div.add(HtmlElement.br())
            div.add(span, 'warning')
            return div
        
        csv_titles = csv_parser.get_titles()

        # for 2nd guess of similar column titles
        processed_csv_titles = [x.replace(' ', '_').lower() for x in csv_titles]
        csv_data = csv_parser.get_data()

        web = WebContainer.get_web()
        data_row = web.get_form_value('data_row')
        if not csv_data:
            div.add(SpanWdg('Your csv file seems to be empty', css='warning'))
            return div
        if not data_row:
            data_row = 0
        else:
            try:
                data_row = int(data_row)
                data_row -= 1
            except ValueError:
                data_row = 0

            if data_row >= len(csv_data):
                data_row = len(csv_data)-1
        #data_row_text.set_value(data_row)


        div.add( IconWdg("Important", IconWdg.CREATE) )
        div.add("Use the sample row to match which columns the data will be imported into TACTIC<br/><br/>")
        table = Table(css='spt_csv_table')
        table.add_color('background','background')
        table.add_color('color','color')

        table.set_attr("cellpadding", "7")
        table.set_attr("border", "1")


        table.add_row()
        cb = CheckboxWdg('csv_row')
        
        cb.set_default_checked()
        js =  '''
             var cbs = bvr.src_el.getParent('.spt_csv_table').getElements('.spt_csv_row');
             for (i=0; i < cbs.length; i++){
                if (!cbs[i].getAttribute('special'))
                    cbs[i].checked = bvr.src_el.checked;
            }'''
        cb.add_behavior({'type': 'click_up',
             'propagate_evt': True,
             'cbjs_action': js}) 

        th = table.add_header(cb)
        th.add_gradient("background", "background")
        th = table.add_header("CSV Column Value")
        th.add_gradient("background", "background")
        th.add_class('smaller')
        th = table.add_header("TACTIC Column")
        th.add_gradient("background", "background")
        th.add_class('smaller')
        th = table.add_header("Create New Column")
        th.add_style('min-width: 100px')
        th.add_gradient("background", "background")
        th.add_class('smaller')
        
        columns = SearchType.get_columns(my.search_type)
        sobj = SObjectFactory.create(my.search_type)
        required_columns = sobj.get_required_columns()
        
        row = csv_data[data_row]
        labels = []
        my.num_columns = len(row)
        hidden = HiddenWdg("num_columns", my.num_columns)
        div.add(hidden)
        
        for column in columns:
            if column in required_columns:
                label = '%s**'%column
            else:
                label = column
            labels.append(label)

        columns.append("(note)")
        labels.append("(Note)")
      

        skipped_columns = []
        new_col_indices = []

        for j, cell in enumerate(row):
            # skip extra empty title
            if j >= len(csv_titles):
                skipped_columns.append(str(j))
                continue

            column_select = SelectWdg("column_%s" % j)

            is_new_column = True
            use_processed = False
            # only set the value if it is actually in there
            if csv_titles[j] in columns:
                column_select.set_option("default", csv_titles[j])
                is_new_column = False
            elif processed_csv_titles[j] in columns:
                column_select.set_option("default", processed_csv_titles[j])
                is_new_column = False
                use_processed = True
            sel_val = column_select.get_value()
            

            table.add_row()
            cb = CheckboxWdg('column_enabled_%s' %j) 
            cb.set_default_checked()
            #cb.set_persistence()
            cb.set_persist_on_submit()
            cb.add_class('spt_csv_row')
            # disable the id column by default
            if csv_titles[j] in columns and csv_titles[j] == 'id':
                cb.set_option('special','true')
                cb.add_behavior({'type':'click_up',
                    #'propagate_evt': True,
                    'cbjs_action': '''spt.alert('The id column is not meant to be imported. It can only be chosen as an Identifying Column for update purpose.'); bvr.src_el.checked = false;'''})
            else:
                # if it is not a new column, and column selected is empty, we don't select the checkbox by default
                if sel_val != '' or is_new_column or not my.is_refresh:
                    cb.set_default_checked()

            table.add_cell(cb) 
            td = table.add_cell(cell)
            
            # this is an optimal max width
            td.add_style('max-width: 600px')

            column_select.add_behavior({'type': "change",
                'cbjs_action': '''if (bvr.src_el.value !='') {
                    set_display_off('new_column_div_%s');
                } else {
                    set_display_on('new_column_div_%s')
                };
                spt.panel.refresh('preview_data',
                spt.api.Utility.get_input_values('csv_import_main'));

            '''% (j,j)})


            column_select.add_empty_option("(New Column)")
            column_select.set_persist_on_submit()
            column_select.set_option("values", columns)
            column_select.set_option("labels", labels)

           
            

            display = column_select.get_buffer_display()
            td = table.add_cell( display )
            if csv_titles[j] != 'id':
                if my.is_refresh:
                    if sel_val != '':
                        td.add_color('background','background2')
                else:
                    if not is_new_column:
                        td.add_color('background','background2')
                
            #if is_new_column:
            if True:
                # this star is not necessary, and could be misleading if one checks off Use TItle Row
                #td.add(" <b style='color: red'>*</b>")

                # new property
                new_column_div = DivWdg()

                if sel_val:
                    new_column_div.add_style("display", "none")
                else:
                    new_column_div.add_style("display", "block")

                new_column_div.set_id("new_column_div_%s" % j)

                td = table.add_cell( new_column_div )
                if sel_val == '':
                    td.add_color('background','background2')
                   

                new_col_indices.append(j)

                text = TextWdg("new_column_%s" % j)
                
                text.add_style('border-color: #8DA832')
                text.set_persist_on_submit()

                if my.has_title:
                    if use_processed:
                        new_title = processed_csv_titles[j]
                    else:
                        new_title = csv_titles[j]
                    text.set_value(new_title)

                # prefer to use bg color instead of OR to notify which one is used
                """
                or_span =  SpanWdg(" OR ", css='med')
                or_span.add_color('color','color')
                new_column_div.add(or_span)
                """
                new_column_div.add( text )

        if skipped_columns:
            div.add(SpanWdg('WARNING: Some titles are empty or there are too many data cells. Column index [%s] '\
                'are skipped.' %','.join(skipped_columns), css='warning'))
            div.add(HtmlElement.br(2))


                            
        div.add(table)

        # Analyze data. It will try to create a timestamp, then integer, then float, then varchar, then text column
        for idx in new_col_indices:
            column_types = {}
            data_cell_list = []
            my.CHECK = 5
            column_type = ''       
            for k, row in enumerate(csv_data):
                if k >= len(row):
                    data = ''
                else:
                    data = row[idx] 
                if data.strip() == '':
                    continue
                if my.CHECK == 5:
                    column_type = my._check_timestamp(data)
                if my.CHECK == 4:
                    column_type = my._check_integer(data)
                if my.CHECK == 3:
                    column_type = my._check_float(data)
                if my.CHECK == 2:
                    column_type = my._check_varchar(data)



                # TEST: use democracy to determine type
                column_type = my._check_timestamp(data)
                if not column_type:
                    column_type = my._check_integer(data)
                    if not column_type:
                        column_type = my._check_float(data)
                        if not column_type:
                            column_type = my._check_varchar(data)

                if column_types.get(column_type) == None:
                    column_types[column_type] = 1
                else:
                    column_types[column_type] = column_types[column_type] + 1


                # max 30 per analysis    
                if k > 30:
                    break

            largest = 0
            for key, num in column_types.items():
                if num > largest:
                    column_type = key
                    largest = num
            #table.add_cell(column_type)

            hidden = HiddenWdg('new_column_type_%s' %idx, value=column_type)
            div.add(hidden)
コード例 #9
0
ファイル: data_export_wdg.py プロジェクト: hellios78/TACTIC
    def get_first_row_wdg(my):

        # read the csv file
        #my.file_path = ""

        div = DivWdg(id='csv_import_main')
        div.add_class('spt_panel')
        
        div.add( my.get_upload_wdg() )
        if not my.search_type:
            return div

        if not my.file_path:
            return div


        if not my.file_path.endswith(".csv"):
            div.add('<br/>')
            div.add( "Uploaded file [%s] is not a csv file. Refreshing in 3 seconds. . ."% os.path.basename(my.file_path))
            div.add_behavior( {'type': 'load', \
                                  'cbjs_action': "setTimeout(function() {spt.panel.load('csv_import_main','%s', {}, {\
                                    'search_type_filter': '%s'});}, 3000);" %(Common.get_full_class_name(my), my.search_type) } )
            return div

        if not os.path.exists(my.file_path):
            raise TacticException("Path '%s' does not exist" % my.file_path)

        
        div.add(HtmlElement.br(2))



        # NOT NEEDED:  clear the widget settings before drawing
        #expr = "@SOBJECT(sthpw/wdg_settings['key','EQ','pyasm.widget.input_wdg.CheckboxWdg|column_enabled_']['login','$LOGIN']['project_code','$PROJECT'])"
        #sobjs = Search.eval(expr)
        #for sobj in sobjs:
        #    sobj.delete(log=False)


        div.add( HtmlElement.b("The following is taken from the first line in the uploaded csv file.  Select the appropriate column to match.") )
        div.add(HtmlElement.br())
        """
        text =  HtmlElement.b("Make sure you have all the required columns** in the csv.")
        text.add_style('text-align: left')
        div.add(text)
        """
        div.add(HtmlElement.br(2))
        option_div_top = DivWdg()
        option_div_top.add_color('color','color')
        option_div_top.add_color('background','background', -5)
        option_div_top.add_style("padding: 10px")
        option_div_top.add_border()
        option_div_top.add_style("width: 300px")

        swap = SwapDisplayWdg(title="Parsing Options")
        option_div_top.add(swap)

        option_div_top.add_style("margin-right: 30px")

        my.search_type_obj = SearchType.get(my.search_type)

        option_div = DivWdg()
        swap.set_content_id(option_div.set_unique_id() )
        option_div.add_style("display: none")
        option_div.add_style('margin-left: 14px')
        option_div.add_style('margin-top: 10px')
        option_div.add_style("font-weight: bold")
        option_div_top.add(option_div)

        # first row and second row
        #option_div.add( HtmlElement.br() )
        option_div.add(SpanWdg("Use Title Row: ", css='small'))
        title_row_checkbox = CheckboxWdg("has_title")
        title_row_checkbox.set_default_checked()

        title_row_checkbox.add_behavior({'type' : 'click_up',
                    'propagate_evt': 'true',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(title_row_checkbox)
        option_div.add( HintWdg("Set this to use the first row as a title row to match up columns in the database") )
        

        option_div.add( HtmlElement.br(2) )
        option_div.add(SpanWdg("Use Lowercase Title: ", css='small'))
        lower_title_checkbox = CheckboxWdg("lowercase_title")

        lower_title_checkbox.add_behavior({'type' : 'click_up',
                    'propagate_evt': 'true',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(lower_title_checkbox)
        option_div.add( HtmlElement.br(2) )

        option_div.add(SpanWdg("Sample Data Row: ", css='small'))
        data_row_text = SelectWdg("data_row")
        data_row_text.set_option('values', '1|2|3|4|5')
        data_row_text.set_value('1')
        data_row_text.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(data_row_text)
        option_div.add( HintWdg("Set this as a sample data row for display here") )

        option_div.add( HtmlElement.br(2) )
      
        # encoder
        option_div.add(SpanWdg("Encoder: ", css='small'))
        select_wdg = SelectWdg('encoder')
        select_wdg.set_option('values', ['','utf-8', 'iso_8859-1']) 
        select_wdg.set_option('labels', ['ASCII (default)','UTF-8','Excel ISO 8859-1']) 
        select_wdg.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(select_wdg)
        option_div.add( HtmlElement.br(2) )


        option_div.add(SpanWdg("Identifying Column: ", css='small'))
        select_wdg = SelectWdg('id_col')
        select_wdg.set_option('empty','true')
        #columns = my.search_type_obj.get_columns()
        columns = SearchType.get_columns(my.search_type)
        
        # make sure it starts off with id, code where applicable
        if 'code' in columns:
            columns.remove('code')
            columns.insert(0, 'code')
        if 'id' in columns:
            columns.remove('id')
            columns.insert(0, 'id')

        select_wdg.set_option('values', columns) 
        option_div.add(select_wdg)
        option_div.add( HintWdg("Set which column to use for identifying an item to update during CSV Import") )
        option_div.add( HtmlElement.br(2) )

        
        # triggers mode
        option_div.add(SpanWdg("Triggers: ", css='small'))
        select_wdg = SelectWdg('triggers_mode')
        select_wdg.set_option('values', ['','False', 'True', 'none']) 
        select_wdg.set_option('labels', ['- Select -','Internal Triggers Only','All Triggers','No Triggers']) 
        select_wdg.add_behavior({'type' : 'change',
                    'cbjs_action': "spt.panel.refresh('preview_data',\
                    spt.api.Utility.get_input_values('csv_import_main'))"})
        option_div.add(select_wdg)
        option_div.add( HtmlElement.br(2) )

        div.add(option_div_top)

        my.has_title = title_row_checkbox.is_checked()
        
        
        # need to somehow specify defaults for columns
        div.add(my.get_preview_wdg())


        return div