Changeset 6465


Ignore:
Timestamp:
Nov 3, 2021, 1:39:48 PM (15 months ago)
Author:
Nicklas Nordborg
Message:

References #1347: Updates to registration of specimen handled by external lab

The library importer will now select the plate type depending on the format of the Plate well value. If the value is digit:digit the STRIP_1x8 is selected otherwise the PLATE_8x12.

Location:
extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/plugins/FutureSpecimenImporter.java

    r6353 r6465  
    415415    else
    416416    {
    417       BioplateType plateType = BioplateType.EXTERNAL_LIBRARY;
     417      BioplateType plateType = info.libPlateType;
     418      if (plateType == null) plateType = BioplateType.EXTERNAL_LIBRARY; // Should not happen if LibraryInfo.valid==TRUE
    418419      plate = BioPlate.getNew(dc, plateType.getPlateGeometry(dc), plateType.get(dc));
    419420      plate.setName(plateType.getNextPlateName(dc, true));
  • extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/plugins/cmd/LibraryInfo.java

    r6463 r6465  
    4747  public Protocol protocol;
    4848  public BioPlate libPlate;
     49  public BioplateType libPlateType = BioplateType.EXTERNAL_LIBRARY;
    4950 
    5051  public boolean valid;
     
    5556    {
    5657      plateId = section.getRequiredEntry("Plate name", PatternValidator.CMD_ID);
    57       well = section.getRequiredEntry("Plate well", PlateWellValidator.PLATE_8x12);
     58      ValidPlateCoordinateWithType plateWell = section.getRequiredEntry("Plate well", PlateOrStripValidator.INSTANCE);
     59      if (plateWell != null)
     60      {
     61        well = plateWell.plateCoordinate;
     62        libPlateType = plateWell.plateType;
     63      }
    5864 
    5965      if (plateId != null && well != null && ctx != null)
     
    6369        {
    6470          String coordinate = Coordinate.numericToAlpha(well.getRow()+1)+(well.getColumn()+1);
    65           String msg = "LibPlate well ["+coordinate+"; ExternalRef="+plateId+"] duplicated in file: ";
     71          String msg = "Plate well ["+coordinate+"; ExternalRef="+plateId+"] duplicated in file: ";
    6672          section.addErrorMessage(msg+duplicate.getFile().getName());
    6773          duplicate.addErrorMessage(msg+section.getFile().getName());
     
    6975      }
    7076     
    71       if (plateId != null) libPlate = findExistingLibPlate(plateId, section);
     77      if (plateId != null) libPlate = findExistingLibPlate(plateId, libPlateType, section);
    7278      if (libPlate != null && well != null)
    7379      {
     
    8288     
    8389      barcode = section.getRequiredEntry("Barcode", BarcodeValidator.INSTANCE);
    84       // TODO -- protocol
    8590      protocol = section.getRequiredEntry("Protocol", ProtocolValidator.LIB_PROTOCOL);
    8691    }
     
    8893  }
    8994 
    90   private BioPlate findExistingLibPlate(String plateId, JsonSection section)
     95  private BioPlate findExistingLibPlate(String plateId, BioplateType plateType, JsonSection section)
    9196  {
    9297    BioPlate libPlate = null;
     
    9499    ItemQuery<BioPlate> query = BioPlate.getQuery();
    95100    query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    96     BioplateType.EXTERNAL_LIBRARY.addFilter(dc, query, false);
     101    if (plateType != null)
     102    {
     103      plateType.addFilter(dc, query, false);
     104    }
    97105    query.join(Annotations.innerJoin(null, Annotationtype.EXTERNAL_REF.load(dc), "eref"));
    98106    query.restrict(Restrictions.eq(Hql.alias("eref"), Expressions.string(plateId)));
     
    196204  }
    197205
     206  /**
     207    Validator implementation that delegates to either STRIP_1x8 validator if
     208    the coordinate is specified as 'digit:digit' or to PLATE_8x12 otherwise.
     209    @since 4.33.4
     210  */
     211  static class PlateOrStripValidator
     212    implements ValueValidator<String, ValidPlateCoordinateWithType>
     213  {
     214    static final PlateOrStripValidator INSTANCE = new PlateOrStripValidator();
     215   
     216    @Override
     217    public Class<String> getExpectedClass()
     218    {
     219      return String.class;
     220    }
     221
     222    @Override
     223    public ValidPlateCoordinateWithType isValid(DbControl dc, String value, JsonSection section, String entryKey)
     224    {
     225      ValidPlateCoordinateWithType result = new ValidPlateCoordinateWithType();
     226      PlateWellValidator validator;
     227      if (value.matches("\\d\\:\\d"))
     228      {
     229        validator = PlateWellValidator.STRIP_1x8;
     230        result.plateType = BioplateType.EXTERNAL_LIBRARY_STRIP;
     231      }
     232      else
     233      {
     234        validator = PlateWellValidator.PLATE_8x12;
     235        result.plateType = BioplateType.EXTERNAL_LIBRARY;
     236      }
     237      result.plateCoordinate = validator.isValid(dc, value, section, entryKey);
     238      return result;
     239    }
     240  }
     241 
     242  /**
     243    Holds the validated plate type and coordinate.
     244  */
     245  static class ValidPlateCoordinateWithType
     246  {
     247    PlateCoordinate plateCoordinate;
     248    BioplateType plateType;
     249  }
    198250}
  • extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/plugins/cmd/PlateWellValidator.java

    r6460 r6465  
    2525  */
    2626  public static final PlateWellValidator PLATE_8x12 = new PlateWellValidator(8, 12);
     27 
     28  /**
     29    Validator for strips with 1 row and 8 columns.
     30    @since 4.33.4
     31  */
     32  public static final PlateWellValidator STRIP_1x8 = new PlateWellValidator(1, 8);
    2733 
    2834  /**
Note: See TracChangeset for help on using the changeset viewer.