Changeset 3598


Ignore:
Timestamp:
Jul 25, 2007, 8:19:55 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #566: Plugins using the flat file parser should warn about complex column mappings

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

Legend:

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

    r3588 r3598  
    326326  */
    327327  protected static final PluginParameter<String> complexMappings = new PluginParameter<String>(
    328     "complexMappings",
     328    "complexExpressions",
    329329    "Complex column mappings",
    330330    "disallow = Only allow simple mappings that are constant value or pick the value " +
  • trunk/src/plugins/core/net/sf/basedb/plugins/AnnotationFlatFileImporter.java

    r3588 r3598  
    443443        // Check that a mapping for name OR external ID is given
    444444        boolean hasExternalId = context == null || hasExternalId(context.getItem());
     445        String nameMapping = (String)request.getParameterValue("nameColumnMapping");
     446        String externalIdMapping = (String)request.getParameterValue("externalIdColumnMapping");
    445447        if (hasExternalId)
    446448        {
    447           if (request.getParameterValue("nameColumnMapping") == null &&
    448             request.getParameterValue("externalIdColumnMapping") == null)
     449          if (nameMapping == null && externalIdMapping == null)
    449450          {
    450451            response.setError("A mapping for either 'Name' or 'External Id' must be given.", null);
    451452            return;
    452453          }
    453           if (request.getParameterValue("nameColumnMapping") != null &&
    454             request.getParameterValue("externalIdColumnMapping") != null)
     454          if (nameMapping != null && externalIdMapping != null)
    455455          {
    456456            response.setError("It is not possible to use a mapping for both 'Name' and 'External Id'.", null);
     
    458458          }
    459459        }
    460      
     460        // Check the mapping expressions
     461        boolean allowComplex = "allow".equals(request.getParameterValue(complexMappings.getName()));
     462        checkColumnMapping(nameMapping, allowComplex, requiredNameColumnMapping.getLabel());
     463        checkColumnMapping(externalIdMapping, allowComplex, externalIdColumnMapping.getLabel());
     464
    461465        // Everything is ok, save values
    462466        if (forJob) storeValue(wrapper, request, fileParameter);
     
    470474        storeValue(wrapper, request, ri.getParameter(CHARSET));
    471475        storeValue(wrapper, request, ri.getParameter(DECIMAL_SEPARATOR));
     476       
     477        // Column mappings
     478        storeValue(wrapper, request, complexMappings);
    472479        if (hasExternalId)
    473480        {
     
    879886      // Mappings for Name and External ID
    880887      parameters.add(mappingSection);
     888      parameters.add(complexMappings);
    881889      if (context == null || hasExternalId(context.getItem()))
    882890      {
Note: See TracChangeset for help on using the changeset viewer.