...
 
Commits (7)
## Sprint 91 - v3.9.9
- Pas de mise à jour de modèle
## Sprint 90 - v3.9.8
- Pas de mise à jour de modèle
......
......@@ -10,7 +10,7 @@
<groupId>fr.ifremer.reefdb</groupId>
<artifactId>reefdb</artifactId>
<version>3.9.8</version>
<version>3.9.9</version>
<packaging>pom</packaging>
<name>Reef DB</name>
......@@ -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</quadrige3-core.version>
<!-- Last ReefDb launcher version -->
<launcherVersion>3.0.3</launcherVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>fr.ifremer.reefdb</groupId>
<artifactId>reefdb</artifactId>
<version>3.9.8</version>
<version>3.9.9</version>
</parent>
<artifactId>reefdb-core</artifactId>
......
......@@ -35,7 +35,7 @@
# Please fill the missing licenses for dependencies :
#
#
#Mon Mar 30 15:21:02 CEST 2020
#Tue Apr 07 17:42:52 CEST 2020
com.oracle--ojdbc7--12.1.0.2.0=OTN license
commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
dom4j--dom4j--1.6.1=BSD License
......
......@@ -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);
}
}
......@@ -4,7 +4,7 @@
<parent>
<groupId>fr.ifremer.reefdb</groupId>
<artifactId>reefdb</artifactId>
<version>3.9.8</version>
<version>3.9.9</version>
</parent>
<artifactId>reefdb-ui-swing</artifactId>
......
......@@ -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));
......
......@@ -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
super.onRowModified(rowIndex, row, propertyName, propertyIndex, oldValue, newValue);
// save modifications to parent model
// be careful, table beans can be filtered, so use detection to save measurements
for (SamplingOperationDTO samplingOperationToSave : getModel().getSurvey().getSamplingOperations()) {
row.setDirty(true);
// use QuadrigeBean comparator
if (samplingOperationToSave.getId().equals(row.getId())) {
}
// update all measurements
row.getMeasurements().forEach(measurement -> measurement.setAnalyst(row.getAnalyst()));
public void save() {
samplingOperationToSave.setMeasurements(row.getMeasurements());
samplingOperationToSave.setDirty(true);
break;
}
}
Map<Integer, OperationMeasurementsUngroupedRowModel> rowById = new HashMap<>();
getModel().getRows().forEach(row -> rowById.put(row.getId(), row));
getModel().getSamplingOperations().forEach(samplingOperation -> {
OperationMeasurementsUngroupedRowModel row = rowById.get(samplingOperation.getId());
if (row == null)
throw new ReefDbTechnicalException("Unable to find the row for sampling operation id=" + samplingOperation.getId());
// update all measurements
row.getMeasurements().forEach(measurement -> measurement.setAnalyst(row.getAnalyst()));
// affect measurements
samplingOperation.setMeasurements(row.getMeasurements());
});
}
......@@ -246,8 +254,8 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb
if (row.getAnalyst() == null && row.getMeasurements().stream().anyMatch(measurement -> !ReefDbBeans.isMeasurementEmpty(measurement))) {
ReefDbBeans.addError(row,
t("reefdb.validator.error.analyst.required"),
OperationMeasurementsUngroupedRowModel.PROPERTY_ANALYST);
t("reefdb.validator.error.analyst.required"),
OperationMeasurementsUngroupedRowModel.PROPERTY_ANALYST);
return false;
}
return true;
......@@ -260,16 +268,16 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb
// Colonne mnemonique
final TableColumnExt colMnemonic = addColumn(
OperationMeasurementsUngroupedTableModel.NAME);
OperationMeasurementsUngroupedTableModel.NAME);
colMnemonic.setSortable(true);
colMnemonic.setEditable(false);
setDefaultColumnMinWidth(colMnemonic);
// Add analyst column (Mantis #42619)
TableColumnExt analystColumn = addColumn(
departmentCellEditor,
newTableCellRender(OperationMeasurementsUngroupedTableModel.ANALYST),
OperationMeasurementsUngroupedTableModel.ANALYST
departmentCellEditor,
newTableCellRender(OperationMeasurementsUngroupedTableModel.ANALYST),
OperationMeasurementsUngroupedTableModel.ANALYST
);
analystColumn.setMinWidth(100);
......
......@@ -71,11 +71,11 @@ public class OperationMeasurementsUngroupedTableUIModel extends AbstractReefDbTa
}
/**
* <p>getSamplings.</p>
* <p>getSamplingOperations.</p>
*
* @return a {@link java.util.List} object.
*/
public List<SamplingOperationDTO> getSamplings() {
public List<SamplingOperationDTO> getSamplingOperations() {
return survey == null ? null : (List<SamplingOperationDTO>) survey.getSamplingOperations();
}
......@@ -106,8 +106,8 @@ public class OperationMeasurementsUngroupedTableUIModel extends AbstractReefDbTa
*/
public List<MeasurementDTO> getAllMeasurements() {
List<MeasurementDTO> measurements = Lists.newArrayList();
if (getSamplings() != null) {
for (SamplingOperationDTO samplingOperation : getSamplings()) {
if (getSamplingOperations() != null) {
for (SamplingOperationDTO samplingOperation : getSamplingOperations()) {
measurements.addAll(samplingOperation.getMeasurements());
}
}
......
......@@ -412,9 +412,9 @@ public class PhotosTabUIHandler extends AbstractReefDbTableUIHandler<PhotosTable
}
/**
* <p>saveActualModel.</p>
* <p>save.</p>
*/
public void saveActualModel() {
public void save() {
getModel().setModelAdjusting(true);
getModel().getObservationModel().setPhotos(getModel().getBeans());
getModel().setModelAdjusting(false);
......
......@@ -319,6 +319,15 @@ public abstract class AbstractMeasurementsGroupedRowModel<B extends MeasurementD
return Lists.newArrayList(PROPERTY_TAXON_GROUP, PROPERTY_TAXON);
}
public boolean hasTaxonInformation() {
return getTaxonGroup() != null || getTaxon() != null;
}
public boolean hasNonEmptyMeasurements() {
return getIndividualMeasurements().stream().anyMatch(measurement -> !ReefDbBeans.isMeasurementEmpty(measurement));
}
/**
* Return a unique hashCode for the row
*
......
......@@ -53,7 +53,7 @@ public abstract class AbstractMeasurementsGroupedTableUIModel<
public static final String PROPERTY_SURVEY = "survey";
public static final String PROPERTY_MEASUREMENT_FILTER = "measurementFilter";
public static final String EVENT_MEASUREMENTS_LOADED = "measurementsLoaded";
public static final String EVENT_INDIVIDUAL_MEASUREMENTS_LOADED = "individualMeasurementsLoaded";
// the survey model
private ObservationUIModel survey;
......@@ -189,6 +189,6 @@ public abstract class AbstractMeasurementsGroupedTableUIModel<
}
public void fireMeasurementsLoaded() {
firePropertyChange(EVENT_MEASUREMENTS_LOADED, null, null);
firePropertyChange(EVENT_INDIVIDUAL_MEASUREMENTS_LOADED, null, null);
}
}
......@@ -197,12 +197,6 @@ public abstract class AbstractMeasurementsMultiEditUIHandler<
// super.onRowsAdded(addedRows);
}
@Override
public void saveMeasurementsInModel(R row) {
// Don't call super method; the selected rows will be saved after multi-line validation
// super.saveMeasurementsInModel(row);
}
@Override
protected List<? extends MeasurementAware> getMeasurementAwareModels() {
// nothing to return, this handler don't save model
......@@ -219,10 +213,6 @@ public abstract class AbstractMeasurementsMultiEditUIHandler<
protected void filterMeasurements() {
}
@Override
protected void removeIndividualMeasurements(List<MeasurementDTO> measurementToDelete) {
}
public void valid() {
if (getModel().isValid()) {
closeDialog();
......
......@@ -43,6 +43,11 @@ NumberEditor {
_selectOnFocus: {true};
}
#surveyDetailsBlockLayer {
blockingColor: {handler.getConfig().getColorBlockingLayer()};
block:{model.isLoading()};
}
#surveyDetailsTabUI {
_panelType: {ReefDbUI.EDITION_PANEL_TYPE};
}
......
......@@ -75,6 +75,7 @@ public class SurveyDetailsTabUIHandler extends AbstractReefDbUIHandler<SurveyDet
@Override
public void afterInit(final SurveyDetailsTabUI ui) {
initUI(ui);
SwingUtil.setLayerUI(ui.getDetailsPanel(), ui.getSurveyDetailsBlockLayer());
// Initialisation des combobox
initComboBox();
......@@ -378,9 +379,9 @@ public class SurveyDetailsTabUIHandler extends AbstractReefDbUIHandler<SurveyDet
}
/**
* <p>saveActualModel.</p>
* <p>save.</p>
*/
public void saveActualModel() {
public void save() {
getModel().setAdjusting(true);
......
......@@ -336,4 +336,24 @@ public class SurveyMeasurementsTabUIHandler extends AbstractReefDbUIHandler<Surv
public boolean onRemoveTab() {
return false;
}
public void save() {
try {
// Disable filter
getModel().getGroupedTableUIModel().setMeasurementFilter(new MeasurementsFilter());
// save ungrouped measurements
getUI().getUngroupedTable().getHandler().save();
// save grouped measurements
getUI().getGroupedTable().getHandler().save();
} finally {
doSearch();
}
}
}
......@@ -27,7 +27,6 @@ import com.google.common.collect.ImmutableList;
import fr.ifremer.quadrige3.ui.swing.table.ColumnIdentifier;
import fr.ifremer.quadrige3.ui.swing.table.SwingTable;
import fr.ifremer.reefdb.dto.data.measurement.MeasurementAware;
import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
import fr.ifremer.reefdb.ui.swing.content.observation.shared.AbstractMeasurementsGroupedTableModel;
import fr.ifremer.reefdb.ui.swing.content.observation.shared.AbstractMeasurementsGroupedTableUIHandler;
import fr.ifremer.reefdb.ui.swing.content.observation.survey.measurement.grouped.multiedit.SurveyMeasurementsMultiEditUI;
......@@ -211,17 +210,6 @@ public class SurveyMeasurementsGroupedTableUIHandler
addEditionPanelBorder();
}
@Override
protected void removeIndividualMeasurements(List<MeasurementDTO> measurementToDelete) {
// Remove from model
getModel().getSurvey().removeAllIndividualMeasurements(measurementToDelete);
getModel().getSurvey().setDirty(true);
getModel().setModify(true);
}
public void editSelectedMeasurements() {
editSelectedMeasurements(new SurveyMeasurementsMultiEditUI(getUI()));
......
......@@ -31,6 +31,7 @@ import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
import fr.ifremer.reefdb.dto.data.survey.SurveyDTO;
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;
......@@ -148,13 +149,12 @@ public class SurveyMeasurementsUngroupedTableUIHandler
// tell the table model is editable or not
getTableModel().setReadOnly(!getModel().getSurvey().isEditable());
// getModel().setBean(getModel().getSurvey());
getModel().setRows(null);
if (notEmpty) {
// affect row
SurveyMeasurementsUngroupedRowModel row = getModel().addNewRow(getModel().getSurvey()); //getModel().getRows().get(0);
SurveyMeasurementsUngroupedRowModel row = getModel().addNewRow(getModel().getSurvey());
// set analyst from first non null measurement
Optional<MeasurementDTO> measurementFound = getModel().getSurvey().getMeasurements().stream().filter(measurement -> measurement.getAnalyst() != null).findFirst();
......@@ -199,12 +199,25 @@ public class SurveyMeasurementsUngroupedTableUIHandler
super.onRowModified(rowIndex, row, propertyName, propertyIndex, oldValue, newValue);
getModel().getSurvey().setDirty(true);
}
public void save() {
if (getModel().getRowCount() == 0)
return;
if (getModel().getRowCount() > 1)
throw new ReefDbTechnicalException("Should be only 1 row of survey ungrouped measurements");
SurveyMeasurementsUngroupedRowModel row = getModel().getRows().get(0);
// update all measurements
row.getMeasurements().forEach(measurement -> measurement.setAnalyst(row.getAnalyst()));
// save modifications to parent model
getModel().getSurvey().setMeasurements(row.getMeasurements());
getModel().getSurvey().setDirty(true);
}
......
package fr.ifremer.reefdb.ui.swing.util;
/*-
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2020 Ifremer
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
import org.jdesktop.beans.AbstractBean;
import javax.annotation.Nonnull;
import java.awt.Component;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.function.Consumer;
/**
* a PropertyChangeListener that auto remove after fired
*
* @author peck7 on 20/03/2020.
*/
public class OneShotListener implements PropertyChangeListener {
private final Component parentComponent;
private final AbstractBean parentBean;
private final String propertyName;
private final Consumer<PropertyChangeEvent> consumer;
/**
* Create and add to parent object
*
* @param parent the component on which this listener will be added
* @param propertyName the property to listen to
* @param consumer the consumer function
*/
public static void create(@Nonnull Component parent, @Nonnull String propertyName, @Nonnull Consumer<PropertyChangeEvent> consumer) {
OneShotListener listener = new OneShotListener(parent, propertyName, consumer);
parent.addPropertyChangeListener(propertyName, listener);
}
/**
* Create and add to parent object
*
* @param parent the bean on which this listener will be added
* @param propertyName the property to listen to
* @param consumer the consumer function
*/
public static void create(@Nonnull AbstractBean parent, @Nonnull String propertyName, @Nonnull Consumer<PropertyChangeEvent> consumer) {
OneShotListener listener = new OneShotListener(parent, propertyName, consumer);
parent.addPropertyChangeListener(propertyName, listener);
}
private OneShotListener(Component parentComponent, String propertyName, Consumer<PropertyChangeEvent> consumer) {
this.parentComponent = parentComponent;
this.parentBean = null;
this.propertyName = propertyName;
this.consumer = consumer;
}
private OneShotListener(AbstractBean parentBean, String propertyName, Consumer<PropertyChangeEvent> consumer) {
this.parentComponent = null;
this.parentBean = parentBean;
this.propertyName = propertyName;
this.consumer = consumer;
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
consumer.accept(evt);
if (parentComponent != null)
parentComponent.removePropertyChangeListener(propertyName, this);
if (parentBean != null)
parentBean.removePropertyChangeListener(propertyName, this);
}
}
......@@ -529,6 +529,7 @@ public abstract class AbstractReefDbTableUIHandler<R extends AbstractReefDbRowUI
protected void removePmfmColumns() {
removeColumns(getModel().getPmfmColumns());
getModel().getPmfmColumns().clear();
}
/**
......
......@@ -31,6 +31,18 @@
</properties>
<body>
<release version="3.9.9" date="2020-04-07" description="Stable release">
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51725,51737">
Grouped measurements: automatic calculation and saving into parent beans has been replaced by unique function executed at observation saving
</action>
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51710">
PIT protocol: section calculation fixed
</action>
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51731">
Upgrade quadrige3-core to version 3.6.14
</action>
</release>
<release version="3.9.8" date="2020-03-30" description="Stable release">
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51586">
Regression of #51520: Postpone calculation also if no row sorting
......