Changeset 6457
- Timestamp:
- Nov 1, 2021, 8:58:28 AM (15 months ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/FastqInfo.java
r6221 r6457 34 34 R1 = fastq.getRequiredEntry("R1", new FastqFile()); 35 35 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 } 39 46 } 40 47 valid = fastq != null && !fastq.hasError(); … … 55 62 FileMetaData info = new FileMetaData(); 56 63 tmp = session.readFile(directory+f.name, info); 57 f. size = info.getSize();64 f.actualSize = info.getSize(); 58 65 f.lastModified = info.getLastModifiedTime(); 59 if (f. size == 0)66 if (f.actualSize == 0) 60 67 { 61 68 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)"); 62 73 } 63 74 } … … 78 89 public String name; 79 90 public String md5; 80 public long size; 91 public Long expectedSize; 92 public long actualSize; 81 93 public long lastModified; 82 94 … … 102 114 j.put("name", name); 103 115 j.put("md5", md5); 104 j.put("size", size);116 j.put("size", actualSize); 105 117 j.put("lastModified", Reggie.CONVERTER_DATETIME_TO_STRING_WITH_SEPARATOR.convert(new Date(lastModified))); 106 118 return j; -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/JsonSection.java
r6217 r6457 89 89 Get an optional entry from the JSON file. A validator is 90 90 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). 92 92 */ 93 93 @SuppressWarnings("unchecked") 94 94 public <T, F> T getOptionalEntry(String key, ValueValidator<F, T> validator) 95 95 { 96 Object val = json.get(key);97 96 T result = null; 98 if ( validator != null)97 if (json.containsKey(key)) 99 98 { 100 if (val != null && !validator.getExpectedClass().isInstance(val)) 99 Object val = json.get(key); 100 if (validator != null) 101 101 { 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 } 104 118 } 105 119 else 106 120 { 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; 115 122 } 116 }117 else118 {119 result = (T)val;120 123 } 121 124 return result; -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LongValidator.java
r6217 r6457 16 16 Allow all long values. 17 17 */ 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); 19 25 20 26 /** 21 27 All positive values > 0. 22 28 */ 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); 24 36 37 private boolean allowNull; 25 38 private Long maxValue; 26 39 private Long minValue; … … 30 43 31 44 /** 32 Allow all integers.45 Allow all long values. 33 46 */ 34 public LongValidator() 35 {} 47 public LongValidator(boolean allowNull) 48 { 49 this.allowNull = allowNull; 50 } 36 51 37 52 /** … … 39 54 Null values are allowed and mean no limit. 40 55 */ 41 public LongValidator(Long min, Long max )56 public LongValidator(Long min, Long max, boolean allowNull) 42 57 { 43 58 this.minValue = min; 44 59 this.maxValue = max; 60 this.allowNull = allowNull; 45 61 } 46 62 … … 84 100 { 85 101 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) 87 110 { 88 111 result = ((Number)value).longValue();
Note: See TracChangeset
for help on using the changeset viewer.