Skip to content

Commit

Permalink
NoReductionReducer produces no output
Browse files Browse the repository at this point in the history
  • Loading branch information
squaregoldfish committed Aug 27, 2024
1 parent d4947ab commit 4ceb550
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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<String> paramNames = Arrays.asList("Water Temperature");
assertTrue(listsEqual(paramNames, reducer.getCalculationParameterNames()));
assertEquals(0, reducer.getCalculationParameterNames().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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<CalculationParameter> getCalculationParameters() {

// The output parameters are the core sensor types defined for the variable

List<CalculationParameter> result = new ArrayList<CalculationParameter>(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<CalculationParameter>();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,15 @@ protected void buildColumnHeadings() {
List<CalculationParameter> variableHeadings = DataReducerFactory
.getCalculationParameters(variable, true);

List<PlotPageColumnHeading> variableQCHeadings = new ArrayList<PlotPageColumnHeading>(
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<PlotPageColumnHeading> variableQCHeadings = new ArrayList<PlotPageColumnHeading>(
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);
}
Expand Down Expand Up @@ -491,10 +493,13 @@ public List<PlotPageTableRecord> 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);
}
}
}

Expand Down

0 comments on commit 4ceb550

Please sign in to comment.