Changeset 7657


Ignore:
Timestamp:
Mar 19, 2019, 2:42:52 PM (3 years ago)
Author:
Nicklas Nordborg
Message:

References #2161: Import data from Excel files

Added support for selecting a specific sheet when importing to the AnnotationFlatFileImporter. Also made it possible to specify this in the configuration.

Location:
trunk/src/plugins/core/net/sf/basedb/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plugins/core/net/sf/basedb/plugins/AnnotationFlatFileImporter.java

    r7627 r7657  
    2929import java.util.Collection;
    3030import java.util.Collections;
     31import java.util.Date;
    3132import java.util.EnumSet;
    3233import java.util.HashMap;
     
    8990import net.sf.basedb.util.error.ErrorHandler;
    9091import net.sf.basedb.util.error.SimpleErrorHandler;
    91 import net.sf.basedb.util.formatter.DateFormatter;
     92import net.sf.basedb.util.formatter.Formatter;
    9293import net.sf.basedb.util.parser.ColumnMapper;
    9394import net.sf.basedb.util.parser.ConfigureByExample;
     
    491492        // Everything is ok, save values
    492493        if (forJob) storeValue(wrapper, request, fileParameter);
     494        storeValue(wrapper, request, excelSheetParameter);
    493495        storeValue(wrapper, request, ri.getParameter("idMethod"));
    494496        // Include options
     
    606608  private FlatFileParser ffp;
    607609  private NumberFormat numberFormat;
    608   private DateFormatter dateFormatter;
    609   private DateFormatter timestampFormatter;
     610  private Formatter<Date> dateFormatter;
     611  private Formatter<Date> timestampFormatter;
    610612  private Item itemType;
    611613  private IdMethod idMethod;
     
    648650  }
    649651 
    650   @Override
    651   /**
    652     The flat file parser is initialised with settings from either the job or configuration.
    653   */
    654   protected FlatFileParser getInitializedFlatFileParser()
    655     throws BaseException
    656   {
    657     ParameterValuesWrapper wrapper = new ParameterValuesWrapper(null, job, configuration, true);
    658     return getInitializedFlatFileParser(wrapper);
    659   }
    660  
    661652  /**
    662653    Don't use AbstractFlatFileImporter to handle errors.
     
    676667    // Formatting options
    677668    this.numberFormat = ffp.getDefaultNumberFormat();
    678     String dateFormat = Values.getString((String)job.getValue(Parameters.DATE_FORMAT_PARAMETER), "yyyy-MM-dd");
    679     String timestampFormat = Values.getString((String)job.getValue(Parameters.TIMESTAMP_FORMAT_PARAMETER), "yyyy-MM-dd HH:mm:ss");
    680     this.dateFormatter = new DateFormatter(dateFormat);
    681     this.dateFormatter.getDateFormat().setLenient(false);
    682     this.timestampFormatter = new DateFormatter(timestampFormat);
    683     this.timestampFormatter.getDateFormat().setLenient(false);
     669    this.dateFormatter = ffp.getDefaultDateFormat();
     670    this.timestampFormatter = ffp.getDefaultTimestampFormat();
    684671   
    685672    this.itemType = Item.valueOf((String)job.getValue("itemType"));
     
    10181005    ffp.setMinDataColumns(IntegerUtil.getInt((Integer)parameters.getValue(minDataColumnsParameter.getName())));
    10191006    ffp.setMaxDataColumns(IntegerUtil.getInt((Integer)parameters.getValue(maxDataColumnsParameter.getName())));
     1007    ffp.setExcelSheet(parameters.getValue(excelSheetParameter.getName()));
    10201008    return ffp;
    10211009  }
     
    10561044          // The file to import from
    10571045          parameters.add(fileParameter);
     1046          parameters.add(excelSheetParameter);
    10581047          parameters.add(identificationSection);
    10591048        }
     
    11501139        // Parser regular expressions
    11511140        parameters.add(parserSection);
     1141        if (!forJob) parameters.add(excelSheetParameter);
    11521142        parameters.add(dataHeaderRegexpParameter);
    11531143        parameters.add(dataSplitterRegexpParameter);
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/AbstractItemImporter.java

    r7656 r7657  
    26432643        // Parser regular expressions
    26442644        parameters.add(parserSection);
     2645        if (!forJob) parameters.add(excelSheetParameter);
    26452646        parameters.add(dataHeaderRegexpParameter);
    26462647        parameters.add(dataSplitterRegexpParameter);
Note: See TracChangeset for help on using the changeset viewer.