From 4ceb55069a3a565b6e7d2723ab2ed04fc02b63e5 Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Tue, 27 Aug 2024 11:26:12 +0200 Subject: [PATCH] NoReductionReducer produces no output --- .../DataReduction/NoReductionReducerTest.java | 11 ++------ .../DataReduction/NoReductionReducer.java | 17 ++---------- .../plotPage/ManualQC/ManualQCData.java | 27 +++++++++++-------- 3 files changed, 20 insertions(+), 35 deletions(-) diff --git a/WebApp/junit/uk/ac/exeter/QuinCe/data/Dataset/DataReduction/NoReductionReducerTest.java b/WebApp/junit/uk/ac/exeter/QuinCe/data/Dataset/DataReduction/NoReductionReducerTest.java index 3d76c52a8..47c7c68d1 100644 --- a/WebApp/junit/uk/ac/exeter/QuinCe/data/Dataset/DataReduction/NoReductionReducerTest.java +++ b/WebApp/junit/uk/ac/exeter/QuinCe/data/Dataset/DataReduction/NoReductionReducerTest.java @@ -1,11 +1,8 @@ package uk.ac.exeter.QuinCe.data.Dataset.DataReduction; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Properties; import org.flywaydb.test.annotation.FlywayTest; @@ -20,7 +17,7 @@ import uk.ac.exeter.QuinCe.web.system.ResourceManager; /** - * Test for the dummy {@link NoReductionReducer}. + * Test for the {@link NoReductionReducer}. */ public class NoReductionReducerTest extends DataReducerTest { @@ -55,10 +52,6 @@ public void testReduction() throws Exception { reducer.doCalculation(instrument, measurement, record, getDataSource().getConnection()); - assertEquals(9.889D, record.getCalculationValue("Water Temperature"), - 0.0001); - - List paramNames = Arrays.asList("Water Temperature"); - assertTrue(listsEqual(paramNames, reducer.getCalculationParameterNames())); + assertEquals(0, reducer.getCalculationParameterNames().size()); } } diff --git a/WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/DataReduction/NoReductionReducer.java b/WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/DataReduction/NoReductionReducer.java index b3ffdc4db..1d2623832 100644 --- a/WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/DataReduction/NoReductionReducer.java +++ b/WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/DataReduction/NoReductionReducer.java @@ -8,7 +8,6 @@ import uk.ac.exeter.QuinCe.data.Dataset.Measurement; import uk.ac.exeter.QuinCe.data.Instrument.Instrument; -import uk.ac.exeter.QuinCe.data.Instrument.SensorDefinition.SensorType; import uk.ac.exeter.QuinCe.data.Instrument.SensorDefinition.Variable; /** @@ -32,24 +31,12 @@ public NoReductionReducer(Variable variable, public void doCalculation(Instrument instrument, Measurement measurement, DataReductionRecord record, Connection conn) throws DataReductionException { - SensorType coreType = variable.getCoreSensorType(); - record.put(coreType.getShortName(), - measurement.getMeasurementValue(coreType).getCalculatedValue()); + // No actions taken } @Override public List getCalculationParameters() { - - // The output parameters are the core sensor types defined for the variable - - List result = new ArrayList(1); - - SensorType coreType = variable.getCoreSensorType(); - result.add(new CalculationParameter(makeParameterId(0), - coreType.getShortName(), coreType.getLongName(), coreType.getCodeName(), - coreType.getUnits(), true)); - - return result; + return new ArrayList(); } } diff --git a/WebApp/src/uk/ac/exeter/QuinCe/web/datasets/plotPage/ManualQC/ManualQCData.java b/WebApp/src/uk/ac/exeter/QuinCe/web/datasets/plotPage/ManualQC/ManualQCData.java index 25e81d667..174085ede 100644 --- a/WebApp/src/uk/ac/exeter/QuinCe/web/datasets/plotPage/ManualQC/ManualQCData.java +++ b/WebApp/src/uk/ac/exeter/QuinCe/web/datasets/plotPage/ManualQC/ManualQCData.java @@ -315,13 +315,15 @@ protected void buildColumnHeadings() { List variableHeadings = DataReducerFactory .getCalculationParameters(variable, true); - List variableQCHeadings = new ArrayList( - variableHeadings.size()); - variableHeadings.stream() - .forEach(x -> variableQCHeadings.add(new PlotPageColumnHeading(x))); - - columnHeadings.put(variable.getName(), variableQCHeadings); - extendedColumnHeadings.put(variable.getName(), variableQCHeadings); + if (variableHeadings.size() > 0) { + List variableQCHeadings = new ArrayList( + variableHeadings.size()); + variableHeadings.stream() + .forEach(x -> variableQCHeadings.add(new PlotPageColumnHeading(x))); + + columnHeadings.put(variable.getName(), variableQCHeadings); + extendedColumnHeadings.put(variable.getName(), variableQCHeadings); + } } catch (DataReductionException e) { error("Error getting variable headers", e); } @@ -491,10 +493,13 @@ public List generateTableDataRecords(int start, Arrays.asList(variableDataReduction.getMeasurementId())); } } else { - // Make blank columns - record.addBlankColumns( - columnHeadings.get(variable.getName()).size(), - PlotPageTableValue.DATA_REDUCTION_TYPE); + // Make blank columns because this measurement doesn't have data + // reduction for the variable. + if (columnHeadings.containsKey(variable.getName())) { + record.addBlankColumns( + columnHeadings.get(variable.getName()).size(), + PlotPageTableValue.DATA_REDUCTION_TYPE); + } } }