Changeset 5242


Ignore:
Timestamp:
Feb 11, 2010, 11:05:48 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1446: Use the core "Reporter importer" without a file format configuration

Fixed some remaining issues (NullPointerException?) when running without a configuration and when used to import reporter lists.

File:
1 edited

Legend:

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

    r5241 r5242  
    328328        storeValue(configuration, request, complexMappings);
    329329        boolean allowComplex = "allow".equals(request.getParameterValue(complexMappings.getName()));
    330         for (PluginParameter<String> pp : getAllColumnMappings())
     330        for (PluginParameter<String> pp : getAllColumnMappings(false))
    331331        {
    332332          String mapExpression = (String)request.getParameterValue(pp.getName());
     
    348348          return;
    349349        }
    350         if (context != null &&
    351           (context.getItem() == Item.REPORTERLIST || context.getItem() == Item.REPORTERSCORE))
     350       
     351        boolean reporterListContext = context != null &&
     352          (context.getItem() == Item.REPORTERLIST || context.getItem() == Item.REPORTERSCORE);
     353        if (reporterListContext)
    352354        {
    353355          storeValue(job, request, reporterListParameter);
     
    371373        storeValue(job, request, complexMappings);
    372374        boolean allowComplex = "allow".equals(request.getParameterValue(complexMappings.getName()));
    373         for (PluginParameter<String> pp : getAllColumnMappings())
     375        for (PluginParameter<String> pp : getAllColumnMappings(reporterListContext))
    374376        {
    375377          String mapExpression = (String)request.getParameterValue(pp.getName());
     
    439441    extendedProperties = ExtendedProperties.getProperties("ReporterData");
    440442    batcher = ReporterBatcher.getNew(dc);
    441     reporterType = (ReporterType)configuration.getValue("reporterType");
     443    reporterType = (ReporterType)getJobOrConfigurationValue("reporterType");
    442444    reporterList = (ReporterList)job.getValue("reporterList");
    443445    String mode = (String)job.getValue("mode");
     
    537539        {
    538540          ReporterData reporter = batcher.getByExternalId(entry.getKey());
    539           reporterList.addReporter(reporter, entry.getValue());
    540           numAddedToList++;
     541          if (reporterList.addReporter(reporter, entry.getValue()))
     542          {
     543            numAddedToList++;
     544          }
    541545        }
    542546      }
     
    644648          else
    645649          {
    646             reporterList.addReporter(reporter, score);
    647             numAddedToList++;
     650            if (reporterList.addReporter(reporter, score))
     651            {
     652              numAddedToList++;
     653            }
    648654          }
    649655        }
     
    732738  // -------------------------------------------
    733739 
    734   private List<PluginParameter<String>> getAllColumnMappings()
     740  private List<PluginParameter<String>> getAllColumnMappings(boolean reporterListContext)
    735741  {
    736742    if (allColumnMappings == null)
     
    738744      // Column mappings
    739745      allColumnMappings = new ArrayList<PluginParameter<String>>();
    740       allColumnMappings.add(nameColumnMapping);
    741       allColumnMappings.add(reporterIdColumnMapping);
    742       allColumnMappings.add(descriptionColumnMapping);
    743       allColumnMappings.add(symbolColumnMapping);
    744       allColumnMappings.add(scoreColumnMapping);
    745       allColumnMappings.add(reporterTypeColumnMapping);
    746       List<ExtendedProperty> extended = ExtendedProperties.getProperties("ReporterData");
    747       if (extended != null)
    748       {
    749         for (ExtendedProperty ep : extended)
    750         {
    751           allColumnMappings.add(
    752             new PluginParameter<String>(
    753               "extendedColumnMapping."+ep.getName(),
    754               ep.getTitle(),
    755               ep.getDescription(),
    756               optionalColumnMapping
    757               )
    758             );
     746      if (reporterListContext)
     747      {
     748        allColumnMappings.add(reporterIdColumnMapping);
     749        allColumnMappings.add(scoreColumnMapping);
     750      }
     751      else
     752      {
     753        allColumnMappings.add(nameColumnMapping);
     754        allColumnMappings.add(reporterIdColumnMapping);
     755        allColumnMappings.add(descriptionColumnMapping);
     756        allColumnMappings.add(symbolColumnMapping);
     757        allColumnMappings.add(reporterTypeColumnMapping);
     758        List<ExtendedProperty> extended = ExtendedProperties.getProperties("ReporterData");
     759        if (extended != null)
     760        {
     761          for (ExtendedProperty ep : extended)
     762          {
     763            allColumnMappings.add(
     764              new PluginParameter<String>(
     765                "extendedColumnMapping."+ep.getName(),
     766                ep.getTitle(),
     767                ep.getDescription(),
     768                optionalColumnMapping
     769                )
     770              );
     771          }
    759772        }
    760773      }
     
    843856      parameters.add(cloneParameterWithDefaultValue(maxDataColumnsParameter));
    844857      parameters.add(Parameters.charsetParameter(null, null,
    845           (String)configuration.getValue(Parameters.CHARSET_PARAMETER)));
     858          (String)getJobOrConfigurationValue(Parameters.CHARSET_PARAMETER)));
    846859      parameters.add(Parameters.decimalSeparatorParameter(null, null,
    847           (String)configuration.getValue(Parameters.DECIMAL_SEPARATOR_PARAMETER)));
     860          (String)getJobOrConfigurationValue(Parameters.DECIMAL_SEPARATOR_PARAMETER)));
    848861
    849862      // Column mappings
    850863      parameters.add(mappingSection);
    851864      parameters.add(complexMappings);
    852       parameters.addAll(getAllColumnMappings());
     865      parameters.addAll(getAllColumnMappings(reporterListContext));
    853866     
    854867      parameters.add(errorSection);
     
    914927      parameters.add(mappingSection);
    915928      parameters.add(complexMappings);
    916       parameters.addAll(getAllColumnMappings());
     929      parameters.addAll(getAllColumnMappings(false));
    917930     
    918931      configurePlugin = new RequestInformation
Note: See TracChangeset for help on using the changeset viewer.