Changeset 4107


Ignore:
Timestamp:
Jan 29, 2008, 2:52:55 PM (15 years ago)
Author:
Nicklas Nordborg
Message:

References #909: Move some static fields from AbstractFlatFileImporter? to a separate class

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

Legend:

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

    r4102 r4107  
    5757import net.sf.basedb.core.signal.ThreadSignalHandler;
    5858
     59import net.sf.basedb.plugins.util.Parameters;
    5960import net.sf.basedb.util.NumberFormatUtil;
    6061import net.sf.basedb.util.error.ClassMapErrorHandler;
     
    277278    Enumerates all available character sets.
    278279    @see #getCharsetParameter(String, String, String)
     280    @deprecated Use {@link Parameters#charsetParameter(String, String, String)}
    279281  */
    280282  protected static final StringParameterType charsetType =
     
    284286  /**
    285287    Type for selecting decimal separator.
     288    @deprecated Use {@link Parameters#decimalSeparatorParameter(String, String, String)}
    286289  */
    287290  protected static final StringParameterType decimalSeparatorType =
     
    345348  /**
    346349    Section definition for grouping error handling options.
    347   */
    348   protected static final PluginParameter<String> errorSection = new PluginParameter<String>(
    349     "errorSection",
    350     "Error handling",
    351     "Select how errors should be handled by the plugin.",
    352     null
    353   );
    354  
    355   protected static final PluginParameter<String> defaultErrorParameter = new PluginParameter<String>(
    356     "defaultError",
    357     "Default error handling",
    358     "The default way to handle an error when no other error handling options have been " +
    359     "specified to take care of specific exceptions.\n\n"+
    360     "skip = Skip the current data line and continue\n"+
    361     "fail = Stop with an error message (default)",
    362     new StringParameterType(255, "fail", true, 1, 0, 0,
    363         Arrays.asList( new String[] { "skip", "fail"} ))
    364   );
    365  
    366   protected static final PluginParameter<String> stringTooLongErrorParameter = new PluginParameter<String>(
    367       "stringTooLongError",
    368       "String too long",
    369       "How to handle errors that are caused by too long string values. If no value is specified the " +
    370       "default error handling is used.\n\n"+
    371       "crop = Crop the string to the maximum allowed length\n"+
    372       "skip = Skip the current data line and continue\n"+
    373       "fail = Stop with an error message",
    374       new StringParameterType(255, null, false, 1, 0, 0,
    375           Arrays.asList( new String[] { "crop", "skip", "fail"} ))
    376     );
    377  
    378   protected static final PluginParameter<String> invalidUseOfNullErrorParameter = new PluginParameter<String>(
    379       "invalidUseOfNullError",
    380       "Missing a required value",
    381       "How to handle errors that are caused by missing a required value. If no value is specified the " +
    382       "default error handling is used.\n\n"+
    383       "skip = Skip the current data line and continue\n"+
    384       "fail = Stop with an error message",
    385       new StringParameterType(255, null, false, 1, 0, 0,
    386           Arrays.asList( new String[] { "skip", "fail"} ))
    387     );
    388 
    389   protected static final PluginParameter<String> numberOutOfRangeErrorParameter = new PluginParameter<String>(
    390       "numberOutOfRangeError",
    391       "Numeric value out of range",
    392       "How to handle errors that are caused by numbers that are either too small or too big. If no value is specified the " +
    393       "default error handling is used.\n\n"+
    394       "skip = Skip the current data line and continue\n"+
    395       "fail = Stop with an error message",
    396       new StringParameterType(255, null, false, 1, 0, 0,
    397         Arrays.asList( new String[] { "skip", "fail"} ))
    398     );
    399  
    400   protected static final PluginParameter<String> numberFormatErrorParameter = new PluginParameter<String>(
    401       "numberFormatError",
    402       "Invalid numeric value",
    403       "How to handle errors that are caused by strings that can't be converted to a numeric value. " +
    404       "If no value is specified the default error handling is used.\n\n"+
    405       "null = Insert a null value and continue\n"+
    406       "skip = Skip the current data line and continue\n"+
    407       "fail = Stop with an error message",
    408       new StringParameterType(255, null, false, 1, 0, 0,
    409         Arrays.asList( new String[] { "null", "skip", "fail"} ))
    410     );
     350    @see Parameters#errorSection(String, String)
     351  */
     352  protected static final PluginParameter<String> errorSection =
     353    Parameters.errorSection(null, null);
     354 
     355  /**
     356    @see Parameters#defaultError(String, String, String, String...)
     357  */
     358  protected static final PluginParameter<String> defaultErrorParameter =
     359    Parameters.defaultError(null, null, null);
     360 
     361  /**
     362    @see Parameters#stringTooLongError(String, String, String, String...)
     363  */
     364  protected static final PluginParameter<String> stringTooLongErrorParameter =
     365    Parameters.stringTooLongError(null, null, null);
     366 
     367  /**
     368    @see Parameters#invalidUseOfNullError(String, String, String, String...)
     369  */
     370  protected static final PluginParameter<String> invalidUseOfNullErrorParameter =
     371    Parameters.invalidUseOfNullError(null, null, null);
     372
     373  /**
     374    @see Parameters#numberOutOfRangeError(String, String, String, String...)
     375   */
     376  protected static final PluginParameter<String> numberOutOfRangeErrorParameter =
     377    Parameters.numberOutOfRangeError(null, null, null);
     378 
     379  /**
     380    @see Parameters#numberFormatError(String, String, String, String...)
     381  */
     382  protected static final PluginParameter<String> numberFormatErrorParameter =
     383    Parameters.numberFormatError(null, null, null);
    411384 
    412385  private long fileSize;
     
    858831  {
    859832    String charset = null;
    860     if (job != null) charset = (String)job.getValue(CHARSET);
     833    if (job != null) charset = (String)job.getValue(Parameters.CHARSET_PARAMETER);
    861834    if (charset == null && configuration != null)
    862835    {
    863       charset = (String)configuration.getValue(CHARSET);
     836      charset = (String)configuration.getValue(Parameters.CHARSET_PARAMETER);
    864837    }
    865838    if (charset == null) charset = Config.getCharset();
     
    877850  {
    878851    String ds = null;
    879     if (job != null) ds = (String)job.getValue(DECIMAL_SEPARATOR);
     852    if (job != null) ds = (String)job.getValue(Parameters.DECIMAL_SEPARATOR_PARAMETER);
    880853    if (ds == null && configuration != null)
    881854    {
    882       ds = (String)configuration.getValue(DECIMAL_SEPARATOR);
     855      ds = (String)configuration.getValue(Parameters.DECIMAL_SEPARATOR_PARAMETER);
    883856    }
    884857    return ds;
     
    911884    The name of the parameter that asks for the character set.
    912885    @see #getCharsetParameter(String, String, String)
    913   */
    914   protected static final String CHARSET = "charset";
     886    @deprecated Use {@link Parameters#CHARSET_PARAMETER}
     887  */
     888  protected static final String CHARSET = Parameters.CHARSET_PARAMETER;
    915889 
    916890  /**
     
    926900    @param defaultValue The default value for the character set or null to use
    927901      the system default
     902    @deprecated USe {@link Parameters#charsetParameter(String, String, String)}
    928903  */
    929904  protected PluginParameter<String> getCharsetParameter(String label, String description, String defaultValue)
    930905  {
    931     if (label == null) label = "Character set";
    932     if (description == null) description = "The character set used in the file, if not specified the default character set is used " +
    933       "(" + Config.getCharset() + ").";
    934     if (defaultValue == null) defaultValue = Config.getCharset();
    935     return new PluginParameter<String>(
    936       CHARSET, label, description, defaultValue, charsetType
    937     );
     906    return Parameters.charsetParameter(label, description, defaultValue);
    938907  }
    939908
     
    941910    The name of the parameter that asks for the decimal separator.
    942911    @see #getCharsetParameter(String, String, String)
    943   */
    944   protected static final String DECIMAL_SEPARATOR = "decimalSeparator";
     912    @deprecated Use {@link Parameters#DECIMAL_SEPARATOR_PARAMETER}
     913  */
     914  protected static final String DECIMAL_SEPARATOR = Parameters.DECIMAL_SEPARATOR_PARAMETER;
    945915 
    946916  /**
     
    957927    @param defaultValue The default value for the decimal separator
    958928    @since 2.2
     929    @deprecated Use {@link Parameters#decimalSeparatorParameter(String, String, String)}
    959930  */
    960931  protected PluginParameter<String> getDecimalSeparatorParameter(String label, String description, String defaultValue)
    961932  {
    962     if (label == null) label = "Decimal separator";
    963     if (description == null)
    964     {
    965       description = "The decimal separator used in numeric values, " +
    966         "if not specified dot is assumed.";
    967     }
    968     return new PluginParameter<String>(
    969       DECIMAL_SEPARATOR, label, description, defaultValue, decimalSeparatorType
    970     );
     933    return Parameters.decimalSeparatorParameter(label, description, defaultValue);
    971934  }
    972935 
  • trunk/src/plugins/core/net/sf/basedb/plugins/AnnotationFlatFileImporter.java

    r4015 r4107  
    7979import net.sf.basedb.core.query.Orders;
    8080import net.sf.basedb.core.query.Restrictions;
     81import net.sf.basedb.plugins.util.Parameters;
    8182import net.sf.basedb.util.error.ClassMapErrorHandler;
    8283import net.sf.basedb.util.error.ErrorHandler;
     
    467468        storeValue(wrapper, request, minDataColumnsParameter);
    468469        storeValue(wrapper, request, maxDataColumnsParameter);
    469         storeValue(wrapper, request, ri.getParameter(CHARSET));
    470         storeValue(wrapper, request, ri.getParameter(DECIMAL_SEPARATOR));
     470        storeValue(wrapper, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
     471        storeValue(wrapper, request, ri.getParameter(Parameters.DECIMAL_SEPARATOR_PARAMETER));
    471472       
    472473        // Column mappings
     
    876877      parameters.add(minDataColumnsParameter);
    877878      parameters.add(maxDataColumnsParameter);
    878       parameters.add(getCharsetParameter(null, null, getCharset()));
    879       parameters.add(getDecimalSeparatorParameter(null, null, getDecimalSeparator()));
     879      parameters.add(Parameters.charsetParameter(null, null, getCharset()));
     880      parameters.add(Parameters.decimalSeparatorParameter(null, null, getDecimalSeparator()));
    880881     
    881882      // Mappings for Name and External ID
  • trunk/src/plugins/core/net/sf/basedb/plugins/IlluminaRawDataImporter.java

    r4095 r4107  
    8282import net.sf.basedb.core.query.Restriction;
    8383import net.sf.basedb.core.query.Restrictions;
     84import net.sf.basedb.plugins.util.Parameters;
    8485import net.sf.basedb.util.error.SimpleErrorHandler;
    8586import net.sf.basedb.util.parser.ColumnMapper;
     
    289290       
    290291        storeValue(job, request, fileParameter);
    291         storeValue(job, request, ri.getParameter(CHARSET));
    292         storeValue(job, request, ri.getParameter(DECIMAL_SEPARATOR));
     292        storeValue(job, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
     293        storeValue(job, request, ri.getParameter(Parameters.DECIMAL_SEPARATOR_PARAMETER));
    293294       
    294295        // Associations
     
    671672       
    672673        parameters.add(fileParameter);
    673         parameters.add(getCharsetParameter(null, null, null));
    674         parameters.add(getDecimalSeparatorParameter(null, null, (String)job.getValue(DECIMAL_SEPARATOR)));
    675  
     674        parameters.add(Parameters.charsetParameter(null, null, null));
     675        parameters.add(Parameters.decimalSeparatorParameter(null, null,
     676            (String)job.getValue(Parameters.DECIMAL_SEPARATOR_PARAMETER)));
     677
    676678        // parameters for scan, protocol, software and array design
    677679        dc = sc.newDbControl();
  • trunk/src/plugins/core/net/sf/basedb/plugins/PlateFlatFileImporter.java

    r3679 r4107  
    5858import net.sf.basedb.core.query.Hql;
    5959import net.sf.basedb.core.query.Orders;
     60import net.sf.basedb.plugins.util.Parameters;
    6061import net.sf.basedb.util.Coordinate;
    6162import net.sf.basedb.util.MD5;
     
    317318        storeValue(configuration, request, minDataColumnsParameter);
    318319        storeValue(configuration, request, maxDataColumnsParameter);
    319         storeValue(configuration, request, ri.getParameter(CHARSET));
     320        storeValue(configuration, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
    320321       
    321322        // Column mappings
     
    345346        storeValue(job, request, plateTypeParameter);
    346347        storeValue(job, request, fileParameter);
    347         storeValue(job, request, ri.getParameter(CHARSET));
     348        storeValue(job, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
    348349       
    349350        // Error handling parameters
     
    524525      parameters.add(minDataColumnsParameter);
    525526      parameters.add(maxDataColumnsParameter);
    526       parameters.add(getCharsetParameter(null, null, null));
     527      parameters.add(Parameters.charsetParameter(null, null, null));
    527528     
    528529      // Column mappings
     
    567568      parameters.add(plateTypeParameter);
    568569      parameters.add(fileParameter);
    569       parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET)));
     570      parameters.add(Parameters.charsetParameter(null, null,
     571          (String)configuration.getValue(Parameters.CHARSET_PARAMETER)));
    570572      parameters.add(plateNamePrefixParameter);
    571573      parameters.add(reporterPrefixParameter);
  • trunk/src/plugins/core/net/sf/basedb/plugins/PrintMapFlatFileImporter.java

    r4080 r4107  
    6262import net.sf.basedb.core.plugin.Request;
    6363import net.sf.basedb.core.plugin.Response;
     64import net.sf.basedb.plugins.util.Parameters;
    6465import net.sf.basedb.util.error.SimpleErrorHandler;
    6566import net.sf.basedb.util.parser.FlatFileParser;
     
    263264        }
    264265        storeValue(job, request, fileParameter);
    265         storeValue(job, request, ri.getParameter(CHARSET));
     266        storeValue(job, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
    266267        storeValue(job, request, arrayDesignParameter);
    267268
     
    543544      );
    544545      parameters.add(fileParameter);
    545       parameters.add(getCharsetParameter(null, null, null));
     546      parameters.add(Parameters.charsetParameter(null, null, null));
    546547     
    547548      // Error handling parameters
  • trunk/src/plugins/core/net/sf/basedb/plugins/RawDataFlatFileImporter.java

    r4097 r4107  
    6464import net.sf.basedb.core.plugin.Request;
    6565import net.sf.basedb.core.plugin.Response;
     66import net.sf.basedb.plugins.util.Parameters;
    6667import net.sf.basedb.util.Enumeration;
    6768import net.sf.basedb.util.error.SimpleErrorHandler;
     
    452453        storeValue(configuration, request, minDataColumnsParameter);
    453454        storeValue(configuration, request, maxDataColumnsParameter);
    454         storeValue(configuration, request, ri.getParameter(CHARSET));
    455         storeValue(configuration, request, ri.getParameter(DECIMAL_SEPARATOR));
     455        storeValue(configuration, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
     456        storeValue(configuration, request, ri.getParameter(Parameters.DECIMAL_SEPARATOR_PARAMETER));
    456457       
    457458        // Column mappings
     
    479480        storeValue(job, request, rawBioAssayParameter);
    480481        storeValue(job, request, fileParameter);
    481         storeValue(job, request, ri.getParameter(CHARSET));
    482         storeValue(job, request, ri.getParameter(DECIMAL_SEPARATOR));
     482        storeValue(job, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
     483        storeValue(job, request, ri.getParameter(Parameters.DECIMAL_SEPARATOR_PARAMETER));
    483484       
    484485        // Annotations
     
    826827      }
    827828     
    828       parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET)));
    829       parameters.add(getDecimalSeparatorParameter(null, null, (String)configuration.getValue(DECIMAL_SEPARATOR)));
     829      parameters.add(Parameters.charsetParameter(null, null,
     830          (String)configuration.getValue(Parameters.CHARSET_PARAMETER)));
     831      parameters.add(Parameters.decimalSeparatorParameter(null, null,
     832          (String)configuration.getValue(Parameters.DECIMAL_SEPARATOR_PARAMETER)));
    830833     
    831834      // Annotations section
     
    937940      parameters.add(minDataColumnsParameter);
    938941      parameters.add(maxDataColumnsParameter);
    939       parameters.add(getCharsetParameter(null, null, null));
    940       parameters.add(getDecimalSeparatorParameter(null, null, null));
     942      parameters.add(Parameters.charsetParameter(null, null, null));
     943      parameters.add(Parameters.decimalSeparatorParameter(null, null, null));
    941944
    942945      // Column mappings
  • trunk/src/plugins/core/net/sf/basedb/plugins/ReporterFlatFileImporter.java

    r4076 r4107  
    6565import net.sf.basedb.core.plugin.GuiContext;
    6666
     67import net.sf.basedb.plugins.util.Parameters;
    6768import net.sf.basedb.util.error.SimpleErrorHandler;
    6869import net.sf.basedb.util.parser.ConfigureByExample;
     
    321322        storeValue(configuration, request, minDataColumnsParameter);
    322323        storeValue(configuration, request, maxDataColumnsParameter);
    323         storeValue(configuration, request, ri.getParameter(CHARSET));
    324         storeValue(configuration, request, ri.getParameter(DECIMAL_SEPARATOR));
     324        storeValue(configuration, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
     325        storeValue(configuration, request, ri.getParameter(Parameters.DECIMAL_SEPARATOR_PARAMETER));
    325326       
    326327        // Column mappings
     
    353354        }
    354355        storeValue(job, request, fileParameter);
    355         storeValue(job, request, ri.getParameter(CHARSET));
    356         storeValue(job, request, ri.getParameter(DECIMAL_SEPARATOR));
     356        storeValue(job, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
     357        storeValue(job, request, ri.getParameter(Parameters.DECIMAL_SEPARATOR_PARAMETER));
    357358        storeValue(job, request, ri.getParameter("mode"));
    358359       
     
    753754     
    754755      parameters.add(modeParameter);
    755       parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET)));
    756       parameters.add(getDecimalSeparatorParameter(null, null, (String)configuration.getValue(DECIMAL_SEPARATOR)));
     756      parameters.add(Parameters.charsetParameter(null, null,
     757          (String)configuration.getValue(Parameters.CHARSET_PARAMETER)));
     758      parameters.add(Parameters.decimalSeparatorParameter(null, null,
     759          (String)configuration.getValue(Parameters.DECIMAL_SEPARATOR_PARAMETER)));
    757760     
    758761      parameters.add(errorSection);
     
    810813      parameters.add(minDataColumnsParameter);
    811814      parameters.add(maxDataColumnsParameter);
    812       parameters.add(getCharsetParameter(null, null, null));
    813       parameters.add(getDecimalSeparatorParameter(null, null, null));
     815      parameters.add(Parameters.charsetParameter(null, null, null));
     816      parameters.add(Parameters.decimalSeparatorParameter(null, null, null));
    814817
    815818      // Column mappings
  • trunk/src/plugins/core/net/sf/basedb/plugins/ReporterMapFlatFileImporter.java

    r4097 r4107  
    6262import net.sf.basedb.core.plugin.Request;
    6363import net.sf.basedb.core.plugin.Response;
     64import net.sf.basedb.plugins.util.Parameters;
    6465import net.sf.basedb.util.error.SimpleErrorHandler;
    6566import net.sf.basedb.util.parser.ConfigureByExample;
     
    445446        storeValue(configuration, request, minDataColumnsParameter);
    446447        storeValue(configuration, request, maxDataColumnsParameter);
    447         storeValue(configuration, request, ri.getParameter(CHARSET));
     448        storeValue(configuration, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
    448449
    449450        // Column mappings
     
    471472        storeValue(job, request, arrayDesignParameter);
    472473        storeValue(job, request, fileParameter);
    473         storeValue(job, request, ri.getParameter(CHARSET));
     474        storeValue(job, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
    474475     
    475476        // Error handling parameters
     
    706707      );
    707708      parameters.add(fileParameter);
    708       parameters.add(getCharsetParameter(null, null, (String)configuration.getValue(CHARSET)));
     709      parameters.add(Parameters.charsetParameter(null, null,
     710          (String)configuration.getValue(Parameters.CHARSET_PARAMETER)));
    709711     
    710712      // Error handling parameters
     
    745747      parameters.add(minDataColumnsParameter);
    746748      parameters.add(maxDataColumnsParameter);
    747       parameters.add(getCharsetParameter(null, null, null));
     749      parameters.add(Parameters.charsetParameter(null, null, null));
    748750     
    749751      // Column mappings
Note: See TracChangeset for help on using the changeset viewer.