Commit 9a5810cd authored by PECQUOT's avatar PECQUOT

[fix] Grouped measurements: automatic calculation and saving into parent beans...

[fix] Grouped measurements: automatic calculation and saving into parent beans has been replaced by unique function executed at observation saving (Mantis #51725 and #51737)
[fix] PIT protocol: section calculation fixed (Mantis #51710)
[fix] Upgrade quadrige3-core to version 3.6.14 (Mantis #51731)
Signed-off-by: PECQUOT's avatarlp1ee9d <ludovic.pecquot@e-is.pro>
parent 8538694d
## Sprint 91 - v3.9.9
- Pas de mise à jour de modèle
## Sprint 90 - v3.9.8
- Pas de mise à jour de modèle
......
......@@ -171,7 +171,7 @@
<maven.compiler.debug>true</maven.compiler.debug>
<!-- Quadrige3 Core version -->
<quadrige3-core.version>3.6.13</quadrige3-core.version>
<quadrige3-core.version>3.6.14-SNAPSHOT</quadrige3-core.version>
<!-- Last ReefDb launcher version -->
<launcherVersion>3.0.3</launcherVersion>
......
......@@ -24,11 +24,14 @@ package fr.ifremer.reefdb.dto;
*/
import fr.ifremer.quadrige3.core.dao.referential.UnitId;
import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @author ludovic.pecquot@e-is.pro on 13/04/2017.
......@@ -54,4 +57,38 @@ public class ReefDbBeansTest {
Assert.assertEquals(60, result.intValue());
}
@Test
public void testReduce() {
List<MeasurementDTO> beans = new ArrayList<>();
{
MeasurementDTO bean = ReefDbBeanFactory.newMeasurementDTO();
bean.setId(1);
beans.add(bean);
}
{
MeasurementDTO bean = ReefDbBeanFactory.newMeasurementDTO();
bean.setId(-2);
beans.add(bean);
}
{
MeasurementDTO bean = ReefDbBeanFactory.newMeasurementDTO();
bean.setId(null);
beans.add(bean);
}
{
MeasurementDTO bean = ReefDbBeanFactory.newMeasurementDTO();
bean.setId(4);
beans.add(bean);
}
int minNegativeId = beans.stream()
.filter(measurementDTO -> measurementDTO.getId() != null)
.mapToInt(MeasurementDTO::getId)
.min().orElse(0);
Assert.assertEquals(-2, minNegativeId);
}
}
......@@ -82,10 +82,13 @@ public class SaveAction extends AbstractReefDbSaveAction<ObservationUIModel, Obs
return false;
}
// TODO Must save partial models from tabs
getUI().getSurveyDetailsTabUI().getHandler().saveActualModel();
// getUI().getPrelevementGeneralTabUI().getHandler().saveActualModel();
getUI().getPhotosTabUI().getHandler().saveActualModel();
// Save partial models from tabs
getUI().getSurveyDetailsTabUI().getHandler().save();
getUI().getPhotosTabUI().getHandler().save();
// Save and control measurements tabs (Mantis #51725)
getUI().getSurveyMeasurementsTabUI().getHandler().save();
getUI().getOperationMeasurementsTabUI().getHandler().save();
return true;
}
......@@ -142,11 +145,11 @@ public class SaveAction extends AbstractReefDbSaveAction<ObservationUIModel, Obs
public void postSuccessAction() {
super.postSuccessAction();
getHandler().refreshModels();
// show error messages
showControlResult(controlMessages, false);
getHandler().refreshModels();
// Postpone model modify state (Mantis #50915)
SwingUtilities.invokeLater(() -> getModel().setModify(false));
......
......@@ -23,6 +23,7 @@ package fr.ifremer.reefdb.ui.swing.content.observation.operation.measurement;
* #L%
*/
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
......@@ -56,10 +57,7 @@ import org.nuiton.jaxx.application.swing.tab.TabHandler;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import static org.nuiton.i18n.I18n.t;
......@@ -114,16 +112,16 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
// Initialisation des prelevements
initBeanFilterableComboBox(
getUI().getSelectionPrelevementsCombo(),
getModel().getSamplings(),
getModel().getSampling(),
DecoratorService.CONCAT);
getUI().getSelectionPrelevementsCombo(),
getModel().getSamplingOperations(),
getModel().getSampling(),
DecoratorService.CONCAT);
// Initialisation des groupe de taxons
initBeanFilterableComboBox(
getUI().getSelectionGroupeTaxonCombo(),
null,
null, DecoratorService.NAME);
getUI().getSelectionGroupeTaxonCombo(),
null,
null, DecoratorService.NAME);
getUI().getSelectionGroupeTaxonCombo().setActionEnabled(getContext().getDataContext().isContextFiltered(FilterTypeValues.TAXON_GROUP));
getUI().getSelectionGroupeTaxonCombo().setActionListener(e -> {
......@@ -135,9 +133,9 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
// Intialisation des taxons
initBeanFilterableComboBox(
getUI().getSelectionTaxonCombo(),
null,
null);
getUI().getSelectionTaxonCombo(),
null,
null);
getUI().getSelectionTaxonCombo().setActionEnabled(getContext().getDataContext().isContextFiltered(FilterTypeValues.TAXON));
getUI().getSelectionTaxonCombo().setActionListener(e -> {
......@@ -180,17 +178,37 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
getModel().setAdjusting(false);
});
PropertyChangeListener loadListener = new PropertyChangeListener() {
Map<String, Boolean> eventMap = new HashMap<>(ImmutableMap.of(
OperationMeasurementsUngroupedTableUIModel.EVENT_MEASUREMENTS_LOADED, false,
OperationMeasurementsGroupedTableUIModel.EVENT_INDIVIDUAL_MEASUREMENTS_LOADED, false
));
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (isEventComplete(evt.getPropertyName())) {
// detect if the triplet of PMFM for transition length
detectPmfmForTransitionCalculator();
detectPitPmfmForGridInitialization();
resetEventMap();
}
}
private boolean isEventComplete(String propertyName) {
if (eventMap.containsKey(propertyName))
eventMap.put(propertyName, true);
return eventMap.values().stream().allMatch(aBoolean -> aBoolean);
}
private void resetEventMap() {
eventMap.keySet().forEach(key -> eventMap.put(key, false));
}
};
// add listeners on table models
getModel().getUngroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsUngroupedTableUIModel.EVENT_MEASUREMENTS_LOADED, evt -> {
// detect if the triplet of PMFM for transition length
detectPmfmForTransitionCalculator();
detectPitPmfmForGridInitialization();
});
getModel().getGroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsGroupedTableUIModel.EVENT_MEASUREMENTS_LOADED, evt -> {
// detect if the triplet of PMFM for transition length
detectPmfmForTransitionCalculator();
detectPitPmfmForGridInitialization();
});
getModel().getUngroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsUngroupedTableUIModel.EVENT_MEASUREMENTS_LOADED, loadListener);
getModel().getGroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsGroupedTableUIModel.EVENT_INDIVIDUAL_MEASUREMENTS_LOADED, loadListener);
// Add listeners on PROPERTY_ROWS_IN_ERROR to catch modifications and revalidate
getModel().getUngroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsUngroupedTableUIModel.PROPERTY_ROWS_IN_ERROR, evt -> {
......@@ -218,7 +236,7 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
getUI().getSelectionGroupeTaxonCombo().setActionEnabled(!forceNoFilter && getContext().getDataContext().isContextFiltered(FilterTypeValues.TAXON_GROUP));
List<TaxonGroupDTO> taxonGroups = getModel().getObservationUIHandler().getAvailableTaxonGroups(taxon,forceNoFilter);
List<TaxonGroupDTO> taxonGroups = getModel().getObservationUIHandler().getAvailableTaxonGroups(taxon, forceNoFilter);
getUI().getSelectionGroupeTaxonCombo().setData(taxonGroups);
......@@ -287,7 +305,7 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
List<PmfmStrategyDTO> pmfmStrategies = ReefDbBeans.filterCollection(survey.getPmfmStrategies(), input -> input != null && input.isSampling());
// list available samplings
getUI().getSelectionPrelevementsCombo().setData(getModel().getSamplings());
getUI().getSelectionPrelevementsCombo().setData(getModel().getSamplingOperations());
// Load ungrouped data (up table)
{
......@@ -301,9 +319,9 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
}
// Load other Pmfms in sampling operations
if (CollectionUtils.isNotEmpty(getModel().getSamplings())) {
if (CollectionUtils.isNotEmpty(getModel().getSamplingOperations())) {
// populate pmfms from strategy to sampling operation and vice versa
for (SamplingOperationDTO samplingOperation : getModel().getSamplings()) {
for (SamplingOperationDTO samplingOperation : getModel().getSamplingOperations()) {
ReefDbBeans.fillListsEachOther(samplingOperation.getPmfms(), pmfms);
}
}
......@@ -330,9 +348,9 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
}
// Load other Pmfms in sampling operations
if (CollectionUtils.isNotEmpty(getModel().getSamplings())) {
if (CollectionUtils.isNotEmpty(getModel().getSamplingOperations())) {
// populate pmfms from strategy to sampling operation and vice versa
for (SamplingOperationDTO samplingOperation : getModel().getSamplings()) {
for (SamplingOperationDTO samplingOperation : getModel().getSamplingOperations()) {
ReefDbBeans.fillListsEachOther(samplingOperation.getIndividualPmfms(), individualPmfms);
}
}
......@@ -345,8 +363,8 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
}
//update selected sampling
if (getContext().getSelectedSamplingOperationId() != null && getModel().getSamplings() != null) {
for (SamplingOperationDTO samplingOperation : getModel().getSamplings()) {
if (getContext().getSelectedSamplingOperationId() != null && getModel().getSamplingOperations() != null) {
for (SamplingOperationDTO samplingOperation : getModel().getSamplingOperations()) {
if (getContext().getSelectedSamplingOperationId().equals(samplingOperation.getId())) {
getModel().setSampling(samplingOperation);
break;
......@@ -394,13 +412,13 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
private void detectPmfmForTransitionCalculator() {
if (CollectionUtils.isEmpty(getModel().getUngroupedTableUIModel().getPmfmColumns())
|| CollectionUtils.isEmpty(getModel().getGroupedTableUIModel().getPmfmColumns())) {
|| CollectionUtils.isEmpty(getModel().getGroupedTableUIModel().getPmfmColumns())) {
// both tables must have pmfm columns
return;
}
List<Integer[]> transitionLengthPmfmTriplets = getConfig().getCalculatedTransitionLengthPmfmTriplets();
for (Integer[] transitionLengthPmfmTriplet: transitionLengthPmfmTriplets) {
for (Integer[] transitionLengthPmfmTriplet : transitionLengthPmfmTriplets) {
int transitionLengthPmfmId = transitionLengthPmfmTriplet[0];
int startPositionPmfmId = transitionLengthPmfmTriplet[1];
......@@ -435,7 +453,6 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
getModel().getGroupedTableUIModel().setCalculatedLengthEndPositionPmfmId(endPositionPmfmId);
getModel().getGroupedTableUIModel().setCalculatedLengthTransitionPmfmId(transitionLengthPmfmId);
// set the transition length column non editable
transitionLengthColumn.setEditable(false);
transitionLengthColumn.getPmfmIdentifier().setNotMandatory();
......@@ -450,17 +467,22 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
map.put(ungroupedRow.getName(), (BigDecimal) startPositionColumn.getPmfmIdentifier().getValue(ungroupedRow));
}
// Remove previous calculator
if (transitionLengthCalculator != null) {
getModel().getGroupedTableUIModel().removePropertyChangeListener(OperationMeasurementsGroupedTableUIModel.PROPERTY_SAMPLING_OPERATION, transitionLengthCalculator);
}
// create calculator
TransitionLengthCalculator calculator = new TransitionLengthCalculator(map,
startPositionColumn.getPmfmIdentifier(),
endPositionColumn.getPmfmIdentifier(),
transitionLengthColumn.getPmfmIdentifier());
transitionLengthCalculator = new TransitionLengthCalculator(map,
startPositionColumn.getPmfmIdentifier(),
endPositionColumn.getPmfmIdentifier(),
transitionLengthColumn.getPmfmIdentifier());
startPositionColumn.getPmfmIdentifier().addPropertyChangeListener(calculator);
endPositionColumn.getPmfmIdentifier().addPropertyChangeListener(calculator);
startPositionColumn.getPmfmIdentifier().addPropertyChangeListener(transitionLengthCalculator);
endPositionColumn.getPmfmIdentifier().addPropertyChangeListener(transitionLengthCalculator);
// add also property change listener on sampling operation column (when a sampling operation in a row has changed) (Mantis #0027395)
getModel().getGroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsGroupedTableUIModel.PROPERTY_SAMPLING_OPERATION, calculator);
getModel().getGroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsGroupedTableUIModel.PROPERTY_SAMPLING_OPERATION, transitionLengthCalculator);
}
}
......@@ -533,6 +555,8 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
return false;
}
private TransitionLengthCalculator transitionLengthCalculator;
private class TransitionLengthCalculator implements PropertyChangeListener {
private final Map<String, BigDecimal> startPositionMap;
......@@ -625,4 +649,25 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
getUI().getGroupedTable().getOperationGroupedMeasurementTable().repaint();
}
}
public void save() {
try {
// Disable filter
getModel().getUngroupedTableUIModel().setSamplingFilter(null);
getModel().getGroupedTableUIModel().setMeasurementFilter(new MeasurementsFilter());
// save ungrouped measurements
getUI().getUngroupedTable().getHandler().save();
// save grouped measurements
getUI().getGroupedTable().getHandler().save();
} finally {
doSearch();
}
}
}
......@@ -122,11 +122,11 @@ public class OperationMeasurementsTabUIModel extends AbstractEmptyUIModel<Operat
}
/**
* <p>getSamplings.</p>
* <p>getSamplingOperations.</p>
*
* @return a {@link java.util.List} object.
*/
public List<SamplingOperationDTO> getSamplings() {
public List<SamplingOperationDTO> getSamplingOperations() {
return observationModel == null ? null : (List<SamplingOperationDTO>) observationModel.getSamplingOperations();
}
......
......@@ -24,7 +24,6 @@ package fr.ifremer.reefdb.ui.swing.content.observation.operation.measurement.gro
*/
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import fr.ifremer.quadrige3.core.dao.technical.AlphanumericComparator;
import fr.ifremer.quadrige3.ui.swing.table.ColumnIdentifier;
import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
......@@ -51,8 +50,6 @@ import javax.swing.RowFilter;
import javax.swing.border.Border;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
......@@ -226,23 +223,17 @@ public class OperationMeasurementsGroupedTableUIHandler
// remove measurement from old sampling
if (oldValue != null) {
SamplingOperationDTO oldSamplingOperation = (SamplingOperationDTO) oldValue;
oldSamplingOperation.removeAllIndividualMeasurements(row.getIndividualMeasurements());
oldSamplingOperation.setDirty(true);
resetIndividualMeasurementIds(row);
setDirty(oldSamplingOperation);
}
// recalculate individual id
if (newValue != null) {
// affect new sampling operation now
row.setSamplingOperation((SamplingOperationDTO) newValue);
// calculate new individual ids
calculateIndividualIds(row);
// fire event for parent listener
getModel().firePropertyChanged(OperationMeasurementsGroupedTableUIModel.PROPERTY_SAMPLING_OPERATION, null, newValue);
SamplingOperationDTO newSamplingOperation = (SamplingOperationDTO) newValue;
row.setSamplingOperation(newSamplingOperation);
setDirty(newSamplingOperation);
}
}
......@@ -250,36 +241,6 @@ public class OperationMeasurementsGroupedTableUIHandler
super.onRowModified(rowIndex, row, propertyName, propertyIndex, oldValue, newValue);
}
@Override
protected void onDuplicatedRowAdded(OperationMeasurementsGroupedRowModel row) {
// send update event on sampling operation
if (row.getSamplingOperation() != null) {
getModel().firePropertyChanged(OperationMeasurementsGroupedTableUIModel.PROPERTY_SAMPLING_OPERATION, null, row.getSamplingOperation());
}
}
@Override
protected void resetIndividualMeasurementIds(OperationMeasurementsGroupedRowModel row) {
// before, remove those measurements from sampling operation
if (row.getSamplingOperation() != null) {
row.getSamplingOperation().removeAllIndividualMeasurements(row.getIndividualMeasurements());
}
super.resetIndividualMeasurementIds(row);
}
/**
* the predicate test if the row is attached to the bean (=SamplingOperationDTO)
*
* @param bean the bean
* @return the predicate for sampling operation
*/
@Override
protected Predicate<? super OperationMeasurementsGroupedRowModel> getRowForBeanPredicate(MeasurementAware bean) {
return (Predicate<OperationMeasurementsGroupedRowModel>) row -> Objects.equals(bean, row.getSamplingOperation());
}
@Override
protected MeasurementAware getMeasurementAwareModelForRow(OperationMeasurementsGroupedRowModel row) {
return row.getSamplingOperation();
......@@ -381,30 +342,15 @@ public class OperationMeasurementsGroupedTableUIHandler
}
@Override
protected void removeIndividualMeasurements(List<MeasurementDTO> measurementToDelete) {
// updated sampling operation
Set<SamplingOperationDTO> updatedSamplingOperations = Sets.newHashSet();
// Remove from model
for (MeasurementDTO deletedMeasurement : measurementToDelete) {
if (deletedMeasurement.getSamplingOperation() != null) {
deletedMeasurement.getSamplingOperation().removeIndividualMeasurements(deletedMeasurement);
updatedSamplingOperations.add(deletedMeasurement.getSamplingOperation());
}
}
getModel().setModify(true);
// final update
for (SamplingOperationDTO updatedSamplingOperation : updatedSamplingOperations) {
updatedSamplingOperation.setDirty(true);
getModel().firePropertyChanged(OperationMeasurementsGroupedTableUIModel.PROPERTY_SAMPLING_OPERATION, null, updatedSamplingOperation);
}
protected boolean isMeasurementNotEmpty(MeasurementDTO measurement) {
return !measurement.getPmfm().getId().equals(getModel().getPitTransitionLengthPmfmId()) && super.isMeasurementNotEmpty(measurement);
}
@Override
protected boolean isMeasurementNotEmpty(MeasurementDTO measurement) {
return !measurement.getPmfm().getId().equals(getModel().getPitTransitionLengthPmfmId()) && super.isMeasurementNotEmpty(measurement);
protected void setDirty(MeasurementAware bean) {
super.setDirty(bean);
if (bean instanceof SamplingOperationDTO)
getModel().firePropertyChanged(OperationMeasurementsGroupedTableUIModel.PROPERTY_SAMPLING_OPERATION, null, bean);
}
/**
......@@ -440,16 +386,11 @@ public class OperationMeasurementsGroupedTableUIHandler
List<OperationMeasurementsGroupedRowModel> rows = Lists.newArrayList();
for (SamplingOperationDTO samplingOperation : initModel.getResultMap().keySet()) {
AtomicInteger individualId = new AtomicInteger();
for (Integer transition : initModel.getResultMap().get(samplingOperation)) {
// Compute next individual id
incrementNextIndividualId(samplingOperation, individualId);
// Initialize the row
OperationMeasurementsGroupedRowModel row = createNewRow(false, samplingOperation);
// Set the individualId
row.setIndividualId(individualId.get());
// Affect individual pmfms from parent model
row.setIndividualPmfms(new ArrayList<>(getModel().getPmfms()));
// Create empty measurements
......@@ -459,13 +400,12 @@ public class OperationMeasurementsGroupedTableUIHandler
if (measurement == null) {
throw new ReefDbTechnicalException("No transition measurement found");
}
// Set its value and individualId
// Set its value
measurement.setNumericalValue(BigDecimal.valueOf(transition));
measurement.setIndividualId(individualId.get());
row.setValid(true);
rows.add(row);
}
samplingOperation.setDirty(true);
setDirty(samplingOperation);
}
resetCellEditors();
......@@ -474,6 +414,20 @@ public class OperationMeasurementsGroupedTableUIHandler
}
}
@Override
protected boolean isRowToSave(OperationMeasurementsGroupedRowModel row) {
boolean toSave = super.isRowToSave(row);
if (toSave && getModel().getPitTransitionLengthPmfmId() != null) {
// If this row has been initialized but nothing else has been set, it can be ignored
Set<Integer> pmfmIds = ReefDbBeans.getPmfmIdsOfNonEmptyIndividualMeasurements(row);
pmfmIds.remove(getModel().getPitTransitionLengthPmfmId());
toSave = !pmfmIds.isEmpty() || row.hasTaxonInformation();
}
return toSave;
}
public void editSelectedMeasurements() {
OperationMeasurementsMultiEditUI editUI = new OperationMeasurementsMultiEditUI(getUI());
......
......@@ -31,6 +31,7 @@ import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
import fr.ifremer.reefdb.dto.enums.FilterTypeValues;
import fr.ifremer.reefdb.dto.referential.DepartmentDTO;
import fr.ifremer.reefdb.service.ReefDbTechnicalException;
import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbTableUIHandler;
import jaxx.runtime.SwingUtil;
import org.apache.commons.collections4.CollectionUtils;
......@@ -38,6 +39,8 @@ import org.jdesktop.swingx.table.TableColumnExt;
import javax.swing.RowFilter;
import javax.swing.SwingUtilities;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static org.nuiton.i18n.I18n.t;
......@@ -115,7 +118,7 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb
private void updateDepartmentCellEditor(boolean forceNoFilter) {
departmentCellEditor.getCombo().setActionEnabled(!forceNoFilter
&& getContext().getDataContext().isContextFiltered(FilterTypeValues.DEPARTMENT));
&& getContext().getDataContext().isContextFiltered(FilterTypeValues.DEPARTMENT));
departmentCellEditor.getCombo().setData(getContext().getObservationService().getAvailableDepartments(forceNoFilter));
}
......@@ -141,16 +144,16 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb
uninstallSaveTableStateListener();
addPmfmColumns(
getModel().getPmfms(),
SamplingOperationDTO.PROPERTY_PMFMS,
DecoratorService.NAME_WITH_UNIT); // insert at the end
getModel().getPmfms(),
SamplingOperationDTO.PROPERTY_PMFMS,
DecoratorService.NAME_WITH_UNIT); // insert at the end
boolean notEmpty = CollectionUtils.isNotEmpty(getModel().getPmfms());
// tell the table model is editable or not
getTableModel().setReadOnly(!getModel().getSurvey().isEditable());
getModel().setBeans(getModel().getSamplings());
getModel().setBeans(getModel().getSamplingOperations());
if (notEmpty) {
for (OperationMeasurementsUngroupedRowModel row : getModel().getRows()) {
// set analyst from first non null measurement
......@@ -159,8 +162,8 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb
row.setAnalyst(measurementFound.get().getAnalyst());
} else {
row.setAnalyst(getContext().getProgramStrategyService().getAnalysisDepartmentOfAppliedStrategyBySurvey(
getModel().getSurvey(),
getModel().getPmfms()
getModel().getSurvey(),
getModel().getPmfms()
));
}
}
......@@ -197,7 +200,7 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb
@Override
public boolean include(Entry<? extends OperationMeasurementsUngroupedTableModel, ? extends Integer> entry) {
return getModel().getSamplingFilter() == null
|| getModel().getSamplingFilter().getName().equals(entry.getValue(getTable().getColumnExt(OperationMeasurementsUngroupedTableModel.NAME).getModelIndex()));
|| getModel().getSamplingFilter().getName().equals(entry.getValue(getTable().getColumnExt(OperationMeasurementsUngroupedTableModel.NAME).getModelIndex()));
}
});
}
......@@ -216,21 +219,26 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb