Changeset 6459


Ignore:
Timestamp:
Nov 1, 2021, 11:31:57 AM (15 months ago)
Author:
Nicklas Nordborg
Message:

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

The changes in [6457] and [6458] was committed to the trunk but they should have been in the reggie/4.33-stable branch. This update merge the same changes to the reggie/4.33-stable
branch.

Location:
extensions/net.sf.basedb.reggie/branches/4.33-stable
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/branches/4.33-stable

  • extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/plugins/cmd/FastqInfo.java

    r6221 r6459  
    3434      R1 = fastq.getRequiredEntry("R1", new FastqFile());
    3535      R2 = fastq.getRequiredEntry("R2", new FastqFile());
    36       // TODO -- wait and see
    37       if (R1 != null) R1.md5 = fastq.getOptionalEntry("R1 MD5", PatternValidator.MD5);
    38       if (R2 != null) R2.md5 = fastq.getOptionalEntry("R2 MD5", PatternValidator.MD5);
     36      if (R1 != null)
     37      {
     38        //R1.md5 = fastq.getOptionalEntry("R1 MD5", PatternValidator.MD5);
     39        R1.expectedSize = fastq.getOptionalEntry("R11size", LongValidator.POSITIVE_OR_NULL);
     40      }
     41      if (R2 != null)
     42      {
     43        //R2.md5 = fastq.getOptionalEntry("R2 MD5", PatternValidator.MD5);
     44        R2.expectedSize = fastq.getOptionalEntry("R2size", LongValidator.POSITIVE_OR_NULL);
     45      }
    3946    }
    4047    valid = fastq != null && !fastq.hasError();
     
    5562      FileMetaData info = new FileMetaData();
    5663      tmp = session.readFile(directory+f.name, info);
    57       f.size = info.getSize();
     64      f.actualSize = info.getSize();
    5865      f.lastModified = info.getLastModifiedTime();
    59       if (f.size == 0)
     66      if (f.actualSize == 0)
    6067      {
    6168        section.addErrorMessage("FASTQ file is missing: " + f.name);
     69      }
     70      else if (f.expectedSize != null && f.actualSize != f.expectedSize)
     71      {
     72        section.addErrorMessage("FASTQ file size: "+f.name+"="+f.actualSize+" (expected "+f.expectedSize+" bytes)");
    6273      }
    6374    }
     
    7889    public String name;
    7990    public String md5;
    80     public long size;
     91    public Long expectedSize;
     92    public long actualSize;
    8193    public long lastModified;
    8294   
     
    102114      j.put("name", name);
    103115      j.put("md5", md5);
    104       j.put("size", size);
     116      j.put("size", actualSize);
    105117      j.put("lastModified", Reggie.CONVERTER_DATETIME_TO_STRING_WITH_SEPARATOR.convert(new Date(lastModified)));
    106118      return j;
  • extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/plugins/cmd/JsonSection.java

    r6217 r6459  
    8989    Get an optional entry from the JSON file. A validator is
    9090    optional, but if a validator is given it will be called
    91     also for null values.
     91    also for null values (but not if the entry is missing).
    9292  */
    9393  @SuppressWarnings("unchecked")
    9494  public <T, F> T getOptionalEntry(String key, ValueValidator<F, T> validator)
    9595  {
    96     Object val = json.get(key);
    9796    T result = null;
    98     if (validator != null)
     97    if (json.containsKey(key))
    9998    {
    100       if (val != null && !validator.getExpectedClass().isInstance(val))
     99      Object val = json.get(key);
     100      if (validator != null)
    101101      {
    102         addErrorMessage("Invalid entry in JSON: "+section+"."+key+"="+val+
    103           " (expected "+validator.getExpectedClass().getSimpleName()+", got " + val.getClass().getSimpleName()+")");
     102        if (val != null && !validator.getExpectedClass().isInstance(val))
     103        {
     104          addErrorMessage("Invalid entry in JSON: "+section+"."+key+"="+val+
     105            " (expected "+validator.getExpectedClass().getSimpleName()+", got " + val.getClass().getSimpleName()+")");
     106        }
     107        else
     108        {
     109          try
     110          {
     111            result = validator.isValid(file.dc(), (F)val, this, section+"."+key);
     112          }
     113          catch (Exception ex)
     114          {
     115            addErrorMessage("Invalid entry in JSON: "+section+"."+key+"="+val+" ("+ex.getMessage()+")");
     116          }
     117        }
    104118      }
    105119      else
    106120      {
    107         try
    108         {
    109           result = validator.isValid(file.dc(), (F)val, this, section+"."+key);
    110         }
    111         catch (Exception ex)
    112         {
    113           addErrorMessage("Invalid entry in JSON: "+section+"."+key+"="+val+" ("+ex.getMessage()+")");
    114         }
     121        result = (T)val;
    115122      }
    116     }
    117     else
    118     {
    119       result = (T)val;
    120123    }
    121124    return result;
  • extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/plugins/cmd/LongValidator.java

    r6217 r6459  
    1616    Allow all long values.
    1717  */
    18   public static final LongValidator ALL = new LongValidator();
     18  public static final LongValidator ALL = new LongValidator(false);
     19 
     20  /**
     21    All all long and null values.
     22    @since 4.33.4
     23  */
     24  public static final LongValidator ALL_OR_NULL = new LongValidator(true);
    1925 
    2026  /**
    2127    All positive values > 0.
    2228  */
    23   public static final LongValidator POSITIVE = new LongValidator(1l, null);
     29  public static final LongValidator POSITIVE = new LongValidator(1l, null, false);
     30
     31  /**
     32    All positive values > 0 or null.
     33    @since 4.33.4
     34  */
     35  public static final LongValidator POSITIVE_OR_NULL = new LongValidator(1l, null, true);
    2436 
     37  private boolean allowNull;
    2538  private Long maxValue;
    2639  private Long minValue;
     
    3043 
    3144  /**
    32     Allow all integers.
     45    Allow all long values.
    3346  */
    34   public LongValidator()
    35   {}
     47  public LongValidator(boolean allowNull)
     48  {
     49    this.allowNull = allowNull;
     50  }
    3651 
    3752  /**
     
    3954    Null values are allowed and mean no limit.
    4055  */
    41   public LongValidator(Long min, Long max)
     56  public LongValidator(Long min, Long max, boolean allowNull)
    4257  {
    4358    this.minValue = min;
    4459    this.maxValue = max;
     60    this.allowNull = allowNull;
    4561  }
    4662 
     
    84100  {
    85101    Long result = null;
    86     if (value instanceof Number)
     102    if (value == null)
     103    {
     104      if (!allowNull)
     105      {
     106        section.addErrorMessage("Missing long in JSON: "+entryKey);
     107      }
     108    }
     109    else if (value instanceof Number)
    87110    {
    88111      result = ((Number)value).longValue();
  • extensions/net.sf.basedb.reggie/branches/4.33-stable/src/net/sf/basedb/reggie/plugins/cmd/SpecimenInfo.java

    r6341 r6459  
    4040    if (section != null)
    4141    {
    42       if (main.idRef.idType == SampleIdType.CASE)
     42      if (main.idRef != null && main.idRef.idType == SampleIdType.CASE)
    4343      {
    4444        pad = section.getRequiredEntry("PAD", PatternValidator.PAD);
Note: See TracChangeset for help on using the changeset viewer.