Changeset 4891


Ignore:
Timestamp:
Apr 7, 2009, 9:48:59 AM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1291: Batch importing same labeled extract in more than one array on a multi-array slide only keeps the last entry in file

There is now an option to detect this and report an error.

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

Legend:

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

    r4835 r4891  
    354354       
    355355        // Everything is ok, save values
    356         /*
    357         if (forJob)
    358         {
    359           storeValue(wrapper, request, fileParameter);
    360           storeValue(wrapper, request, ri.getParameter("mode"));
    361         }
    362         storeValue(wrapper, request, dataHeaderRegexpParameter);
    363         storeValue(wrapper, request, dataSplitterRegexpParameter);
    364         storeValue(wrapper, request, trimQuotesParameter);
    365         storeValue(wrapper, request, ignoreRegexpParameter);
    366         storeValue(wrapper, request, dataFooterRegexpParameter);
    367         storeValue(wrapper, request, minDataColumnsParameter);
    368         storeValue(wrapper, request, maxDataColumnsParameter);
    369         storeValue(wrapper, request, ri.getParameter(Parameters.CHARSET_PARAMETER));
    370         storeValue(wrapper, request, ri.getParameter(Parameters.DECIMAL_SEPARATOR_PARAMETER));
    371         storeValue(wrapper, request, ri.getParameter(Parameters.DATE_FORMAT_PARAMETER));
    372        
    373         // Identification method
    374         storeValue(wrapper, request, ri.getParameter("idMethod"));
    375         if (forJob)
    376         {
    377           storeValue(wrapper, request, ri.getParameter("includeMine"));
    378           storeValue(wrapper, request, ri.getParameter("includeSharedTo"));
    379           storeValue(wrapper, request, ri.getParameter("includeInProject"));
    380           storeValue(wrapper, request, ri.getParameter("includeOthers"));
    381         }
    382        
    383         // Column mappings
    384         storeValue(wrapper, request, complexMappings);
    385         */
    386356        for (PluginParameter pp : ri.getParameters())
    387357        {
    388 //          if (pp.getName().contains("ColumnMapping"))
    389358          if (pp.getParameterType() != null)
    390359          {
     
    392361          }
    393362        }
    394 //        storeValue(wrapper, request, ri.getParameter("dataDirectory"));
    395363        if (forJob)
    396364        {
     
    413381     
    414382        // Error handling
    415         storeValue(job, request, ri.getParameter(Parameters.LOGFILE_PARAMETER));
    416383        response.setDryRun(Boolean.TRUE.equals(request.getParameterValue(Parameters.DRY_RUN_PARAMETER)));
    417         storeValue(job, request, defaultErrorParameter);
    418         storeValue(job, request, itemNotFoundErrorParameter);
    419         storeValue(job, request, itemExistsErrorParameter);
    420         storeValue(job, request, multipleItemsFoundErrorParameter);
    421         storeValue(job, request, referenceNotFoundErrorParameter);
    422         storeValue(job, request, multipleReferencesFoundErrorParameter);
    423         storeValue(job, request, ri.getParameter(Parameters.INVALID_USE_OF_NULL_ERROR));
    424         storeValue(job, request, stringTooLongErrorParameter);
    425         storeValue(job, request, numberFormatErrorParameter);
    426         storeValue(job, request, numberOutOfRangeErrorParameter);
    427         storeValue(job, request, noWritePermissionToItemErrorParameter);
    428         storeValue(job, request, noUsePermissionToReferenceErrorParameter);
    429        
     384        for (PluginParameter pp : ri.getParameters())
     385        {
     386          if (pp.getParameterType() != null)
     387          {
     388            storeValue(job, request, ri.getParameter(pp.getName()));
     389          }
     390        }
     391
    430392        // Save context info
    431393        response.setDone("Job configuration complete", Job.ExecutionTime.SHORT);   
  • trunk/src/plugins/core/net/sf/basedb/plugins/batchimport/HybridizationImporter.java

    r4837 r4891  
    2222package net.sf.basedb.plugins.batchimport;
    2323
     24import java.util.Arrays;
    2425import java.util.Collections;
    2526import java.util.List;
     
    3132import net.sf.basedb.core.Hardware;
    3233import net.sf.basedb.core.Hybridization;
     34import net.sf.basedb.core.InvalidDataException;
    3335import net.sf.basedb.core.Item;
    3436import net.sf.basedb.core.ItemQuery;
     
    3941import net.sf.basedb.core.Protocol;
    4042import net.sf.basedb.core.ProtocolType;
     43import net.sf.basedb.core.StringParameterType;
    4144import net.sf.basedb.core.SystemItems;
    4245import net.sf.basedb.core.Version;
     
    116119    );
    117120 
     121  private static final PluginParameter<String> multipleArrayIndexErrorParameter =
     122    new PluginParameter<String>(
     123      "multipleArrayIndexError",
     124      "Labeled extract on multiple arrays",
     125      "What to do if trying to assign a labeled extract to more than one array " +
     126      "on a multi-array hybridization\n\n"+
     127      "ignore = Update the array index overriding previous settings\n" +
     128      "fail = Stop with an error message",
     129      new StringParameterType(255, "fail", false, 1, 0, 0,
     130        Arrays.asList( new String[] { "ignore", "fail"} ))
     131    );
     132
     133 
    118134  public HybridizationImporter()
    119135  {}
     
    156172  private Mapper arrayIndexMapper;
    157173  private Mapper arraySlideMapper;
     174  private boolean failIfMultipleArrayIndex;
    158175 
    159176  /**
     
    194211  }
    195212 
     213  @Override
     214  protected void addMoreErrorParameters(List<PluginParameter<?>> parameters)
     215  {
     216    parameters.add(multipleArrayIndexErrorParameter);
     217  }
     218 
    196219  /**
    197220    Calls {@link Hybridization#getQuery()}.
     
    218241    arrayIndexMapper = getMapper(ffp, (String)job.getValue("arrayIndexColumnMapping"), null, null);
    219242    arraySlideMapper = getMapper(ffp, (String)job.getValue("arraySlideColumnMapping"), null, null);
     243    this.failIfMultipleArrayIndex = "fail".equals(getErrorOption("multipleArrayIndexError"));
    220244  }
    221245 
     
    294318      {
    295319        BioMaterialEvent creationEvent = hyb.getCreationEvent();
     320        int currentIndex = creationEvent.getSourceGroup(parent);
    296321        Float usedQuantity = usedQuantityMapper == null ?
    297322            null : usedQuantityMapper.getFloat(data);
     
    300325        {
    301326          Integer arrayIndex = arrayIndexMapper.getInt(data);
    302           if (arrayIndex != null) creationEvent.setSourceGroup(parent, arrayIndex);
     327          if (arrayIndex != null)
     328          {
     329            if (currentIndex != 0 && arrayIndex != currentIndex && failIfMultipleArrayIndex)
     330            {
     331              throw new InvalidDataException("Labeled extract '" + parent.getName() +
     332                  "' is already associated with array index " + currentIndex +
     333                  " on hybridization '" + hyb.getName() + "'. It is not possible to " +
     334                  "also associate it with array index " + arrayIndex);
     335            }
     336            creationEvent.setSourceGroup(parent, arrayIndex);
     337          }
    303338        }
    304339      }
Note: See TracChangeset for help on using the changeset viewer.