Commit 2e0eeb3b authored by PECQUOT's avatar PECQUOT
Browse files

[fix] Restore transition calculator after save (Mantis #48255)


Signed-off-by: PECQUOT's avatarlp1ee9d <ludovic.pecquot@e-is.pro>
parent 887fabdd
......@@ -60,10 +60,6 @@
<artifactId>quadrige3-test-shared</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>fr.ifremer.quadrige3</groupId>
<artifactId>quadrige3-ui-core-common</artifactId>
</dependency>
</dependencies>
......
......@@ -126,7 +126,6 @@ public class DecoratorServiceImpl extends fr.ifremer.quadrige3.core.service.deco
provider.registerDecorator(CodeOnly.class, "${code}$s", TOKEN_SEPARATOR, SEPARATOR);
// data
// provider.registerDecorator(CampaignDTO.class, "${name}$s", TOKEN_SEPARATOR, SEPARATOR); // not needed
provider.registerDecorator(OccasionDTO.class, "${name}$s", TOKEN_SEPARATOR, SEPARATOR);
provider.registerDecorator(SamplingOperationDTO.class, "${name}$s", TOKEN_SEPARATOR, SEPARATOR);
provider.registerDecorator(CONCAT, new SamplingOperationDecorator());
......
......@@ -49,25 +49,18 @@ import fr.ifremer.reefdb.dto.referential.LocationDTO;
import fr.ifremer.reefdb.dto.referential.pmfm.PmfmDTO;
import fr.ifremer.reefdb.dto.system.extraction.ExtractionDTO;
import fr.ifremer.reefdb.dto.system.extraction.ExtractionPeriodDTO;
import fr.ifremer.reefdb.service.ReefDbTechnicalException;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.nuiton.util.DateUtil;
import java.lang.reflect.InvocationTargetException;
import java.sql.Array;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static org.nuiton.i18n.I18n.t;
/**
* useful methods around ReefDb bean.
*
......@@ -75,29 +68,6 @@ import static org.nuiton.i18n.I18n.t;
*/
public class ReefDbBeans extends QuadrigeBeans {
/**
* Constant <code>GET_ID_STRING</code>
*/
public static final Function<QuadrigeBean, String> GET_ID_STRING = input -> (input == null) ? null : input.getId().toString();
/**
* Constant <code>ID_MAPPER</code>
*/
public static final Function<String, Integer> ID_MAPPER = id -> (id == null || id.isEmpty()) ? null : Integer.valueOf(id);
/**
* Constant <code>GET_CODE</code>
*/
public static final Function<QuadrigeBean, String> GET_CODE = p -> (p == null) ? null : (String) getProperty(p, "code");
/**
* Constant <code>DEFAULT_DATE_FORMAT="dd/MM/yyyy"</code>
*/
private static final String DEFAULT_DATE_FORMAT = "dd/MM/yyyy";
/**
* Constant <code>DEFAULT_STRING_SEPARATOR=" - "</code>
*/
private static final String DEFAULT_STRING_SEPARATOR = " - ";
private static DecimalFormatSymbols symbols;
private static DecimalFormat decimalFormat;
/**
* <p>Constructor for ReefDbBeans.</p>
*/
......@@ -119,38 +89,6 @@ public class ReefDbBeans extends QuadrigeBeans {
}
}
/**
* <p>getDecimalFormatSymbols.</p>
*
* @return a {@link DecimalFormatSymbols} object.
*/
public static DecimalFormatSymbols getDecimalFormatSymbols() {
if (symbols == null) {
symbols = new DecimalFormatSymbols();
symbols.setDecimalSeparator('.');
symbols.setGroupingSeparator(' ');
}
return symbols;
}
/**
* <p>Getter for the field <code>decimalFormat</code>.</p>
*
* @param minDecimal a int.
* @param maxDecimal a int.
* @return a {@link DecimalFormat} object.
*/
public static DecimalFormat getDecimalFormat(int minDecimal, int maxDecimal) {
if (decimalFormat == null) {
decimalFormat = new DecimalFormat();
decimalFormat.setDecimalFormatSymbols(getDecimalFormatSymbols());
decimalFormat.setGroupingUsed(false);
}
decimalFormat.setMinimumFractionDigits(minDecimal);
decimalFormat.setMaximumFractionDigits(maxDecimal);
return decimalFormat;
}
/**
* <p>computeAddress.</p>
*
......@@ -246,61 +184,6 @@ public class ReefDbBeans extends QuadrigeBeans {
return bean.toString();
}
/**
* transform the string to a secured format (eg for file name):
* - strip accents
* - remove special characters
*
* @param text to transform
* @return transformed string
*/
public static String toSecuredString(String text) {
if (text == null) return null;
// remove special characters
String result = text.trim().replaceAll("[.,:;'\"()\\[\\]{}?!^=+/\\\\#~%²&|`¨@$£€¤µ*§]+", "");
// transform accented characters
return StringUtils.stripAccents(result);
}
/**
* transform the string to a fully secured format (eg for extraction):
* - strip accents
* - remove article with apostrophe
* - remove special characters
* - replace space by underscore
*
* @param text to transform
* @return transformed string
*/
public static String toFullySecuredString(String text) {
if (text == null) return null;
// remove d' l'
String result = text.replaceAll("[a-zA-Z]'", "");
// transform accented characters and remove special characters
result = toSecuredString(result);
// replace space by underscore
return result.replaceAll(" ", "_");
}
/**
* <p>clone.</p>
*
* @param bean a B object.
* @param <B> a B object.
* @return a B object.
* @throws ReefDbTechnicalException if any.
*/
@SuppressWarnings("unchecked")
public static <B extends QuadrigeBean> B clone(final B bean) throws ReefDbTechnicalException {
if (bean == null) return null;
try {
// Clone bean
return (B) BeanUtils.cloneBean(bean);
} catch (final IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
throw new ReefDbTechnicalException(t("reefdb.error.exception.duplicateBean"), e);
}
}
/**
* <p>filterNotEmptyAppliedPeriod.</p>
*
......@@ -938,28 +821,6 @@ public class ReefDbBeans extends QuadrigeBeans {
|| SynchronizationStatusValues.READY_TO_SYNCHRONIZE.equals(survey.getSynchronizationStatus());
}
/**
* <p>filterProgramsByCodes.</p>
*
* @param source a {@link List} object.
* @param allowedProgramCodes a {@link Set} object.
* @return a {@link List} object.
*/
public static List<ProgramDTO> filterProgramsByCodes(List<ProgramDTO> source, final Set<String> allowedProgramCodes) {
// Do not filter if programs list from config is empty
// or if given list is empty
if (CollectionUtils.isEmpty(allowedProgramCodes)
|| CollectionUtils.isEmpty(source)) {
return source;
}
// Keep programs found in the config list
return ReefDbBeans.filterCollection(source, programDTO -> programDTO != null
&& programDTO.getCode() != null
&& allowedProgramCodes.contains(programDTO.getCode())
);
}
/**
* <p>getFilterOfType.</p>
*
......
......@@ -280,7 +280,6 @@ reefdb.error.dao.ruleList.rule.empty=The rule list '%s' is not compatible (rule
reefdb.error.dao.ruleList.rule.skip=Control rule [%s] skipped (Bad controlled attribute '%s').
reefdb.error.delete.directory=
reefdb.error.emptyResponse=No response received from the server
reefdb.error.exception.duplicateBean=
reefdb.error.filter.import.error=
reefdb.error.filter.import.withLocalReferential=
reefdb.error.filter.import.wrongFilterType=
......
......@@ -250,7 +250,6 @@ reefdb.error.dao.ruleList.rule.empty=La liste de règles '%s' n'est pas compatib
reefdb.error.dao.ruleList.rule.skip=La règle de contrôle [%s] est ignorée (Elément à controller inconnu \= '%s')
reefdb.error.delete.directory=Impossible de supprimer le répertoire %s
reefdb.error.emptyResponse=Aucune réponse reçue du serveur
reefdb.error.exception.duplicateBean=
reefdb.error.filter.import.error=Le fichier que vous avez spécifié n’est pas un fichier de filtre ${reefdb.application.name}.
reefdb.error.filter.import.withLocalReferential=Le filtre '%s' contient des des éléments de référentiel local.<br/>Importation annulée.
reefdb.error.filter.import.wrongFilterType=Le fichier que vous avez spécifié n’est pas un fichier de filtre sur <b>%s</b> mais sur <b>%s</b><br/>Importation annulée.
......
......@@ -181,12 +181,12 @@ public class OperationMeasurementsTabUIHandler extends AbstractReefDbUIHandler<O
});
// add listeners on table models
getModel().getUngroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsUngroupedTableUIModel.PROPERTY_MEASUREMENTS_LOADED, evt -> {
getModel().getUngroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsUngroupedTableUIModel.EVENT_MEASUREMENTS_LOADED, evt -> {
// detect if the triplet of PMFM for transition length
detectPmfmForTransitionCalculator();
detectPmfmForGridInitialization();
});
getModel().getGroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsGroupedTableUIModel.PROPERTY_MEASUREMENTS_LOADED, evt -> {
getModel().getGroupedTableUIModel().addPropertyChangeListener(OperationMeasurementsGroupedTableUIModel.EVENT_MEASUREMENTS_LOADED, evt -> {
// detect if the triplet of PMFM for transition length
detectPmfmForTransitionCalculator();
detectPmfmForGridInitialization();
......
......@@ -182,7 +182,7 @@ public class OperationMeasurementsUngroupedTableUIHandler extends AbstractReefDb
// Install save state listener
installSaveTableStateListener();
getModel().setMeasurementsLoaded(true);
getModel().fireMeasurementsLoaded();
});
}
......
......@@ -38,11 +38,10 @@ public class OperationMeasurementsUngroupedTableUIModel extends AbstractReefDbTa
public static final String PROPERTY_SURVEY = "survey";
public static final String PROPERTY_SAMPLING_FILTER = "samplingFilter";
public static final String PROPERTY_MEASUREMENTS_LOADED = "measurementsLoaded";
public static final String EVENT_MEASUREMENTS_LOADED = "measurementsLoaded";
private ObservationUIModel survey;
private SamplingOperationDTO samplingFilter;
private boolean measurementsLoaded;
/**
* Constructor.
......@@ -114,13 +113,7 @@ public class OperationMeasurementsUngroupedTableUIModel extends AbstractReefDbTa
return measurements;
}
public boolean isMeasurementsLoaded() {
return measurementsLoaded;
}
public void setMeasurementsLoaded(boolean measurementsLoaded) {
boolean oldValue = isMeasurementsLoaded();
this.measurementsLoaded = measurementsLoaded;
firePropertyChange(PROPERTY_MEASUREMENTS_LOADED, oldValue, measurementsLoaded);
public void fireMeasurementsLoaded() {
firePropertyChange(EVENT_MEASUREMENTS_LOADED, null, null);
}
}
......@@ -222,7 +222,7 @@ public abstract class AbstractMeasurementsGroupedTableUIHandler<
loadMeasurements();
break;
case AbstractMeasurementsGroupedTableUIModel.PROPERTY_MEASUREMENTS_LOADED:
case AbstractMeasurementsGroupedTableUIModel.EVENT_MEASUREMENTS_LOADED:
detectPreconditionedPmfms();
detectGroupedIdentifiers();
......@@ -297,7 +297,7 @@ public abstract class AbstractMeasurementsGroupedTableUIHandler<
// Install save state listener
installSaveTableStateListener();
getModel().setMeasurementsLoaded(true);
getModel().fireMeasurementsLoaded();
});
}
......
......@@ -49,7 +49,7 @@ public abstract class AbstractMeasurementsGroupedTableUIModel<B extends Quadrige
public static final String PROPERTY_SURVEY = "survey";
public static final String PROPERTY_MEASUREMENT_FILTER = "measurementFilter";
public static final String PROPERTY_MEASUREMENTS_LOADED = "measurementsLoaded";
public static final String EVENT_MEASUREMENTS_LOADED = "measurementsLoaded";
// the survey model
private ObservationUIModel survey;
......@@ -62,7 +62,6 @@ public abstract class AbstractMeasurementsGroupedTableUIModel<B extends Quadrige
// map holding groups per pmfm id
private Multimap<ControlRuleDTO, Map.Entry<RuleGroupDTO, ReefDbColumnIdentifier<R>>> identifiersByGroupedRuleMap;
private boolean adjusting;
private boolean measurementsLoaded;
/**
* <p>Getter for the field <code>survey</code>.</p>
......@@ -177,13 +176,7 @@ public abstract class AbstractMeasurementsGroupedTableUIModel<B extends Quadrige
this.adjusting = adjusting;
}
public boolean isMeasurementsLoaded() {
return measurementsLoaded;
}
public void setMeasurementsLoaded(boolean measurementsLoaded) {
boolean oldValue = isMeasurementsLoaded();
this.measurementsLoaded = measurementsLoaded;
firePropertyChange(PROPERTY_MEASUREMENTS_LOADED, oldValue, measurementsLoaded);
public void fireMeasurementsLoaded() {
firePropertyChange(EVENT_MEASUREMENTS_LOADED, null, null);
}
}
......@@ -180,7 +180,7 @@ public class SurveyMeasurementsUngroupedTableUIHandler
// Install save state listener
installSaveTableStateListener();
getModel().setMeasurementsLoaded(true);
getModel().fireMeasurementsLoaded();
});
}
......
......@@ -33,10 +33,9 @@ import fr.ifremer.reefdb.ui.swing.util.table.AbstractReefDbTableUIModel;
public class SurveyMeasurementsUngroupedTableUIModel extends AbstractReefDbTableUIModel<SurveyDTO, SurveyMeasurementsUngroupedRowModel, SurveyMeasurementsUngroupedTableUIModel> {
public static final String PROPERTY_SURVEY = "survey";
public static final String PROPERTY_MEASUREMENTS_LOADED = "measurementsLoaded";
public static final String EVENT_MEASUREMENTS_LOADED = "measurementsLoaded";
private ObservationUIModel survey;
private boolean measurementsLoaded;
/**
* Constructor.
......@@ -64,13 +63,7 @@ public class SurveyMeasurementsUngroupedTableUIModel extends AbstractReefDbTable
firePropertyChange(PROPERTY_SURVEY, null, survey);
}
public boolean isMeasurementsLoaded() {
return measurementsLoaded;
}
public void setMeasurementsLoaded(boolean measurementsLoaded) {
boolean oldValue = isMeasurementsLoaded();
this.measurementsLoaded = measurementsLoaded;
firePropertyChange(PROPERTY_MEASUREMENTS_LOADED, oldValue, measurementsLoaded);
public void fireMeasurementsLoaded() {
firePropertyChange(EVENT_MEASUREMENTS_LOADED, null, null);
}
}
......@@ -65,6 +65,9 @@
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="48115">
Try to deleting a forbidden campaign will not remove the line
</action>
<action dev="ludovic.pecquot@e-is.pro" type="fix" issue="48255">
Restore transition calculator after save
</action>
<action dev="ludovic.pecquot@e-is.pro" type="add">
Use the new quadrige3-ui-core-common module with many model refactoring
</action>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment