branch develop updated (068770c -> 1f4faad)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git from 068770c Corrections et améliorations diverses sur l'écran des observations individuelles new 5e7552f Suppression des bons lots new 6e821cb Correction de la suppression d'une opération de pêche dans le cache des échantillons new fba0a6a Mieux recharger l'opération dans le contexte de données new 0b290b1 Ajout de plus de logs suite à la suppression d'une opération dans le cache new 5dbc8d1 Ajout d'une méthode pour nettoyer les caches (supprimer les clefs vides) + afficher les caches new 95043cf A la sauvegarde d'une opération, on doit rafraîchir le contexte de données new 8a3df5d Envoyer un signal quand l'opération est rechargée new 1f4faad Bien recharger l'opération de pêche lorsqu'elle change dans le contexte de données The 8 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 1f4faadf6384c4bf721b8ca2ed566c1fd1eae01c Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:31:07 2016 +0200 Bien recharger l'opération de pêche lorsqu'elle change dans le contexte de données commit 8a3df5de4e33f530cbe00c89e8ece21d91bf99a6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:30:36 2016 +0200 Envoyer un signal quand l'opération est rechargée commit 95043cf68e2a0144754fe868f488c70679b099ab Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:17:09 2016 +0200 A la sauvegarde d'une opération, on doit rafraîchir le contexte de données commit 5dbc8d1e4a632f45f7156893e92fd1475660196d Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:15:30 2016 +0200 Ajout d'une méthode pour nettoyer les caches (supprimer les clefs vides) + afficher les caches commit 0b290b134a7d2f2c319facf058e01de51f2d0607 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:14:18 2016 +0200 Ajout de plus de logs suite à la suppression d'une opération dans le cache commit fba0a6ae519d57bbe908d8418dede26018a20f1f Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:13:32 2016 +0200 Mieux recharger l'opération dans le contexte de données commit 6e821cb6c99d4447a01170b92bc01617cc37f61f Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 19:51:07 2016 +0200 Correction de la suppression d'une opération de pêche dans le cache des échantillons commit 5e7552f416a6f78a06fce315e15668bdbdd86d30 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 19:50:16 2016 +0200 Suppression des bons lots Summary of changes: .../ifremer/tutti/service/PersistenceService.java | 8 ++ .../fr/ifremer/tutti/service/TuttiDataContext.java | 6 +- .../service/sampling/CruiseSamplingCache.java | 93 +++++++++++++------ .../sampling/CruiseSamplingInternalCache.java | 78 ++++++++-------- .../catches/species/BenthosBatchUISupportImpl.java | 10 ++ .../catches/species/SpeciesBatchUISupportImpl.java | 9 ++ .../species/SpeciesOrBenthosBatchUISupport.java | 3 + .../edit/actions/RemoveSpeciesBatchAction.java | 6 +- .../edit/actions/RemoveSpeciesSubBatchAction.java | 6 +- .../frequency/IndividualObservationUICache.java | 30 +++++- .../frequency/SpeciesFrequencyUIHandler.java | 14 ++- .../actions/SaveFishingOperationAction.java | 102 ++++++++++++--------- 12 files changed, 235 insertions(+), 130 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 5e7552f416a6f78a06fce315e15668bdbdd86d30 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 19:50:16 2016 +0200 Suppression des bons lots --- .../operation/catches/species/BenthosBatchUISupportImpl.java | 10 ++++++++++ .../operation/catches/species/SpeciesBatchUISupportImpl.java | 9 +++++++++ .../catches/species/SpeciesOrBenthosBatchUISupport.java | 3 +++ .../catches/species/edit/actions/RemoveSpeciesBatchAction.java | 6 +----- .../species/edit/actions/RemoveSpeciesSubBatchAction.java | 6 +----- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/BenthosBatchUISupportImpl.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/BenthosBatchUISupportImpl.java index f46815a..c092fd3 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/BenthosBatchUISupportImpl.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/BenthosBatchUISupportImpl.java @@ -264,4 +264,14 @@ public class BenthosBatchUISupportImpl extends SpeciesOrBenthosBatchUISupport { return context.getDataContext().getProtocol().getBenthos(); } + @Override + public void deleteSpeciesSubBatch(Integer speciesBatchId) { + getPersistenceService().deleteBenthosSubBatch(speciesBatchId); + } + + @Override + public void deleteSpeciesBatch(Integer speciesBatchId) { + getPersistenceService().deleteBenthosBatch(speciesBatchId); + } + } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUISupportImpl.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUISupportImpl.java index 28faded..b648ec4 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUISupportImpl.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUISupportImpl.java @@ -264,4 +264,13 @@ public class SpeciesBatchUISupportImpl extends SpeciesOrBenthosBatchUISupport { return context.getDataContext().getProtocol().getSpecies(); } + @Override + public void deleteSpeciesSubBatch(Integer speciesBatchId) { + getPersistenceService().deleteSpeciesSubBatch(speciesBatchId); + } + + @Override + public void deleteSpeciesBatch(Integer speciesBatchId) { + getPersistenceService().deleteSpeciesBatch(speciesBatchId); + } } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesOrBenthosBatchUISupport.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesOrBenthosBatchUISupport.java index 96b60bc..32cadb1 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesOrBenthosBatchUISupport.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesOrBenthosBatchUISupport.java @@ -189,4 +189,7 @@ public abstract class SpeciesOrBenthosBatchUISupport { return context.getDataContext().getBestFirstSampleCategory(data, speciesProtocol); } + public abstract void deleteSpeciesSubBatch(Integer speciesBatchId); + + public abstract void deleteSpeciesBatch(Integer speciesBatchId); } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RemoveSpeciesBatchAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RemoveSpeciesBatchAction.java index d53a6da..8e6163f 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RemoveSpeciesBatchAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RemoveSpeciesBatchAction.java @@ -23,7 +23,6 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.actions */ import com.google.common.base.Preconditions; -import fr.ifremer.tutti.persistence.TuttiPersistence; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchTableModel; @@ -100,8 +99,6 @@ public class RemoveSpeciesBatchAction extends LongActionSupport<SpeciesBatchUIMo @Override public void doAction() throws Exception { - TuttiPersistence persistenceService = getContext().getPersistenceService(); - int[] selectedRowIndexes = SwingUtil.getSelectedModelRows(handler.getTable()); Preconditions.checkState(selectedRowIndexes.length > 0, "Cant remove batches if no batches selected"); @@ -132,8 +129,7 @@ public class RemoveSpeciesBatchAction extends LongActionSupport<SpeciesBatchUIMo } // remove selected batch and all his children - persistenceService.deleteSpeciesBatch(selectedBatchId); - + getModel().getSpeciesOrBenthosBatchUISupport() .deleteSpeciesBatch(selectedBatchId); if (batchRoot) { // update speciesUsed diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RemoveSpeciesSubBatchAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RemoveSpeciesSubBatchAction.java index e63a9d4..8b23d35 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RemoveSpeciesSubBatchAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/edit/actions/RemoveSpeciesSubBatchAction.java @@ -23,7 +23,6 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.actions */ import com.google.common.base.Preconditions; -import fr.ifremer.tutti.persistence.TuttiPersistence; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.species.edit.SpeciesBatchUI; @@ -93,21 +92,18 @@ public class RemoveSpeciesSubBatchAction extends LongActionSupport<SpeciesBatchU @Override public void doAction() throws Exception { - TuttiPersistence persistenceService = getContext().getPersistenceService(); - JXTable table = handler.getTable(); rowIndex = SwingUtil.getSelectedModelRow(table); Preconditions.checkState(rowIndex != -1, "Cant remove sub batch if no batch selected"); - parentBatch = handler.getTableModel().getEntry(rowIndex); Preconditions.checkState(!TuttiEntities.isNew(parentBatch), "Can't remove sub batch if batch is not persisted"); // save parent batch (will destroy all his childs from db) - persistenceService.deleteSpeciesSubBatch(parentBatch.getIdAsInt()); + getModel().getSpeciesOrBenthosBatchUISupport().deleteSpeciesSubBatch(parentBatch.getIdAsInt()); // collect of rows to remove from model -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 6e821cb6c99d4447a01170b92bc01617cc37f61f Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 19:51:07 2016 +0200 Correction de la suppression d'une opération de pêche dans le cache des échantillons --- .../service/sampling/CruiseSamplingCache.java | 66 +++++++++++--------- .../sampling/CruiseSamplingInternalCache.java | 70 ++++++++++------------ 2 files changed, 69 insertions(+), 67 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java index d7c30af..23d5743 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java @@ -49,9 +49,10 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; -import java.util.Set; import java.util.stream.IntStream; +import static fr.ifremer.tutti.service.sampling.CruiseSamplingInternalCache.addPrefixKey; + /** * @author Kevin Morin (Code Lutin) * @since 4.5 @@ -280,44 +281,53 @@ public class CruiseSamplingCache implements CruiseCacheAble { Zone zone = optionalZone.get(); - setLoading(true); - try { + String fishingOperationId = fishingOperation.getId(); - String fishingOperationId = fishingOperation.getId(); + if (log.isInfoEnabled()) { + log.info("Removing fishing operation: " + fishingOperation + " from " + this); + } - if (log.isInfoEnabled()) { - log.info("Removing fishing operation: " + fishingOperation + " from " + this); - } + // suppression de toutes les entrées du cache des opérations (et récupération des clefs) - // suppression de toutes les entrées du cache des opérations (et récupération des clefs) - Set<String> removedKeys = fishingOperationCache.removeAllWhereKeyStartingWith(fishingOperationId); + String keyPrefix = CruiseSamplingInternalCache.addPrefixKey(fishingOperationId, ""); + int keyPrefixLength = keyPrefix.length(); - if (log.isInfoEnabled()) { - log.info("Fishing operation: " + fishingOperation + " removed from fishingOperationCache: " + fishingOperationCache.size()); - } + String zoneId = zone.getId(); - removedKeys.forEach(cruiseCache::removeOneIndividualObservation); + fishingOperationCache.getKeys() + .stream() + .filter(key -> key.startsWith(keyPrefix)) + .forEach(fishingOperationSamplingKey -> { - if (log.isInfoEnabled()) { - log.info("Fishing operation: " + fishingOperation + " removed from cruiseCache: " + cruiseCache.size()); - } + CruiseSamplingInternalCache.SamplingData samplingData = fishingOperationCache.getSamplingData(fishingOperationSamplingKey); - String zoneId = zone.getId(); - removedKeys.forEach(key -> zoneCache.removeOneIndividualObservation(CruiseSamplingInternalCache.addPrefixKey(zoneId, key))); + if (log.isInfoEnabled()) { + log.info("Found " + fishingOperationSamplingKey + " to remove from fishing operation cache (" + samplingData + ")."); + } - if (log.isInfoEnabled()) { - log.info("Fishing operation: " + fishingOperation + " removed from zoneCache: " + zoneCache.size()); - } + int individualObservationCount = samplingData.getIndividualObservationCount(); + int samplingCount = samplingData.getSamplingCount(); - if (log.isInfoEnabled()) { - log.info("Fishing operation: " + fishingOperation + " removed from " + this); - } + String cruiseSamplingKey = fishingOperationSamplingKey.substring(keyPrefixLength); + cruiseCache.remove(cruiseSamplingKey, individualObservationCount, samplingCount); - } finally { + String zoneSamplingKey = addPrefixKey(zoneId, cruiseSamplingKey); + zoneCache.remove(zoneSamplingKey, individualObservationCount, samplingCount); - setLoading(false); + fishingOperationCache.remove(fishingOperationSamplingKey, individualObservationCount, samplingCount); + + }); + cruiseCache.cleanEmptyEntries(); + zoneCache.cleanEmptyEntries(); + fishingOperationCache.cleanEmptyEntries(); + + if (log.isInfoEnabled()) { + log.info("Fishing operation: " + fishingOperation + " removed from fishingOperationCache: " + fishingOperationCache.size()); + log.info("Fishing operation: " + fishingOperation + " removed from cruiseCache: " + cruiseCache.size()); + log.info("Fishing operation: " + fishingOperation + " removed from zoneCache: " + zoneCache.size()); + log.info("Fishing operation: " + fishingOperation + " removed from " + this); } } @@ -531,11 +541,11 @@ public class CruiseSamplingCache implements CruiseCacheAble { } private String createZoneSamplingKey(String cruiseSamplingKey, Zone zone) { - return CruiseSamplingInternalCache.addPrefixKey(zone.getId(), cruiseSamplingKey); + return addPrefixKey(zone.getId(), cruiseSamplingKey); } private String createFishingOperationSamplingKey(String cruiseSamplingKey, int fishingOperationId) { - return CruiseSamplingInternalCache.addPrefixKey(fishingOperationId, cruiseSamplingKey); + return addPrefixKey(fishingOperationId, cruiseSamplingKey); } private void addIndividualObservation(IndividualObservationSamplingContext individualObservationSamplingContext, boolean addSampling) { diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java index 9b896d4..d327d78 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java @@ -29,13 +29,11 @@ import com.google.common.base.Preconditions; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import java.io.Closeable; import java.io.Serializable; +import java.util.Collections; import java.util.Iterator; -import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -51,9 +49,6 @@ import java.util.TreeMap; */ class CruiseSamplingInternalCache implements Closeable { - /** Logger. */ - private static final Log log = LogFactory.getLog(CruiseSamplingInternalCache.class); - private static final String KEY_SEPARATOR = "#"; public static String createSamplingKey(Species species, CaracteristicQualitativeValue gender, Boolean maturity, int lengthStep) { @@ -90,39 +85,6 @@ class CruiseSamplingInternalCache implements Closeable { } /** - * Supprime du cache toutes les entrées dont la clef commence par l'identifiant donné (suivant du séparateur de clef) - * et retourne l'ensemble des clefs supprimées du cache. - * - * À noter que sur les clefs retournées, on a retirer le préfixe de concordance. - * - * @param id l'identifiant de début de clef à supprimer - * @return l'ensemble des clefs supprimées du cache (amputées du préfixe de concordance). - */ - public Set<String> removeAllWhereKeyStartingWith(String id) { - Objects.requireNonNull(id); - String keyPrefix = addPrefixKey(id, ""); - if (log.isDebugEnabled()) { - log.debug("Ask to remove all keys starting with: " + keyPrefix); - } - Set<String> result = new LinkedHashSet<>(); - Iterator<Map.Entry<String, SamplingData>> iterator = data.entrySet().iterator(); - int keyPrefixLength = keyPrefix.length(); - while (iterator.hasNext()) { - Map.Entry<String, SamplingData> entry = iterator.next(); - String key = entry.getKey(); - - if (key.startsWith(keyPrefix)) { - iterator.remove(); - if (log.isDebugEnabled()) { - log.debug("Removing key: " + key); - } - result.add(key.substring(keyPrefixLength)); - } - } - return result; - } - - /** * Get the number of samplings by lengthstep for a species, maturity and gender, for the lengthsteps between min size and max size * * @return a map of the number of samplings for each lengthstep in millimeters @@ -207,6 +169,36 @@ class CruiseSamplingInternalCache implements Closeable { return samplingData; } + public Set<String> getKeys() { + return Collections.unmodifiableSet(data.keySet()); + } + + public void remove(String key, int individualObservationCountToRemove, int samplingCountToRemove) { + + SamplingData samplingData = getSamplingData(key); + Objects.requireNonNull(samplingData, "[" + key + "] not found."); + + int individualObservationCount = samplingData.getIndividualObservationCount(); + Preconditions.checkState(individualObservationCount >= individualObservationCountToRemove, "[" + key + "] You cannot decrement " + individualObservationCountToRemove + " individual observation(s), you just have " + individualObservationCount); + samplingData.individualObservationCount -= individualObservationCountToRemove; + + int samplingCount = samplingData.getSamplingCount(); + Preconditions.checkState(samplingCount >= samplingCountToRemove, "[" + key + "] You cannot decrement " + samplingCountToRemove + " sampling(s), you just have " + samplingCount); + samplingData.samplingCount -= samplingCountToRemove; + + } + + public void cleanEmptyEntries() { + Iterator<Map.Entry<String, SamplingData>> iterator = data.entrySet().iterator(); + while (iterator.hasNext()) { + Map.Entry<String, SamplingData> entry = iterator.next(); + SamplingData samplingData = entry.getValue(); + if (!(samplingData.withSampling() || samplingData.withIndividualObservation())) { + iterator.remove(); + } + } + } + class SamplingData { /** -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit fba0a6ae519d57bbe908d8418dede26018a20f1f Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:13:32 2016 +0200 Mieux recharger l'opération dans le contexte de données --- .../src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java index 09fd0b0..b733e9d 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java @@ -617,15 +617,14 @@ public class TuttiDataContext extends AbstractBean implements Closeable { return fishingOperation; } - public FishingOperation reloadFishingOperation() { + public void reloadFishingOperation() { checkOpened(); Preconditions.checkState(isFishingOperationFilled()); Integer id = getFishingOperationId(); if (log.isInfoEnabled()) { log.info("Reloading fishingOperation: " + id); } - fishingOperation = service.getFishingOperation(id); - return fishingOperation; + resetFishingOperation(); } public List<Caracteristic> getCaracteristics() { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 0b290b134a7d2f2c319facf058e01de51f2d0607 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:14:18 2016 +0200 Ajout de plus de logs suite à la suppression d'une opération dans le cache --- .../main/java/fr/ifremer/tutti/service/PersistenceService.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java index 771cc7e..bcfb6cb 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java @@ -1382,6 +1382,8 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer } reloadSamplingCache = true; + cruiseSamplingCache.printInfos("Before removing fishing operation"); + List<IndividualObservationBatch> individualObservations = getAllIndividualObservationBatchsForFishingOperation(bean.getIdAsInt()); cruiseCache.removeFishingOperation(oldFishingOperation, individualObservations); @@ -1399,9 +1401,15 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer log.info("Zone has changed for fishingOperation: " + bean + ", recompute fishing operation from cruise cache."); } + CruiseSamplingCache cruiseSamplingCache = cruiseCache.getSamplingCruiseCache().orElseGet(null); + + cruiseSamplingCache.printInfos("Before loading " + fishingOperation); + CruiseCacheLoader cruiseCacheLoader = CruiseCacheLoader.newCacheLoader(this, context.getService(DecoratorService.class), null, cruiseCache); cruiseCacheLoader.loadCruiseCacheForFishingOperation(fishingOperation); + cruiseSamplingCache.printInfos("After loading " + fishingOperation); + } return fishingOperation; } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 5dbc8d1e4a632f45f7156893e92fd1475660196d Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:15:30 2016 +0200 Ajout d'une méthode pour nettoyer les caches (supprimer les clefs vides) + afficher les caches --- .../service/sampling/CruiseSamplingCache.java | 41 ++++++++++++++++++---- .../sampling/CruiseSamplingInternalCache.java | 8 +++++ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java index 23d5743..f6c4e19 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingCache.java @@ -319,15 +319,17 @@ public class CruiseSamplingCache implements CruiseCacheAble { }); - cruiseCache.cleanEmptyEntries(); - zoneCache.cleanEmptyEntries(); - fishingOperationCache.cleanEmptyEntries(); + printInfos("After removing " + fishingOperation); + + cleanEmptyEntries(); + + printInfos("After cleanEmptyEntries"); if (log.isInfoEnabled()) { - log.info("Fishing operation: " + fishingOperation + " removed from fishingOperationCache: " + fishingOperationCache.size()); - log.info("Fishing operation: " + fishingOperation + " removed from cruiseCache: " + cruiseCache.size()); - log.info("Fishing operation: " + fishingOperation + " removed from zoneCache: " + zoneCache.size()); - log.info("Fishing operation: " + fishingOperation + " removed from " + this); + log.info(fishingOperation + " removed from fishingOperationCache: " + fishingOperationCache.size()); + log.info(fishingOperation + " removed from cruiseCache: " + cruiseCache.size()); + log.info(fishingOperation + " removed from zoneCache: " + zoneCache.size()); + log.info(fishingOperation + " removed from " + this); } } @@ -847,4 +849,29 @@ public class CruiseSamplingCache implements CruiseCacheAble { } + private void cleanEmptyEntries() { + cruiseCache.cleanEmptyEntries(); + zoneCache.cleanEmptyEntries(); + fishingOperationCache.cleanEmptyEntries(); + } + + public void printInfos(String message) { + + if (log.isInfoEnabled()) { + + String cruiseCacheInfos = cruiseCache.toStringVerbose(); + String zoneCacheInfos = zoneCache.toStringVerbose(); + String fishingOperationCacheInfos = fishingOperationCache.toStringVerbose(); + + StringBuilder stringBuilder = new StringBuilder(message); + stringBuilder.append("\nCruise cache: ").append(cruiseCacheInfos); + stringBuilder.append("\nZone cache: ").append(zoneCacheInfos); + stringBuilder.append("\nFishing operation cache: ").append(fishingOperationCacheInfos); + + if (log.isInfoEnabled()) { + log.info(stringBuilder.toString()); + } + } + } + } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java index d327d78..f32e606 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/sampling/CruiseSamplingInternalCache.java @@ -199,6 +199,14 @@ class CruiseSamplingInternalCache implements Closeable { } } + private static final String TO_STRING_VERBOSE_FORMAT = "\n%1$-40s → %2$s"; + + public String toStringVerbose() { + StringBuilder stringBuilder = new StringBuilder(size() +" entries."); + data.entrySet().forEach(entry -> stringBuilder.append(String.format(TO_STRING_VERBOSE_FORMAT, entry.getKey(), entry.getValue()))); + return stringBuilder.toString(); + } + class SamplingData { /** -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 95043cf68e2a0144754fe868f488c70679b099ab Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:17:09 2016 +0200 A la sauvegarde d'une opération, on doit rafraîchir le contexte de données --- .../actions/SaveFishingOperationAction.java | 102 ++++++++++++--------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/actions/SaveFishingOperationAction.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/actions/SaveFishingOperationAction.java index e5c4d87..9e9d421 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/actions/SaveFishingOperationAction.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/fishing/actions/SaveFishingOperationAction.java @@ -29,7 +29,6 @@ import fr.ifremer.tutti.persistence.entities.data.CatchBatchs; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.ValidationService; -import fr.ifremer.tutti.ui.swing.util.actions.LongActionSupport; import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUI; import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.EditFishingOperationUIModel; @@ -37,6 +36,7 @@ import fr.ifremer.tutti.ui.swing.content.operation.FishingOperationsUIModel; import fr.ifremer.tutti.ui.swing.content.operation.fishing.AbstractCaracteristicTabUIModel; import fr.ifremer.tutti.ui.swing.content.operation.fishing.GearUseFeatureTabUIModel; import fr.ifremer.tutti.ui.swing.content.operation.fishing.VesselUseFeatureTabUIModel; +import fr.ifremer.tutti.ui.swing.util.actions.LongActionSupport; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -49,9 +49,7 @@ import org.apache.commons.logging.LogFactory; public class SaveFishingOperationAction extends LongActionSupport<EditFishingOperationUIModel, EditFishingOperationUI, EditFishingOperationUIHandler> { /** Logger. */ - private static final Log log = - LogFactory.getLog(SaveFishingOperationAction.class); - + private static final Log log = LogFactory.getLog(SaveFishingOperationAction.class); /** * A flag to update ui after create or save the edit fishing operation. @@ -80,15 +78,13 @@ public class SaveFishingOperationAction extends LongActionSupport<EditFishingOpe public void doAction() throws Exception { // previous fishingOperation was modified, let's save it - EditFishingOperationUIModel beanToSave = - handler.getFishingOperationMonitor().getBean(); + EditFishingOperationUIModel beanToSave = handler.getFishingOperationMonitor().getBean(); - // must save when bean is new or was modifiy and is valid - boolean mustSave = beanToSave.getFishingOperation() != null - && beanToSave.isValid(); + moveTab = true; + // must save when bean is new or was modifiy and is valid + boolean mustSave = beanToSave.getFishingOperation() != null && beanToSave.isValid(); - moveTab = true; if (mustSave) { // prepare model @@ -113,19 +109,14 @@ public class SaveFishingOperationAction extends LongActionSupport<EditFishingOpe subModel.setModify(false); } - sendMessage( - "[ Trait - Caractéristiques générales ] " + - "Sauvegarde des modifications de " + decorate(toSave) + - "." - ); + sendMessage("[ Trait - Caractéristiques générales ] Sauvegarde des modifications de " + decorate(toSave) + "."); if (log.isInfoEnabled()) { - log.info("FishingOperation " + toSave.getId() + - " was modified, will save it."); + log.info("FishingOperation " + toSave.getId() + " was modified, will save it."); } - saveFishingOperation(toSave); + } } @@ -143,48 +134,71 @@ public class SaveFishingOperationAction extends LongActionSupport<EditFishingOpe protected void saveFishingOperation(FishingOperation toSave) { - PersistenceService service = getContext().getPersistenceService(); - boolean create = TuttiEntities.isNew(toSave); - FishingOperationsUIModel model = - getHandler().getParentUi().getModel(); - FishingOperation savedFishingOperation; - if (create) { - // create fishing operation - savedFishingOperation = service.createFishingOperation(toSave); - - // create then the CatchBatch - CatchBatch catchBatch = CatchBatchs.newCatchBatch(); - catchBatch.setFishingOperation(savedFishingOperation); - service.createCatchBatch(catchBatch); - - // add new created fishing operation to list - model.addFishingOperation(savedFishingOperation); - - // select it (will reload editing fishing operation) - model.setSelectedFishingOperation(savedFishingOperation); + createFishingOperation(toSave); } else { + FishingOperationsUIModel model = getHandler().getParentUi().getModel(); model.setEditionAdjusting(true); try { - // save fishing operation - savedFishingOperation = service.saveFishingOperation(toSave); - - model.setSelectedFishingOperation(null); - // reinject it in model - model.updateFishingOperation(savedFishingOperation); + persistFishingOperation(toSave); - model.setSelectedFishingOperation(savedFishingOperation); } finally { + model.setEditionAdjusting(false); + } + } + + } + + private void createFishingOperation(FishingOperation toSave) { + + FishingOperationsUIModel model = getHandler().getParentUi().getModel(); + PersistenceService service = getContext().getPersistenceService(); + + // create fishing operation + FishingOperation savedFishingOperation = service.createFishingOperation(toSave); + + // create then the CatchBatch + CatchBatch catchBatch = CatchBatchs.newCatchBatch(); + catchBatch.setFishingOperation(savedFishingOperation); + service.createCatchBatch(catchBatch); + + // add new created fishing operation to list + model.addFishingOperation(savedFishingOperation); + + // select it (will reload editing fishing operation) + model.setSelectedFishingOperation(savedFishingOperation); + + } + + private void persistFishingOperation(FishingOperation toSave) { + + + PersistenceService service = getContext().getPersistenceService(); + + FishingOperationsUIModel model = getHandler().getParentUi().getModel(); + + // save fishing operation + FishingOperation savedFishingOperation = service.saveFishingOperation(toSave); + + model.setSelectedFishingOperation(null); + + // reinject it in model + model.updateFishingOperation(savedFishingOperation); + + model.setSelectedFishingOperation(savedFishingOperation); + + getDataContext().reloadFishingOperation(); + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 8a3df5de4e33f530cbe00c89e8ece21d91bf99a6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:30:36 2016 +0200 Envoyer un signal quand l'opération est rechargée --- .../src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java index b733e9d..10f0753 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/TuttiDataContext.java @@ -625,6 +625,7 @@ public class TuttiDataContext extends AbstractBean implements Closeable { log.info("Reloading fishingOperation: " + id); } resetFishingOperation(); + firePropertyChange(PROPERTY_FISHING_OPERATION_ID, -1, fishingOperationId); } public List<Caracteristic> getCaracteristics() { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit 1f4faadf6384c4bf721b8ca2ed566c1fd1eae01c Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Apr 24 22:31:07 2016 +0200 Bien recharger l'opération de pêche lorsqu'elle change dans le contexte de données --- .../frequency/IndividualObservationUICache.java | 30 ++++++++++++++++++---- .../frequency/SpeciesFrequencyUIHandler.java | 14 +++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationUICache.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationUICache.java index dac9edd..4f4964a 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationUICache.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/IndividualObservationUICache.java @@ -24,6 +24,7 @@ package fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency; * #L% */ +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.protocol.Zone; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.cruise.CruiseCache; @@ -33,6 +34,8 @@ import fr.ifremer.tutti.service.sampling.IndividualObservationSamplingCacheReque import fr.ifremer.tutti.service.sampling.IndividualObservationSamplingStatus; import fr.ifremer.tutti.service.sampling.SizeNotDefinedOnIndividualObservationException; import fr.ifremer.tutti.service.sampling.ZoneNotDefinedOnFishingOperationException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import java.io.Closeable; import java.util.Collection; @@ -51,6 +54,9 @@ import java.util.Optional; */ public class IndividualObservationUICache implements Closeable { + /** Logger. */ + private static final Log log = LogFactory.getLog(IndividualObservationUICache.class); + private final CruiseSamplingCache cruiseSamplingCache; private final boolean useCruiseSamplingCache; private final SpeciesFrequencyUIModel uiModel; @@ -76,6 +82,24 @@ public class IndividualObservationUICache implements Closeable { return fishingOperationZone != null; } + public void initFishingOperation(FishingOperation fishingOperation) { + + Objects.requireNonNull(fishingOperation); + if (useCruiseSamplingCache) { + + // calcule de la zone associée à l'opération de pêche + Optional<Zone> optionalZone = cruiseSamplingCache.tryFindZone(fishingOperation); + + if (log.isInfoEnabled()) { + log.info("Init fishing operation zone: " + optionalZone); + } + + fishingOperationZone = optionalZone.orElse(null); + + } + + } + public void init(Species species, List<IndividualObservationBatchRowModel> individualObservations, boolean addToCache) { Objects.requireNonNull(species); @@ -83,10 +107,6 @@ public class IndividualObservationUICache implements Closeable { if (useCruiseSamplingCache) { - // calcule de la zone associée à l'opération de pêche - Optional<Zone> optionalZone = cruiseSamplingCache.tryFindZone(uiModel.getFishingOperation()); - fishingOperationZone = optionalZone.orElse(null); - // est-ce que l'espèce du lot existe dans l'algortihme des pièces calcifiées speciesDefinedInCalcifiedPiecesSampling = cruiseSamplingCache.isSpeciesDefined(species); @@ -124,7 +144,7 @@ public class IndividualObservationUICache implements Closeable { IndividualObservationSamplingCacheRequest samplingCacheRequest = uiModel.toSamplingCacheRequest(row); addIndividualObservation(samplingCacheRequest); - + }); } diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java index b61e68c..f69115e 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java @@ -30,6 +30,7 @@ import fr.ifremer.tutti.ichtyometer.feed.event.IchtyometerFeedReaderListener; import fr.ifremer.tutti.ichtyometer.feed.record.IchtyometerFeedReaderMeasureRecord; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.CopyIndividualObservationMode; +import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.protocol.Rtp; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; @@ -386,6 +387,16 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci // listen when caliper is connected or not and adjust the listener getContext().addPropertyChangeListener(TuttiUIContext.PROPERTY_CALIPER_CONNECTED, listenCaliperIsConnected); + // pour recharger l'opération dans le modèle quand celle ci a changée (après une sauvegarde de l'opération par exemple) + getDataContext().addPropertyChangeListener(TuttiDataContext.PROPERTY_FISHING_OPERATION_ID, event -> { + TuttiDataContext source = (TuttiDataContext) event.getSource(); + FishingOperation fishingOperation = source.getFishingOperation(); + if (log.isInfoEnabled()) { + log.info("Reloading fishing operation in model: " + fishingOperation); + } + model.setFishingOperation(fishingOperation); + }); + } @Override @@ -676,10 +687,11 @@ public class SpeciesFrequencyUIHandler extends AbstractTuttiTableUIHandler<Speci model.setRtp(rtp); - // init maturity caracteristic individualObservationBatchTableHandler.initMaturityCaracteristic(speciesProtocol); individualObservationBatchTableHandler.initDefaultCaracteristics(speciesBatch); + model.getIndividualObservationUICache().initFishingOperation(model.getFishingOperation()); + loadFrequenciesAndObservations(frequency, individualObservations, false); samplingNotificationZoneHandler.editBatch(speciesBatch); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm