...
 
Commits (3)
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
<maven.compiler.debug>true</maven.compiler.debug> <maven.compiler.debug>true</maven.compiler.debug>
<!-- Quadrige3 Core version --> <!-- Quadrige3 Core version -->
<quadrige3-core.version>3.6.11</quadrige3-core.version> <quadrige3-core.version>3.6.13</quadrige3-core.version>
<!-- Last ReefDb launcher version --> <!-- Last ReefDb launcher version -->
<launcherVersion>3.0.3</launcherVersion> <launcherVersion>3.0.3</launcherVersion>
......
...@@ -905,9 +905,9 @@ public final class ReefDbConfiguration extends QuadrigeCoreConfiguration { ...@@ -905,9 +905,9 @@ public final class ReefDbConfiguration extends QuadrigeCoreConfiguration {
String configOption = applicationConfig.getOption(ReefDbConfigurationOption.PMFM_IDS_TRANSITION_LENGTH.getKey()); String configOption = applicationConfig.getOption(ReefDbConfigurationOption.PMFM_IDS_TRANSITION_LENGTH.getKey());
if (StringUtils.isBlank(configOption)) return result; if (StringUtils.isBlank(configOption)) return result;
List<String> triplets = Splitter.on(";").splitToList(configOption); List<String> triplets = Splitter.on(";").omitEmptyStrings().splitToList(configOption);
for (String triplet : triplets) { for (String triplet : triplets) {
List<String> pmfmsIdsStr = Splitter.on(",").splitToList(triplet); List<String> pmfmsIdsStr = Splitter.on(",").omitEmptyStrings().trimResults().splitToList(triplet);
if (CollectionUtils.size(pmfmsIdsStr) == 3) { if (CollectionUtils.size(pmfmsIdsStr) == 3) {
try { try {
Integer[] pmfmIds = new Integer[3]; Integer[] pmfmIds = new Integer[3];
......
...@@ -42,6 +42,7 @@ import fr.ifremer.reefdb.dto.configuration.programStrategy.PmfmStrategyDTO; ...@@ -42,6 +42,7 @@ import fr.ifremer.reefdb.dto.configuration.programStrategy.PmfmStrategyDTO;
import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO; import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO;
import fr.ifremer.reefdb.dto.data.measurement.MeasurementAware; import fr.ifremer.reefdb.dto.data.measurement.MeasurementAware;
import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO; import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
import fr.ifremer.reefdb.dto.data.survey.CampaignDTO; import fr.ifremer.reefdb.dto.data.survey.CampaignDTO;
import fr.ifremer.reefdb.dto.data.survey.SurveyDTO; import fr.ifremer.reefdb.dto.data.survey.SurveyDTO;
import fr.ifremer.reefdb.dto.enums.*; import fr.ifremer.reefdb.dto.enums.*;
...@@ -90,36 +91,6 @@ public class ReefDbBeans extends QuadrigeBeans { ...@@ -90,36 +91,6 @@ public class ReefDbBeans extends QuadrigeBeans {
} }
} }
/**
* <p>computeAddress.</p>
*
* @param street a {@link String} object.
* @param zipCode a {@link String} object.
* @param city a {@link String} object.
* @return a {@link String} object.
*/
public static String computeAddress(String street, String zipCode, String city) {
StringBuilder addressBuilder = new StringBuilder();
if (StringUtils.isNotBlank(street)) {
addressBuilder.append(street.replaceAll("[ ]+", " "));
if (StringUtils.isNotBlank(zipCode) || StringUtils.isNotBlank(city)) {
addressBuilder.append(", ");
}
}
if (StringUtils.isNotBlank(zipCode)) {
addressBuilder.append(zipCode);
if (StringUtils.isNotBlank(city)) {
addressBuilder.append(" ");
}
}
if (StringUtils.isNotBlank(city)) {
addressBuilder.append(city);
}
return addressBuilder.toString();
}
public static String toQuotedString(String string) { public static String toQuotedString(String string) {
return "'" + string.replaceAll("'", "''") + "'"; return "'" + string.replaceAll("'", "''") + "'";
} }
...@@ -189,6 +160,47 @@ public class ReefDbBeans extends QuadrigeBeans { ...@@ -189,6 +160,47 @@ public class ReefDbBeans extends QuadrigeBeans {
return bean.toString(); return bean.toString();
} }
public static List<MeasurementDTO> duplicate(List<MeasurementDTO> measurements) {
if (measurements == null)
return new ArrayList<>();
return measurements.stream().map(ReefDbBeans::duplicate).collect(Collectors.toList());
}
public static MeasurementDTO duplicate(MeasurementDTO measurement) {
// Clone object
MeasurementDTO clone = clone(measurement);
// Remove Id & individualId
clone.setId(null);
clone.setIndividualId(null);
// remove errors
clone.setErrors(null);
return clone;
}
public static SamplingOperationDTO duplicate(final SamplingOperationDTO samplingOperation) {
// Clone object
final SamplingOperationDTO clone = clone(samplingOperation);
// Remove ID
clone.setId(null);
// clone coordinate
clone.setCoordinate(clone(samplingOperation.getCoordinate()));
// remove errors
clone.setErrors(null);
// duplicate measurements
clone.setMeasurements(duplicate(samplingOperation.getMeasurements()));
clone.setIndividualMeasurements(duplicate(samplingOperation.getIndividualMeasurements()));
return clone;
}
/** /**
* <p>filterNotEmptyAppliedPeriod.</p> * <p>filterNotEmptyAppliedPeriod.</p>
* *
......
...@@ -26,7 +26,6 @@ package fr.ifremer.reefdb.service.observation; ...@@ -26,7 +26,6 @@ package fr.ifremer.reefdb.service.observation;
import fr.ifremer.quadrige3.core.ProgressionCoreModel; import fr.ifremer.quadrige3.core.ProgressionCoreModel;
import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgStratDTO; import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgStratDTO;
import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO; import fr.ifremer.reefdb.dto.configuration.programStrategy.ProgramDTO;
import fr.ifremer.reefdb.dto.data.measurement.MeasurementDTO;
import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO; import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
import fr.ifremer.reefdb.dto.data.survey.CampaignDTO; import fr.ifremer.reefdb.dto.data.survey.CampaignDTO;
import fr.ifremer.reefdb.dto.data.survey.SurveyDTO; import fr.ifremer.reefdb.dto.data.survey.SurveyDTO;
...@@ -128,24 +127,6 @@ public interface ObservationService { ...@@ -128,24 +127,6 @@ public interface ObservationService {
@PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)") @PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
SurveyDTO duplicateSurvey(SurveyDTO survey, boolean fullDuplication, boolean copyCoordinates, boolean duplicateSurveyMeasurements); SurveyDTO duplicateSurvey(SurveyDTO survey, boolean fullDuplication, boolean copyCoordinates, boolean duplicateSurveyMeasurements);
/**
* Duplicate prelevement.
*
* @param samplingOperation Prelevement to duplicate
* @return Prelvement duplicated
*/
@PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
SamplingOperationDTO duplicateSamplingOperation(SamplingOperationDTO samplingOperation);
/**
* Duplicate a list of measurements.
*
* @param measurements Measurements to duplicate
* @return Measurements duplicate
*/
@PreAuthorize("hasPermission(null, T(fr.ifremer.quadrige3.core.security.QuadrigeUserAuthority).USER)")
List<MeasurementDTO> duplicateMeasurements(List<MeasurementDTO> measurements);
/** /**
* <p>getAvailablePrograms.</p> * <p>getAvailablePrograms.</p>
* *
......
...@@ -538,59 +538,6 @@ public class ObservationServiceImpl implements ObservationInternalService { ...@@ -538,59 +538,6 @@ public class ObservationServiceImpl implements ObservationInternalService {
} }
/**
* {@inheritDoc}
*/
@Override
public SamplingOperationDTO duplicateSamplingOperation(final SamplingOperationDTO samplingOperation) {
// Duplicate sampling operation
final SamplingOperationDTO duplicatedSamplingOperation = ReefDbBeans.clone(samplingOperation);
// Remove ID
duplicatedSamplingOperation.setId(null);
// duplicate coordinate
duplicatedSamplingOperation.setCoordinate(ReefDbBeans.clone(samplingOperation.getCoordinate()));
// remove errors
duplicatedSamplingOperation.setErrors(null);
// duplicate measurements
duplicatedSamplingOperation.setMeasurements(duplicateMeasurements(samplingOperation.getMeasurements()));
duplicatedSamplingOperation.setIndividualMeasurements(duplicateMeasurements(samplingOperation.getIndividualMeasurements()));
return duplicatedSamplingOperation;
}
/**
* {@inheritDoc}
*/
@Override
public List<MeasurementDTO> duplicateMeasurements(List<MeasurementDTO> measurements) {
List<MeasurementDTO> duplicatedMeasurements = Lists.newArrayList();
if (CollectionUtils.isNotEmpty(measurements)) {
for (MeasurementDTO measurement : measurements) {
// duplicated measurement
final MeasurementDTO duplicatedMeasurement = ReefDbBeans.clone(measurement);
// Remove Id & individualId
duplicatedMeasurement.setId(null);
duplicatedMeasurement.setIndividualId(null);
// remove errors
duplicatedMeasurement.setErrors(null);
duplicatedMeasurements.add(duplicatedMeasurement);
}
}
return duplicatedMeasurements;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
......
...@@ -23,12 +23,15 @@ package fr.ifremer.reefdb.ui.swing.content.home.operation; ...@@ -23,12 +23,15 @@ package fr.ifremer.reefdb.ui.swing.content.home.operation;
* #L% * #L%
*/ */
import fr.ifremer.reefdb.dto.ReefDbBeans;
import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO; import fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO;
import fr.ifremer.reefdb.ui.swing.action.AbstractReefDbAction; import fr.ifremer.reefdb.ui.swing.action.AbstractReefDbAction;
/** /**
* Duplicate sampling operation action. * Duplicate sampling operation action.
* {@link Deprecated} Use fr.ifremer.reefdb.dto.ReefDbBeans#duplicate(fr.ifremer.reefdb.dto.data.sampling.SamplingOperationDTO) outside an action
*/ */
@Deprecated
public class DuplicateOperationAction extends AbstractReefDbAction<OperationsTableUIModel, OperationsTableUI, OperationsTableUIHandler> { public class DuplicateOperationAction extends AbstractReefDbAction<OperationsTableUIModel, OperationsTableUI, OperationsTableUIHandler> {
/** /**
...@@ -60,12 +63,10 @@ public class DuplicateOperationAction extends AbstractReefDbAction<OperationsTab ...@@ -60,12 +63,10 @@ public class DuplicateOperationAction extends AbstractReefDbAction<OperationsTab
if (operationsTableRowModel != null) { if (operationsTableRowModel != null) {
// Duplicate operation // Duplicate operation
final SamplingOperationDTO duplicatePrelevement = getContext().getObservationService().duplicateSamplingOperation(operationsTableRowModel.toBean()); final SamplingOperationDTO duplicateOperation = ReefDbBeans.duplicate(operationsTableRowModel.toBean());
if (duplicatePrelevement != null) {
// Add duplicate operation to table
// Add duplicate operation to table newRow = getModel().addNewRow(duplicateOperation);
newRow = getModel().addNewRow(duplicatePrelevement);
}
} }
} }
......
...@@ -252,7 +252,7 @@ public class OperationsTableUIHandler extends AbstractReefDbTableUIHandler<Opera ...@@ -252,7 +252,7 @@ public class OperationsTableUIHandler extends AbstractReefDbTableUIHandler<Opera
} }
// save actual table context before loading new survey // save actual table context before loading new survey
getContext().saveComponentInSwingSession(getTable(), getTableModel().getStateContext()); saveTableState();
// affect new selected survey // affect new selected survey
getModel().setSurvey(survey); getModel().setSurvey(survey);
...@@ -739,7 +739,7 @@ public class OperationsTableUIHandler extends AbstractReefDbTableUIHandler<Opera ...@@ -739,7 +739,7 @@ public class OperationsTableUIHandler extends AbstractReefDbTableUIHandler<Opera
forceRevalidateModel(); forceRevalidateModel();
// restore table state from swing session // restore table state from swing session
getContext().restoreComponentFromSwingSession(getTable()); restoreTableState();
// hide analyst column if no pmfm (Mantis #42619) // hide analyst column if no pmfm (Mantis #42619)
// forceColumnVisibleAtLastPosition(OperationsTableModel.ANALYST, notEmpty); // forceColumnVisibleAtLastPosition(OperationsTableModel.ANALYST, notEmpty);
......
...@@ -439,13 +439,11 @@ public class AddOperationTableUIHandler extends AbstractReefDbTableUIHandler<Ope ...@@ -439,13 +439,11 @@ public class AddOperationTableUIHandler extends AbstractReefDbTableUIHandler<Ope
for (int i = 0; i < nbOperation; i++) { for (int i = 0; i < nbOperation; i++) {
// Ajout du prelevement dans la liste // Ajout du prelevement dans la liste
final SamplingOperationDTO newOperation = getContext().getObservationService().duplicateSamplingOperation(operation); final SamplingOperationDTO newOperation = ReefDbBeans.duplicate(operation);
if (newOperation != null) { operations.add(newOperation);
operations.add(newOperation);
// do it at creation time // do it at creation time
newOperation.setMeasurementsLoaded(true); newOperation.setMeasurementsLoaded(true);
}
} }
// Ajout des prelevements // Ajout des prelevements
......
package fr.ifremer.reefdb.ui.swing.content.observation.operation.measurement.grouped;
/*
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2015 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 fr.ifremer.reefdb.ui.swing.action.AbstractReefDbAction;
/**
* Action dupliquer mesure (ecran prelevements/mesure).
*/
public class DuplicateOperationMeasurementsAction extends AbstractReefDbAction<OperationMeasurementsGroupedTableUIModel, OperationMeasurementsGroupedTableUI, OperationMeasurementsGroupedTableUIHandler> {
/**
* La ligne ajoutee.
*/
private OperationMeasurementsGroupedRowModel row;
/**
* Constrcuteur.
*
* @param handler Controller
*/
public DuplicateOperationMeasurementsAction(final OperationMeasurementsGroupedTableUIHandler handler) {
super(handler, false);
}
/** {@inheritDoc} */
@Override
public boolean prepareAction() throws Exception {
return super.prepareAction() && getModel().getSelectedRows().size() == 1;
}
/** {@inheritDoc} */
@Override
public void doAction() {
// Selected measurement
final OperationMeasurementsGroupedRowModel rowToDuplicate = getModel().getSelectedRows().iterator().next();
if (rowToDuplicate != null) {
row = new OperationMeasurementsGroupedRowModel(false);
row.setSamplingOperation(rowToDuplicate.getSamplingOperation());
row.setTaxonGroup(rowToDuplicate.getTaxonGroup());
row.setTaxon(rowToDuplicate.getTaxon());
row.setInputTaxonId(rowToDuplicate.getInputTaxonId());
row.setInputTaxonName(rowToDuplicate.getInputTaxonName());
row.setComment(rowToDuplicate.getComment());
row.setIndividualPmfms(rowToDuplicate.getIndividualPmfms());
// add also analyst (MAntis #45054)
row.setAnalyst(rowToDuplicate.getAnalyst());
// duplicate measurements by service
row.setIndividualMeasurements(getContext().getObservationService().duplicateMeasurements(rowToDuplicate.getIndividualMeasurements()));
}
}
/** {@inheritDoc} */
@Override
public void postSuccessAction() {
super.postSuccessAction();
// Add duplicate measurement to table
getModel().insertRowAfterSelected(row);
// save directly to sampling operation
getHandler().saveMeasurementsInModel(row);
// send update event on sampling operation
if (row.getSamplingOperation() != null) {
getModel().firePropertyChanged(OperationMeasurementsGroupedTableUIModel.PROPERTY_SAMPLING_OPERATION, null, row.getSamplingOperation());
}
getHandler().recomputeRowsValidState();
getModel().setModify(true);
// Ajouter le focus sur la cellule de la ligne cree
getHandler().setFocusOnCell(row);
}
}
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<JPanel id='tableauBasPanelButtons' layout='{new BorderLayout()}' constraints="BorderLayout.PAGE_END"> <JPanel id='tableauBasPanelButtons' layout='{new BorderLayout()}' constraints="BorderLayout.PAGE_END">
<JPanel layout='{new FlowLayout()}' constraints='BorderLayout.LINE_START'> <JPanel layout='{new FlowLayout()}' constraints='BorderLayout.LINE_START'>
<JButton id='addButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="model.insertNewRowAfterSelected()"/> <JButton id='addButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="model.insertNewRowAfterSelected()"/>
<JButton id='duplicateButton' alignmentX='{Component.CENTER_ALIGNMENT}'/> <JButton id='duplicateButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.duplicateSelectedRow()"/>
<JButton id='initDataGridButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.initializeDataGrid()"/> <JButton id='initDataGridButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.initializeDataGrid()"/>
<JButton id='multiEditButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.editSelectedMeasurements()"/> <JButton id='multiEditButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.editSelectedMeasurements()"/>
<JButton id='deleteButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.removeIndividualMeasurements()"/> <JButton id='deleteButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.removeIndividualMeasurements()"/>
......
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
actionIcon: copy; actionIcon: copy;
text: "reefdb.action.duplicate.label"; text: "reefdb.action.duplicate.label";
toolTipText: "reefdb.action.duplicate.measurement.tip"; toolTipText: "reefdb.action.duplicate.measurement.tip";
_applicationAction: {DuplicateOperationMeasurementsAction.class};
enabled: {model.getSurvey().isEditable() && !model.getSelectedRows().isEmpty() && (model.getSelectedRows().size() == 1) && !model.getPmfms().isEmpty()}; enabled: {model.getSurvey().isEditable() && !model.getSelectedRows().isEmpty() && (model.getSelectedRows().size() == 1) && !model.getPmfms().isEmpty()};
} }
......
...@@ -150,6 +150,22 @@ public class OperationMeasurementsGroupedTableUIHandler ...@@ -150,6 +150,22 @@ public class OperationMeasurementsGroupedTableUIHandler
// update some controls // update some controls
getUI().processDataBinding(OperationMeasurementsGroupedTableUI.BINDING_INIT_DATA_GRID_BUTTON_ENABLED); getUI().processDataBinding(OperationMeasurementsGroupedTableUI.BINDING_INIT_DATA_GRID_BUTTON_ENABLED);
break; break;
// TODO ? force sort on sampling operation and transition column
// case OperationMeasurementsGroupedTableUIModel.PROPERTY_PIT_TRANSITION_LENGTH_PMFM_ID:
//
// // Try to apply sort on sampling operation and transition column
// if (getModel().getPitTransitionLengthPmfmId() != null) {
// TableColumnExt samplingColumn = getTable().getColumnExt(OperationMeasurementsGroupedTableModel.SAMPLING);
// PmfmTableColumn transitionColumn = findPmfmColumnByPmfmId(getModel().getPmfmColumns(), getModel().getPitTransitionLengthPmfmId());
// if (samplingColumn != null && transitionColumn != null) {
// getTable().getRowSorter().setSortKeys(ImmutableList.of(
// new RowSorter.SortKey(samplingColumn.getModelIndex(), SortOrder.ASCENDING),
// new RowSorter.SortKey(transitionColumn.getModelIndex(), SortOrder.ASCENDING)
// ));
// }
// }
// break;
} }
}); });
...@@ -185,11 +201,10 @@ public class OperationMeasurementsGroupedTableUIHandler ...@@ -185,11 +201,10 @@ public class OperationMeasurementsGroupedTableUIHandler
@Override @Override
protected List<? extends MeasurementAware> getMeasurementAwareModels() { protected List<? extends MeasurementAware> getMeasurementAwareModels() {
List<SamplingOperationDTO> samplingOperations = Lists.newArrayList(getModel().getSamplingOperations()); return getModel().getSamplingOperations().stream()
// sort by name // sort by name
samplingOperations.sort(Comparator.comparing(SamplingOperationDTO::getName)); .sorted(Comparator.comparing(SamplingOperationDTO::getName))
.collect(Collectors.toList());
return samplingOperations;
} }
@Override @Override
...@@ -205,12 +220,13 @@ public class OperationMeasurementsGroupedTableUIHandler ...@@ -205,12 +220,13 @@ public class OperationMeasurementsGroupedTableUIHandler
@Override @Override
protected void onRowModified(int rowIndex, OperationMeasurementsGroupedRowModel row, String propertyName, Integer propertyIndex, Object oldValue, Object newValue) { protected void onRowModified(int rowIndex, OperationMeasurementsGroupedRowModel row, String propertyName, Integer propertyIndex, Object oldValue, Object newValue) {
// update individual id when sampling operation changes // when sampling operation changes
if (OperationMeasurementsGroupedRowModel.PROPERTY_SAMPLING_OPERATION.equals(propertyName)) { if (OperationMeasurementsGroupedRowModel.PROPERTY_SAMPLING_OPERATION.equals(propertyName)) {
// remove measurement from old sampling // remove measurement from old sampling
if (oldValue != null) { if (oldValue != null) {
SamplingOperationDTO oldSamplingOperation = (SamplingOperationDTO) oldValue; SamplingOperationDTO oldSamplingOperation = (SamplingOperationDTO) oldValue;
// fixme: il rest edes mesures dans le operation !!!!!!!!!!!!!!
oldSamplingOperation.removeAllIndividualMeasurements(row.getIndividualMeasurements()); oldSamplingOperation.removeAllIndividualMeasurements(row.getIndividualMeasurements());
oldSamplingOperation.setDirty(true); oldSamplingOperation.setDirty(true);
...@@ -235,6 +251,14 @@ public class OperationMeasurementsGroupedTableUIHandler ...@@ -235,6 +251,14 @@ public class OperationMeasurementsGroupedTableUIHandler
super.onRowModified(rowIndex, row, propertyName, propertyIndex, oldValue, newValue); 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 @Override
protected void resetIndividualMeasurementIds(OperationMeasurementsGroupedRowModel row) { protected void resetIndividualMeasurementIds(OperationMeasurementsGroupedRowModel row) {
...@@ -421,15 +445,14 @@ public class OperationMeasurementsGroupedTableUIHandler ...@@ -421,15 +445,14 @@ public class OperationMeasurementsGroupedTableUIHandler
for (Integer transition : initModel.getResultMap().get(samplingOperation)) { for (Integer transition : initModel.getResultMap().get(samplingOperation)) {
// Compute next individual id
incrementNextIndividualId(samplingOperation, individualId); incrementNextIndividualId(samplingOperation, individualId);
OperationMeasurementsGroupedRowModel row = getTableModel().createNewRow();
// Initialize the row // Initialize the row
row.setSamplingOperation(samplingOperation); OperationMeasurementsGroupedRowModel row = createNewRow(false, samplingOperation);
// Affect individual pmfms from parent model
row.setIndividualPmfms(new ArrayList<>(getModel().getPmfms()));
// Set the individualId // Set the individualId
row.setIndividualId(individualId.get()); row.setIndividualId(individualId.get());
// Affect individual pmfms from parent model
row.setIndividualPmfms(new ArrayList<>(getModel().getPmfms()));
// Create empty measurements // Create empty measurements
ReefDbBeans.createEmptyMeasurements(row); ReefDbBeans.createEmptyMeasurements(row);
// Get the measurement // Get the measurement
...@@ -452,14 +475,6 @@ public class OperationMeasurementsGroupedTableUIHandler ...@@ -452,14 +475,6 @@ public class OperationMeasurementsGroupedTableUIHandler
} }
} }
private void incrementNextIndividualId(SamplingOperationDTO samplingOperation, AtomicInteger nextIndividualId) {
do {
nextIndividualId.incrementAndGet();
} while (getModel().getRows().stream().anyMatch(row ->
samplingOperation.equals(row.getSamplingOperation()) && nextIndividualId.get() == row.getIndividualId()));
}
public void editSelectedMeasurements() { public void editSelectedMeasurements() {
OperationMeasurementsMultiEditUI editUI = new OperationMeasurementsMultiEditUI(getUI()); OperationMeasurementsMultiEditUI editUI = new OperationMeasurementsMultiEditUI(getUI());
......
...@@ -44,6 +44,7 @@ public class OperationMeasurementsGroupedTableUIModel ...@@ -44,6 +44,7 @@ public class OperationMeasurementsGroupedTableUIModel
* property identifier used to propagate row sampling operation property change to parent * property identifier used to propagate row sampling operation property change to parent
*/ */
public static final String PROPERTY_SAMPLING_OPERATION = "samplingOperation"; public static final String PROPERTY_SAMPLING_OPERATION = "samplingOperation";
public static final String PROPERTY_PIT_TRANSITION_LENGTH_PMFM_ID = "pitTransitionLengthPmfmId";
// pmfm ids for grid initialization (pit protocol) // pmfm ids for grid initialization (pit protocol)
private Integer pitTransectOriginPmfmId; private Integer pitTransectOriginPmfmId;
...@@ -85,6 +86,7 @@ public class OperationMeasurementsGroupedTableUIModel ...@@ -85,6 +86,7 @@ public class OperationMeasurementsGroupedTableUIModel
public void setPitTransitionLengthPmfmId(Integer pitTransitionLengthPmfmId) { public void setPitTransitionLengthPmfmId(Integer pitTransitionLengthPmfmId) {
this.pitTransitionLengthPmfmId = pitTransitionLengthPmfmId; this.pitTransitionLengthPmfmId = pitTransitionLengthPmfmId;
firePropertyChange(PROPERTY_PIT_TRANSITION_LENGTH_PMFM_ID, null, pitTransitionLengthPmfmId);
} }
public boolean isPitTransitionGridInitializationEnabled() { public boolean isPitTransitionGridInitializationEnabled() {
......
...@@ -170,7 +170,7 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb ...@@ -170,7 +170,7 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb
filterSamplingOperations(); filterSamplingOperations();
// restore table from swing session // restore table from swing session
getContext().restoreComponentFromSwingSession(getTable()); restoreTableState();
// hide analyst if no pmfm // hide analyst if no pmfm
// forceColumnVisibleAtLastPosition(OperationMeasurementsUngroupedTableModel.ANALYST, notEmpty); // forceColumnVisibleAtLastPosition(OperationMeasurementsUngroupedTableModel.ANALYST, notEmpty);
......
package fr.ifremer.reefdb.ui.swing.content.observation.survey.measurement.grouped;
/*
* #%L
* Reef DB :: UI
* $Id:$
* $HeadURL:$
* %%
* Copyright (C) 2014 - 2015 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 fr.ifremer.reefdb.ui.swing.action.AbstractReefDbAction;
/**
* Action dupliquer mesure (ecran observation/mesure).
*/
public class DuplicateSurveyMeasurementsAction extends AbstractReefDbAction<SurveyMeasurementsGroupedTableUIModel, SurveyMeasurementsGroupedTableUI, SurveyMeasurementsGroupedTableUIHandler> {
/**
* La ligne ajoutee.
*/
private SurveyMeasurementsGroupedRowModel row;
/**
* Constrcuteur.
*
* @param handler Controller
*/
public DuplicateSurveyMeasurementsAction(final SurveyMeasurementsGroupedTableUIHandler handler) {
super(handler, false);
}
/** {@inheritDoc} */
@Override
public boolean prepareAction() throws Exception {
return super.prepareAction() && getModel().getSelectedRows().size() == 1;
}
/** {@inheritDoc} */
@Override
public void doAction() {
// Selected measurement
final SurveyMeasurementsGroupedRowModel rowToDuplicate = getModel().getSelectedRows().iterator().next();
if (rowToDuplicate != null) {
row = new SurveyMeasurementsGroupedRowModel(false);
row.setTaxonGroup(rowToDuplicate.getTaxonGroup());
row.setTaxon(rowToDuplicate.getTaxon());
row.setInputTaxonId(rowToDuplicate.getInputTaxonId());
row.setInputTaxonName(rowToDuplicate.getInputTaxonName());
row.setComment(rowToDuplicate.getComment());
row.setIndividualPmfms(rowToDuplicate.getIndividualPmfms());
// add also analyst (MAntis #45054)
row.setAnalyst(rowToDuplicate.getAnalyst());
// duplicate measurements by service
row.setIndividualMeasurements(getContext().getObservationService().duplicateMeasurements(rowToDuplicate.getIndividualMeasurements()));
}
}
/** {@inheritDoc} */
@Override
public void postSuccessAction() {
super.postSuccessAction();
// Add duplicate measurement to table
getModel().insertRowAfterSelected(row);
// save directly to sampling operation
getHandler().saveMeasurementsInModel(row);
getHandler().recomputeRowsValidState();
getModel().setModify(true);
// Ajouter le focus sur la cellule de la ligne cree
getHandler().setFocusOnCell(row);
}
}
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
<JPanel id='tableauBasPanelButtons' layout='{new BorderLayout()}' constraints="BorderLayout.PAGE_END"> <JPanel id='tableauBasPanelButtons' layout='{new BorderLayout()}' constraints="BorderLayout.PAGE_END">
<JPanel layout='{new FlowLayout()}' constraints='BorderLayout.LINE_START'> <JPanel layout='{new FlowLayout()}' constraints='BorderLayout.LINE_START'>
<JButton id='newButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="model.insertNewRowAfterSelected()"/> <JButton id='newButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="model.insertNewRowAfterSelected()"/>
<JButton id='duplicateButton' alignmentX='{Component.CENTER_ALIGNMENT}'/> <JButton id='duplicateButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.duplicateSelectedRow()"/>
<JButton id='multiEditButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.editSelectedMeasurements()"/> <JButton id='multiEditButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.editSelectedMeasurements()"/>
<JButton id='deleteButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.removeIndividualMeasurements()"/> <JButton id='deleteButton' alignmentX='{Component.CENTER_ALIGNMENT}' onActionPerformed="handler.removeIndividualMeasurements()"/>
</JPanel> </JPanel>
......
...@@ -52,7 +52,6 @@ ...@@ -52,7 +52,6 @@
actionIcon: copy; actionIcon: copy;
text: "reefdb.action.duplicate.label"; text: "reefdb.action.duplicate.label";
toolTipText: "reefdb.action.duplicate.measurement.tip"; toolTipText: "reefdb.action.duplicate.measurement.tip";
_applicationAction: {DuplicateSurveyMeasurementsAction.class};
enabled: {model.getSurvey().isEditable() && !model.getSelectedRows().isEmpty() && (model.getSelectedRows().size() == 1) && !model.getPmfms().isEmpty()}; enabled: {model.getSurvey().isEditable() && !model.getSelectedRows().isEmpty() && (model.getSelectedRows().size() == 1) && !model.getPmfms().isEmpty()};
} }
......
...@@ -172,7 +172,7 @@ public class SurveyMeasurementsUngroupedTableUIHandler ...@@ -172,7 +172,7 @@ public class SurveyMeasurementsUngroupedTableUIHandler
recomputeRowsValidState(); recomputeRowsValidState();
// restore table from swing session // restore table from swing session
getContext().restoreComponentFromSwingSession(getTable()); restoreTableState();
// hide analyst if no pmfm // hide analyst if no pmfm
// forceColumnVisibleAtLastPosition(SurveyMeasurementsUngroupedTableModel.ANALYST, notEmpty); // forceColumnVisibleAtLastPosition(SurveyMeasurementsUngroupedTableModel.ANALYST, notEmpty);
......
package fr.ifremer.reefdb.ui.swing.util;
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 parent;
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);
}
private OneShotListener(Component parent, String propertyName, Consumer<PropertyChangeEvent> consumer) {
this.parent = parent;
this.propertyName = propertyName;
this.consumer = consumer;
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
consumer.accept(evt);
parent.removePropertyChangeListener(propertyName, this);
}
}
...@@ -31,6 +31,15 @@ ...@@ -31,6 +31,15 @@
</properties> </properties>
<body> <body>
<release version="3.9.7" date="2020-03-19" description="Stable release">
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51520">
Rework the calculation of individual ids on grouped measurements, now use table sorting if possible
</action>
<action dev="ludovic.pecquot@e-is.pro" type="add">
Upgrade quadrige3-core to version 3.6.13
</action>
</release>
<release version="3.9.6" date="2020-03-06" description="Stable release"> <release version="3.9.6" date="2020-03-06" description="Stable release">
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51385"> <action dev="ludovic.pecquot@e-is.pro" type="fix" issue="51385">
Upgrade quadrige3-core to version 3.6.11 Upgrade quadrige3-core to version 3.6.11
......