Changeset 6206
- Timestamp:
- Apr 12, 2021, 12:52:13 PM (13 months ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/batch/import-external-specimen.js
r6205 r6206 99 99 html += '</td>'; 100 100 html += '<td class="valid dottedleft">'; 101 var startNo = 1; 101 102 if (jsonFile && jsonFile.errors) 102 103 { 103 html += '<div class="messagecontainer error"><ol >';104 html += '<div class="messagecontainer error"><ol start="'+startNo+'">'; 104 105 for (var errNo = 0; errNo < jsonFile.errors.length; errNo++) 105 106 { 106 107 html += '<li>'+Strings.encodeTags(jsonFile.errors[errNo]); 107 108 } 108 html += '</ol><div>'; 109 } 110 else if (jsonFile && jsonFile.warnings) 111 { 112 html += '<div">'+Strings.encodeTags(jsonFile.warnings.join('<br>'))+'</div>'; 109 html += '</ol></div>'; 110 startNo += jsonFile.errors.length; 111 } 112 if (jsonFile && jsonFile.warnings) 113 { 114 html += '<div class="messagecontainer note"><ol start="'+startNo+'">'; 115 for (var warnNo = 0; warnNo < jsonFile.warnings.length; warnNo++) 116 { 117 html += '<li>'+Strings.encodeTags(jsonFile.warnings[warnNo]); 118 } 119 html += '</ol></div>'; 120 startNo += jsonFile.warnings.length; 113 121 } 114 122 html += '</td>'; -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/DateValidator.java
r6205 r6206 6 6 7 7 import net.sf.basedb.core.DbControl; 8 import net.sf.basedb.reggie.Reggie; 8 9 9 10 … … 15 16 */ 16 17 public class DateValidator 17 implements ValueValidator<String, Date> 18 implements ValueValidator<String, Date>, Cloneable 18 19 { 19 20 /** … … 36 37 private final DateFormat dateFormat; 37 38 39 private Date notAfter; 40 private Date notBefore; 41 38 42 public DateValidator(String format) 39 43 { … … 42 46 } 43 47 48 /** 49 Wrap this date validator with a validator that issue a warning 50 if the date is in the future. 51 */ 52 public DateValidator warnIfFuture() 53 { 54 DateValidator wrap; 55 try 56 { 57 wrap = (DateValidator)this.clone(); 58 wrap.notAfter = new Date(); 59 } 60 catch (CloneNotSupportedException e) 61 { 62 throw new UnsupportedOperationException("clone()"); 63 } 64 return wrap; 65 } 66 67 /** 68 Wrap this date validator with a validator that issue a warning 69 if the date is in the future or older than the specified number of 70 days. 71 */ 72 public DateValidator warnIfFutureOrOlder(int numDays) 73 { 74 DateValidator wrap = warnIfFuture(); 75 wrap.notBefore = new Date(wrap.notAfter.getTime()-numDays*86400l*1000l); 76 return wrap; 77 } 78 79 /** 80 Wrap this date validator with a validator that issue a warning 81 if the date is in the future or older than the specified date. 82 */ 83 public DateValidator warnIfFutureOrOlder(Date oldDate) 84 { 85 DateValidator wrap = warnIfFuture(); 86 wrap.notBefore = oldDate; 87 return wrap; 88 } 89 44 90 @Override 45 91 public Date isValid(DbControl dc, String value, JsonSection section, String entryKey) 46 92 { 93 Date result = null; 47 94 try 48 95 { 49 re turndateFormat.parse(value);96 result = dateFormat.parse(value); 50 97 } 51 98 catch (Exception ex) … … 53 100 section.addErrorMessage("Invalid date in JSON: "+entryKey+"="+value+" (expected format: "+format+")"); 54 101 } 55 return null; 102 if (result != null) 103 { 104 if (notAfter != null && result.after(notAfter)) 105 { 106 section.addWarningMessage("Future date in JSON: "+entryKey+"="+value); 107 } 108 if (notBefore != null && result.before(notBefore)) 109 { 110 section.addWarningMessage("Old date in JSON: "+entryKey+"="+value+ 111 " (expected after "+Reggie.CONVERTER_DATE_TO_STRING_WITH_SEPARATOR.format(notBefore)+")"); 112 } 113 } 114 return result; 56 115 } 57 116 -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/IntValidator.java
r6203 r6206 12 12 */ 13 13 public class IntValidator 14 implements ValueValidator<Object, Integer> 14 implements ValueValidator<Object, Integer>, Cloneable 15 15 { 16 16 /** … … 33 33 private List<Integer> allowed; 34 34 35 private Integer softMax; 36 private Integer softMin; 37 35 38 /** 36 39 Allow all integers. … … 42 45 Allow all integers between min and max (inclusive). 43 46 Null values are allowed and mean no limit. 47 Report either as error or warnings. 44 48 */ 45 49 public IntValidator(Integer min, Integer max) … … 55 59 { 56 60 this.allowed = allowed; 61 } 62 63 /** 64 Wrap this validator with a validator that create warnings 65 if the value is below the softMin or above the softMax limits. 66 */ 67 public IntValidator warnIf(Integer softMin, Integer softMax) 68 { 69 IntValidator wrap; 70 try 71 { 72 wrap = (IntValidator)this.clone(); 73 wrap.softMax = softMax; 74 wrap.softMin = softMin; 75 } 76 catch (CloneNotSupportedException e) 77 { 78 throw new UnsupportedOperationException("clone()"); 79 } 80 return wrap; 57 81 } 58 82 … … 97 121 } 98 122 } 123 if (result != null) 124 { 125 if (softMin != null && result < softMin) 126 { 127 section.addWarningMessage("Unexpected integer in JSON: "+entryKey+"="+value+" (expected >="+softMin+")"); 128 } 129 if (softMax != null && result > softMax) 130 { 131 section.addWarningMessage("Unexpected integer in JSON: "+entryKey+"="+value+" (expected <="+softMax+")"); 132 } 133 } 99 134 return result; 100 135 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LibraryInfo.java
r6205 r6206 63 63 } 64 64 65 libDate = section.getRequiredEntry("Date", DateValidator.YYYY_MM_DD );66 libSize = section.getRequiredEntry("Library size", IntValidator.POSITIVE );65 libDate = section.getRequiredEntry("Date", DateValidator.YYYY_MM_DD.warnIfFutureOrOlder(365)); 66 libSize = section.getRequiredEntry("Library size", IntValidator.POSITIVE.warnIf(150, 400)); 67 67 libMolarity = section.getRequiredEntry("Library molarity", FloatValidator.POSITIVE); 68 68 qubitConc = section.getRequiredEntry("Qubit concentration (ng/ul)", FloatValidator.POSITIVE); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LongValidator.java
r6204 r6206 11 11 */ 12 12 public class LongValidator 13 implements ValueValidator<Object, Long> 13 implements ValueValidator<Object, Long>, Cloneable 14 14 { 15 15 /** … … 26 26 private Long minValue; 27 27 private List<Long> allowed; 28 private Long softMax; 29 private Long softMin; 28 30 29 31 /** … … 50 52 this.allowed = allowed; 51 53 } 54 55 /** 56 Wrap this validator with a validator that create warnings 57 if the value is below the softMin or above the softMax limits. 58 */ 59 public LongValidator warnIf(Long softMin, Long softMax) 60 { 61 LongValidator wrap; 62 try 63 { 64 wrap = (LongValidator)this.clone(); 65 wrap.softMax = softMax; 66 wrap.softMin = softMin; 67 } 68 catch (CloneNotSupportedException e) 69 { 70 throw new UnsupportedOperationException("clone()"); 71 } 72 return wrap; 73 } 74 52 75 53 76 @Override … … 91 114 } 92 115 } 116 if (result != null) 117 { 118 if (softMin != null && result < softMin) 119 { 120 section.addWarningMessage("Unexpected long in JSON: "+entryKey+"="+value+" (expected >="+softMin+")"); 121 } 122 if (softMax != null && result > softMax) 123 { 124 section.addWarningMessage("Unexpected long in JSON: "+entryKey+"="+value+" (expected <="+softMax+")"); 125 } 126 } 93 127 return result; 94 128 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/MergeInfo.java
r6204 r6206 20 20 if (merge != null) 21 21 { 22 pfReads = merge.getRequiredEntry("PF_READS", LongValidator.POSITIVE );22 pfReads = merge.getRequiredEntry("PF_READS", LongValidator.POSITIVE.warnIf(10000000l, null)); // Warn if less than 10M reads 23 23 } 24 24 valid = merge != null && !merge.hasError(); -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/PoolInfo.java
r6205 r6206 46 46 verifyUnusedBarcode(pool, libInfo.barcode, section); 47 47 } 48 poolDate = section.getRequiredEntry("Date", DateValidator.YYYY_MM_DD );48 poolDate = section.getRequiredEntry("Date", DateValidator.YYYY_MM_DD.warnIfFutureOrOlder(365)); 49 49 operator = section.getRequiredEntry("Operator"); 50 50 } -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/SequencingRunInfo.java
r6205 r6206 49 49 position = section.getRequiredEntry("Position", PatternValidator.SEQUENCER_POSITION); 50 50 runNumber = section.getRequiredEntry("RunNumber", IntValidator.POSITIVE); 51 startDate = section.getRequiredEntry("StartDate", DateValidator.YYMMDD );52 endDate = section.getRequiredEntry("EndDate", DateValidator.YYMMDD_HH_MM_SS );51 startDate = section.getRequiredEntry("StartDate", DateValidator.YYMMDD.warnIfFutureOrOlder(365)); 52 endDate = section.getRequiredEntry("EndDate", DateValidator.YYMMDD_HH_MM_SS.warnIfFutureOrOlder(startDate)); 53 53 operator = section.getRequiredEntry("Operator"); 54 54 if (flowCellInfo.flowCell != null)
Note: See TracChangeset
for help on using the changeset viewer.