Skip to content

Commit 7ce67d9

Browse files
(#2995) Detect instances where QC messages set without comments
Includes lookups, which at some points seem to get set without a source in the QC message field.
1 parent 206b479 commit 7ce67d9

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/DataSetDataDB.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ public static void storeSensorValues(Connection conn,
397397
}
398398
}
399399

400+
if (value.getUserQCFlag().commentRequired()
401+
&& StringUtils.isBlank(value.getUserQCMessage())) {
402+
throw new InvalidSensorValueException(
403+
"User QC message cannot be empty with flag "
404+
+ value.getUserQCFlag().getFlagValue(),
405+
value);
406+
}
407+
400408
updateStmt.setString(3, userQCMessage);
401409
updateStmt.setLong(4, value.getId());
402410

WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/DatasetSensorValues.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.javadocmd.simplelatlng.LatLng;
1414

1515
import uk.ac.exeter.QuinCe.data.Dataset.QC.Flag;
16+
import uk.ac.exeter.QuinCe.data.Dataset.QC.InvalidFlagException;
1617
import uk.ac.exeter.QuinCe.data.Instrument.DiagnosticQCConfig;
1718
import uk.ac.exeter.QuinCe.data.Instrument.FileDefinition;
1819
import uk.ac.exeter.QuinCe.data.Instrument.Instrument;
@@ -681,9 +682,11 @@ public DatasetSensorValues subset(TreeSet<LocalDateTime> times,
681682
* @return The {@link SensorValues} that have been changed as part of this
682683
* cascade.
683684
* @throws RecordNotFoundException
685+
* @throws InvalidFlagException
684686
*/
685687
public Set<SensorValue> applyQCCascade(SensorValue source,
686-
RunTypePeriods runTypePeriods) throws RecordNotFoundException {
688+
RunTypePeriods runTypePeriods)
689+
throws RecordNotFoundException, InvalidFlagException {
687690

688691
Set<SensorValue> changedValues = new HashSet<SensorValue>();
689692

WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/QC/Flag.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,4 +745,8 @@ public static Flag getMostSignificantFlag(Flag... flags) {
745745

746746
return result;
747747
}
748+
749+
public boolean commentRequired() {
750+
return flagValue == 3 || flagValue == 4 || flagValue == -200;
751+
}
748752
}

WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/SensorValue.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,25 +826,33 @@ public static double getMinimumChange(List<SensorValue> values) {
826826
*
827827
* @param source
828828
* The source of the QC flag
829+
* @throws InvalidFlagException
829830
*/
830-
public void setCascadingQC(SensorValue source) {
831+
public void setCascadingQC(SensorValue source) throws InvalidFlagException {
831832
SortedSet<Long> sources = userQCFlag.equals(Flag.LOOKUP)
832833
? StringUtils.delimitedToLongSet(userQCMessage)
833834
: new TreeSet<Long>();
834835

835836
sources.add(source.getId());
837+
836838
userQCFlag = Flag.LOOKUP;
837839
userQCMessage = StringUtils.collectionToDelimited(sources, ",");
838840
dirty = true;
839841
}
840842

841-
public void setCascadingQC(PlotPageTableValue source) {
843+
public void setCascadingQC(PlotPageTableValue source)
844+
throws InvalidFlagException {
842845
SortedSet<Long> sources = userQCFlag.equals(Flag.LOOKUP)
843846
? StringUtils.delimitedToLongSet(userQCMessage)
844847
: new TreeSet<Long>();
845848

846849
sources.addAll(source.getSources());
847850

851+
if (sources.size() == 0) {
852+
throw new InvalidFlagException(
853+
"Attempted to set LOOKUP flag with no source");
854+
}
855+
848856
userQCFlag = Flag.LOOKUP;
849857
userQCMessage = StringUtils.collectionToDelimited(sources, ",");
850858
dirty = true;

0 commit comments

Comments
 (0)