This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository tutti. See http://git.codelutin.com/tutti.git commit 593481ddec3d3e5dbc729ce18055eacb68429b9d Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Apr 4 08:33:59 2015 +0200 changer l'API de persistence pour pouvoir utiliser le rankOrder fournit ou bien continuer a le calculer --- .../tutti/persistence/TuttiPersistenceImpl.java | 8 +- .../persistence/TuttiPersistenceNoDbImpl.java | 4 +- .../service/BenthosBatchPersistenceService.java | 2 +- .../BenthosBatchPersistenceServiceImpl.java | 169 +----------------- .../MarineLitterBatchPersistenceServiceImpl.java | 15 +- .../service/SpeciesBatchPersistenceService.java | 2 +- .../SpeciesBatchPersistenceServiceImpl.java | 196 +-------------------- .../service/util/BatchPersistenceHelper.java | 71 +++++--- .../BenthosBatchPersistenceServiceWriteTest.java | 2 +- .../SpeciesBatchPersistenceServiceWriteTest.java | 2 +- .../ifremer/tutti/service/PersistenceService.java | 8 +- .../tutti/service/bigfin/BigfinImportService.java | 2 +- .../catches/multipost/MultiPostImportService.java | 4 +- .../GenericformatImportPersistenceHelper.java | 4 +- .../consumer/CsvConsumerForCatch.java | 2 + .../service/genericformat/csv/CatchModel.java | 4 +- .../importactions/ImportCatchAction.java | 6 +- .../service/psionimport/PsionImportService.java | 10 +- .../service/pupitri/PupitriImportService.java | 6 +- .../service/bigfin/BigfinImportService2Test.java | 2 +- .../catches/benthos/BenthosBatchUIHandler.java | 2 +- .../catches/species/SpeciesBatchUIHandler.java | 2 +- 22 files changed, 109 insertions(+), 414 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java index db56413..918ba4f 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java @@ -1078,8 +1078,8 @@ public class TuttiPersistenceImpl implements TuttiPersistence { } @Override - public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) { - return getSpeciesBatchService().createSpeciesBatch(bean, parentBatchId); + public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId, boolean computeRankOrder) { + return getSpeciesBatchService().createSpeciesBatch(bean, parentBatchId, computeRankOrder); } @Override @@ -1137,8 +1137,8 @@ public class TuttiPersistenceImpl implements TuttiPersistence { } @Override - public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId) { - return getBenthosBatchService().createBenthosBatch(bean, parentBatchId); + public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId, boolean computeRankOrder) { + return getBenthosBatchService().createBenthosBatch(bean, parentBatchId, computeRankOrder); } @Override diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java index bd05c77..22aec96 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java @@ -620,7 +620,7 @@ public class TuttiPersistenceNoDbImpl implements TuttiPersistence { } @Override - public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) { + public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId, boolean computeRankOrder) { throw notImplemented(); } @@ -679,7 +679,7 @@ public class TuttiPersistenceNoDbImpl implements TuttiPersistence { } @Override - public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId) { + public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId, boolean computeRankOrder) { throw notImplemented(); } diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java index 5ec5858..58634cd 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java @@ -61,7 +61,7 @@ public interface BenthosBatchPersistenceService extends TuttiPersistenceServiceI BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, boolean validateTree) throws InvalidBatchModelException; @Transactional(readOnly = false) - BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId); + BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId, boolean computeRankOrder); @Transactional(readOnly = false) Collection<BenthosBatch> createBenthosBatches(String fishingOperationId, Collection<BenthosBatch> beans); diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java index dee2116..c8db192 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java @@ -172,7 +172,7 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi } @Override - public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId) { + public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId, boolean computeRankOrder) { Preconditions.checkNotNull(bean); Preconditions.checkArgument(TuttiEntities.isNew(bean)); Preconditions.checkNotNull(bean.getSpecies()); @@ -181,10 +181,7 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi Preconditions.checkNotNull(bean.getFishingOperation().getId()); CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(bean.getFishingOperation().getId(), false); - BenthosBatch created = createBenthosBatch(bean, parentBatchId, catchBatch); -// SortingBatch batch = SortingBatch.Factory.newInstance(); -// beanToEntity(bean, batch, parentBatchId, catchBatch); -// bean = batchHelper.createSortingBatch(bean, catchBatch, batch); + BenthosBatch created = createBenthosBatch(bean, parentBatchId, catchBatch, computeRankOrder); return created; } @@ -200,7 +197,7 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi Collection<BenthosBatch> result = new ArrayList<>(); for (BenthosBatch bean : beans) { - BenthosBatch created = createBenthosBatch(bean, null, catchBatch); + BenthosBatch created = createBenthosBatch(bean, null, catchBatch, true); result.add(created); } @@ -208,7 +205,7 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi } - protected BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId, CatchBatch catchBatch) { + protected BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId, CatchBatch catchBatch, boolean computeRankOrder) { Preconditions.checkNotNull(bean); Preconditions.checkArgument(TuttiEntities.isNew(bean)); @@ -218,7 +215,7 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi Preconditions.checkNotNull(bean.getFishingOperation().getId()); SortingBatch batch = SortingBatch.Factory.newInstance(); - beanToEntity(bean, batch, parentBatchId, catchBatch); + beanToEntity(bean, batch, parentBatchId, catchBatch, computeRankOrder); bean = batchHelper.createSortingBatch(bean, catchBatch, batch); return bean; @@ -237,7 +234,7 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi if (bean.getParentBatch() != null) { parentBatchId = bean.getParentBatch().getId(); } - beanToEntity(bean, batch, parentBatchId, catchBatch); + beanToEntity(bean, batch, parentBatchId, catchBatch, true); batchHelper.updateSortingBatch(batch, catchBatch); return bean; @@ -415,91 +412,11 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi //-- Internal methods --// //------------------------------------------------------------------------// -// protected BenthosBatch entityToBean(SampleCategoryModel sampleCategoryModel, -// SortingBatch source, -// BenthosBatch target) { -// -// Preconditions.checkNotNull(target.getSpecies()); -// -// target.setId(source.getId().toString()); -// -// // Rank order -// target.setRankOrder(Integer.valueOf(source.getRankOrder())); -// -// // Individual count -// target.setNumber(source.getIndividualCount()); -// -// // Convert database weight (and sampling ratio) into UI weight and sampleCategoryWeight -// if (source.getWeight() != null && source.getWeightBeforeSampling() == null) { -// target.setSampleCategoryWeight(source.getWeight()); -// } else { -// target.setWeight(source.getWeight()); -// target.setSampleCategoryWeight(source.getWeightBeforeSampling()); -// } -// -// if (CollectionUtils.isNotEmpty(source.getChildBatchs()) && target.getWeight() != null) { -// -// // can't use this sample weight on a node -// // the weight comes from sampleRatioText, but must NOT be used here -// target.setWeight(null); -// -// } -// -// // Comments -// target.setComment(source.getComments()); -// -// // Sample category type (only one is applied) -// SortingMeasurement sm = null; -// if (source.getSortingMeasurements().size() == 1) { -// sm = source.getSortingMeasurements().iterator().next(); -// } else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) { -// sm = measurementPersistenceHelper.getInheritedSortingMeasurement(source); -// } -// if (sm != null) { -// boolean isSamplingCategory = sampleCategoryModel.containsCategoryId( -// sm.getPmfm().getId()); -// if (isSamplingCategory) { -// Integer qualitativeId = null; -// if (sm.getQualitativeValue() != null) { -// qualitativeId = sm.getQualitativeValue().getId(); -// } -// batchHelper.setSampleCategoryQualitative( -// target, -// sm.getPmfm().getId(), -// sm.getNumericalValue(), -// sm.getAlphanumericalValue(), -// qualitativeId); -// } -// } -// -// if (target.getSampleCategoryId() != null) { -// List<BenthosBatch> targetChilds = Lists.newArrayList(); -// for (Batch batch : source.getChildBatchs()) { -// SortingBatch sourceChild = (SortingBatch) batch; -// BenthosBatch targetChild = BenthosBatchs.newBenthosBatch(); -// targetChild.setSpecies(target.getSpecies()); -// entityToBean(sampleCategoryModel, sourceChild, targetChild); -// if (log.isDebugEnabled()) { -// log.debug("Loaded CatchBatch Hors Vrac > Benthos > " + targetChild.getSpecies().getReferenceTaxonId() + " : " + target.getId()); -// } -// if (targetChild.getSampleCategoryValue() != null) { -// targetChilds.add(targetChild); -// targetChild.setParentBatch(target); -// } -// } -// target.setChildBatchs(targetChilds); -// } -// -// QualityFlag qualityFlag = source.getQualityFlag(); -// target.setSpeciesToConfirm(qualityFlag != null && QualityFlagCode.DOUBTFUL.getValue().equals(qualityFlag.getCode())); -// -// return target; -// } - protected void beanToEntity(BenthosBatch source, SortingBatch target, String parentBatchId, - CatchBatch catchBatch) { + CatchBatch catchBatch, + boolean computeRankOrder) { Preconditions.checkNotNull(source.getFishingOperation()); Preconditions.checkNotNull(source.getFishingOperation().getId()); @@ -516,75 +433,7 @@ public class BenthosBatchPersistenceServiceImpl extends AbstractPersistenceServi catchBatch); } - batchHelper.beanToEntity(parentBatchId, source, target); + batchHelper.beanToEntity(parentBatchId, source, target, computeRankOrder); } -// protected void beanToEntity(BenthosBatchFrequency source, -// SortingBatch target, -// SortingBatch parentBatch, -// short rankOrder) { -// Preconditions.checkNotNull(source.getBatch()); -// Preconditions.checkNotNull(source.getBatch().getId()); -// -// Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements(); -// Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements(); -// -// // Create lists to store all updates, then remove not updated items -// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet(); -// if (quantificationMeasurements != null) { -// notChangedQuantificationMeasurements.addAll(quantificationMeasurements); -// } -// Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet(); -// if (sortingMeasurements != null) { -// notChangedSortingMeasurements.addAll(sortingMeasurements); -// } -// -// // If parent and root need to be set -// if (target.getId() == null -// || target.getRootBatch() == null -// || (target.getParentBatch() != null && !target.getParentBatch().getId().equals(parentBatch.getId()))) { -// -// target.setParentBatch(parentBatch); -// target.setRootBatch(parentBatch.getRootBatch()); -// } -// -// // RankOrder -// target.setRankOrder(rankOrder); -// -// // Weight or SampleCategoryWeight -// if (source.getWeight() != null) { -// QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( -// target, -// source.getWeight()); -// notChangedQuantificationMeasurements.remove(quantificationMeasurement); -// } -// -// // Sorting measurement -// if ((source.getLengthStepCaracteristic() != null && source.getLengthStep() != null)) { -// Integer pmfmId = source.getLengthStepCaracteristic().getIdAsInt(); -// SortingMeasurement sortingMeasurement = measurementPersistenceHelper.setSortingMeasurement(target, pmfmId, -// source.getLengthStep()); -// notChangedSortingMeasurements.remove(sortingMeasurement); -// } -// -// // Individual count -// target.setIndividualCount(source.getNumber()); -// -// // Species -// target.setReferenceTaxon(null); -// -// // QualityFlag -// target.setQualityFlag(parentBatch.getQualityFlag()); -// -// // Exhaustive inventory (always true under a species batch) -// target.setExhaustiveInventory(true); -// -// // Removed not changed measurements (in sorting and quantification measurement lists) -// if (quantificationMeasurements != null) { -// quantificationMeasurements.removeAll(notChangedQuantificationMeasurements); -// } -// if (sortingMeasurements != null) { -// sortingMeasurements.removeAll(notChangedSortingMeasurements); -// } -// } } diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java index f28acbd..de2728d 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java @@ -242,19 +242,10 @@ public class MarineLitterBatchPersistenceServiceImpl extends AbstractPersistence // RankOrder (initialize once, at creation) if (target.getRankOrder() == null) { - // Start rank order at 1, nothing before it - short rankOrder = (short) 1; - if (target.getParentBatch() != null && target.getParentBatch().getChildBatchs() != null) { - int maxRankOrder = 0; - for (Batch batch : target.getParentBatch().getChildBatchs()) { - Short r = batch.getRankOrder(); - if (r != null && r > maxRankOrder) { - maxRankOrder = r; - } - } - rankOrder += maxRankOrder; - } + + short rankOrder = batchHelper.computeRankOrder(target); target.setRankOrder(rankOrder); + } // Force subgroup count to '1', as Allegro diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java index cb648ec..74c1d11 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java @@ -63,7 +63,7 @@ public interface SpeciesBatchPersistenceService extends TuttiPersistenceServiceI boolean validateTree) throws InvalidBatchModelException; @Transactional(readOnly = false) - SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId); + SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId, boolean computeRankOrder); @Transactional(readOnly = false) Collection<SpeciesBatch> createSpeciesBatches(String fishingOperationId, Collection<SpeciesBatch> beans); diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java index b91d021..7479c39 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java @@ -181,7 +181,7 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi } @Override - public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) { + public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId, boolean computeRankOrder) { Preconditions.checkNotNull(bean); Preconditions.checkArgument(TuttiEntities.isNew(bean)); Preconditions.checkNotNull(bean.getSpecies()); @@ -191,11 +191,7 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(bean.getFishingOperation().getId(), false); - SpeciesBatch created = createSpeciesBatch(bean, parentBatchId, catchBatch); -// -// SortingBatch batch = SortingBatch.Factory.newInstance(); -// beanToEntity(bean, batch, parentBatchId, catchBatch); -// bean = batchHelper.createSortingBatch(bean, catchBatch, batch); + SpeciesBatch created = createSpeciesBatch(bean, parentBatchId, catchBatch, computeRankOrder); return created; } @@ -211,7 +207,7 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi Collection<SpeciesBatch> result = new ArrayList<>(); for (SpeciesBatch bean : beans) { - SpeciesBatch created = createSpeciesBatch(bean, null, catchBatch); + SpeciesBatch created = createSpeciesBatch(bean, null, catchBatch, true); result.add(created); } @@ -220,7 +216,7 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi } - protected SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId, CatchBatch catchBatch) { + protected SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId, CatchBatch catchBatch, boolean computeRankOrder) { Preconditions.checkNotNull(bean); Preconditions.checkArgument(TuttiEntities.isNew(bean)); @@ -230,7 +226,7 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi Preconditions.checkNotNull(bean.getFishingOperation().getId()); SortingBatch batch = SortingBatch.Factory.newInstance(); - beanToEntity(bean, batch, parentBatchId, catchBatch); + beanToEntity(bean, batch, parentBatchId, catchBatch, computeRankOrder); bean = batchHelper.createSortingBatch(bean, catchBatch, batch); return bean; @@ -249,7 +245,7 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi if (bean.getParentBatch() != null) { parentBatchId = bean.getParentBatch().getId(); } - beanToEntity(bean, batch, parentBatchId, catchBatch); + beanToEntity(bean, batch, parentBatchId, catchBatch, true); batchHelper.updateSortingBatch(batch, catchBatch); return bean; @@ -454,116 +450,11 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi //-- Internal methods --// //------------------------------------------------------------------------// -// protected SpeciesBatch entityToBean(SampleCategoryModel sampleCategoryModel, -// SortingBatch source, -// SpeciesBatch target) { -// -// Preconditions.checkNotNull(target.getSpecies()); -// -// target.setId(source.getId().toString()); -// -// // Rank order -// target.setRankOrder(Integer.valueOf(source.getRankOrder())); -// -// // Individual count -// target.setNumber(source.getIndividualCount()); -// -// // Convert database weight (and sampling ratio) into UI weight and sampleCategoryWeight -// if (source.getWeight() != null && source.getWeightBeforeSampling() == null) { -// target.setSampleCategoryWeight(source.getWeight()); -// } else { -// target.setWeight(source.getWeight()); -// target.setSampleCategoryWeight(source.getWeightBeforeSampling()); -// } -// -//// if (CollectionUtils.isNotEmpty(source.getChildBatchs()) && target.getWeight() != null) { -//// -//// // can't use this sample weight on a node -//// // the weight comes from sampleRatioText, but must NOT be used here -//// target.setWeight(null); -//// -//// } -// -// -// // Comments -// target.setComment(source.getComments()); -// -// // Sample category type (only one is applied) -// SortingMeasurement sm = null; -// if (source.getSortingMeasurements().size() == 1) { -// sm = source.getSortingMeasurements().iterator().next(); -// } else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) { -// sm = measurementPersistenceHelper.getInheritedSortingMeasurement(source); -// } -// if (sm != null) { -// -// boolean isFrequency = batchHelper.isFrequencyBatch(sampleCategoryModel, source); -// -// if (!isFrequency) { -// Integer qualitativeId = null; -// if (sm.getQualitativeValue() != null) { -// qualitativeId = sm.getQualitativeValue().getId(); -// } -// batchHelper.setSampleCategoryQualitative( -// target, -// sm.getPmfm().getId(), -// sm.getNumericalValue(), -// sm.getAlphanumericalValue(), -// qualitativeId); -// } -// } -// -// if (target.getSampleCategoryId() != null) { -// List<SpeciesBatch> targetChilds = Lists.newArrayList(); -// for (Batch batch : source.getChildBatchs()) { -// SortingBatch sourceChild = (SortingBatch) batch; -// SpeciesBatch targetChild = SpeciesBatchs.newSpeciesBatch(); -// targetChild.setSpecies(target.getSpecies()); -// entityToBean(sampleCategoryModel, sourceChild, targetChild); -// if (log.isDebugEnabled()) { -// log.debug("Loaded CatchBatch (Vrac|Hors Vrac) > Species > " + targetChild.getSpecies().getReferenceTaxonId() + " : " + target.getId()); -// } -// if (targetChild.getSampleCategoryValue() != null) { -// targetChilds.add(targetChild); -// targetChild.setParentBatch(target); -// } -// } -// target.setChildBatchs(targetChilds); -// } -// -// //FIXME tchemit-2014-08-29 We can only do this if not an a leaf node (means with no frequencies...) -// //FIXME tchemit-2014-08-29 But need to see if this is really need to do that . -// // see https://forge.codelutin.com/issues/5698 -// -// if (CollectionUtils.isNotEmpty(source.getChildBatchs()) && target.getWeight() != null) { -// -// SortingBatch childBatch = (SortingBatch) Iterables.get(source.getChildBatchs(), 0); -// -// boolean isFrequency = batchHelper.isFrequencyBatch(sampleCategoryModel, childBatch); -// -// if (!isFrequency) { -// -// // can't use this sample weight on a node -// // the weight comes from sampleRatioText, but must NOT be used here -// // but we can only do this if childs are not frequencies -// -// target.setWeight(null); -// -// } -// -// } -// -// -// QualityFlag qualityFlag = source.getQualityFlag(); -// target.setSpeciesToConfirm(qualityFlag != null && QualityFlagCode.DOUBTFUL.getValue().equals(qualityFlag.getCode())); -// -// return target; -// } - protected void beanToEntity(SpeciesBatch source, SortingBatch target, String parentBatchId, - fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch) { + CatchBatch catchBatch, + boolean computeRankOrder) { Preconditions.checkNotNull(source.getFishingOperation()); Preconditions.checkNotNull(source.getFishingOperation().getId()); @@ -582,77 +473,8 @@ public class SpeciesBatchPersistenceServiceImpl extends AbstractPersistenceServi ); } - batchHelper.beanToEntity(parentBatchId, source, target); + batchHelper.beanToEntity(parentBatchId, source, target, computeRankOrder); } -// protected void beanToEntity(SpeciesBatchFrequency source, -// SortingBatch target, -// SortingBatch parentBatch, -// short rankOrder) { -// Preconditions.checkNotNull(source.getBatch()); -// Preconditions.checkNotNull(source.getBatch().getId()); -// -// Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements(); -// Collection<SortingMeasurement> sortingMeasurements = target.getSortingMeasurements(); -// -// // Create lists to store all updates, then remove not updated items -// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet(); -// if (quantificationMeasurements != null) { -// notChangedQuantificationMeasurements.addAll(quantificationMeasurements); -// } -// Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet(); -// if (sortingMeasurements != null) { -// notChangedSortingMeasurements.addAll(sortingMeasurements); -// } -// -// // If parent and root need to be set -// if (target.getId() == null -// || target.getRootBatch() == null -// || (target.getParentBatch() != null && !target.getParentBatch().getId().equals(parentBatch.getId()))) { -// -// target.setParentBatch(parentBatch); -// target.setRootBatch(parentBatch.getRootBatch()); -// } -// -// // RankOrder -// target.setRankOrder(rankOrder); -// -// // Weight or SampleCategoryWeight -// if (source.getWeight() != null) { -// QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( -// target, -// source.getWeight()); -// notChangedQuantificationMeasurements.remove(quantificationMeasurement); -// } -// -// // Sorting measurement -// if ((source.getLengthStepCaracteristic() != null && source.getLengthStep() != null)) { -// Integer pmfmId = source.getLengthStepCaracteristic().getIdAsInt(); -// SortingMeasurement sortingMeasurement = measurementPersistenceHelper.setSortingMeasurement(target, pmfmId, -// source.getLengthStep()); -// notChangedSortingMeasurements.remove(sortingMeasurement); -// } -// -// // Individual count -// target.setIndividualCount(source.getNumber()); -// -// // Species -// target.setReferenceTaxon(null); -// -// // QualityFlag -// target.setQualityFlag(parentBatch.getQualityFlag()); -// -// // Exhaustive inventory (always true under a species batch) -// target.setExhaustiveInventory(true); -// -// // Removed not changed measurements (in sorting and quantification measurement lists) -// if (quantificationMeasurements != null) { -// quantificationMeasurements.removeAll(notChangedQuantificationMeasurements); -// } -// if (sortingMeasurements != null) { -// sortingMeasurements.removeAll(notChangedSortingMeasurements); -// } -// } - } diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/util/BatchPersistenceHelper.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/util/BatchPersistenceHelper.java index 6f69427..e8d5e11 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/util/BatchPersistenceHelper.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/util/BatchPersistenceHelper.java @@ -508,35 +508,46 @@ public class BatchPersistenceHelper extends AbstractPersistenceService { public void beanToEntity(String parentBatchId, SpeciesAbleBatch source, - SortingBatch target) { + SortingBatch target, + boolean computeRankOrder) { // --- RankOrder (initialize once, at creation) --- // { if (target.getRankOrder() == null) { - // Start rank order at 1 - short rankOrder = (short) 1; - if (source.getParentBatch() != null && CollectionUtils.isNotEmpty(source.getParentBatch().getChildBatchs())) { - int maxRankOrder = 0; - for (SpeciesAbleBatch batch : source.getParentBatch().getChildBatchs()) { - Integer r = batch.getRankOrder(); - if (r != null && r > maxRankOrder) { - maxRankOrder = r; - } - } - rankOrder += (short) maxRankOrder; - - } else if (target.getParentBatch() != null && CollectionUtils.isNotEmpty(target.getParentBatch().getChildBatchs())) { - short maxRankOrder = 0; - for (Batch batch : target.getParentBatch().getChildBatchs()) { - Short r = batch.getRankOrder(); - if (r != null && r > maxRankOrder) { - maxRankOrder = r; + + short rankOrder; + + if (computeRankOrder) { + + // Start rank order at 1 + rankOrder = (short) 1; + //FIXME : tchemit-2015-04-04 This code can not be used to save multiple batches at the same time, since it will always give the + //FIXME : tchemit-2015-04-04 same values for all batches + if (source.getParentBatch() != null && CollectionUtils.isNotEmpty(source.getParentBatch().getChildBatchs())) { + int maxRankOrder = 0; + for (SpeciesAbleBatch batch : source.getParentBatch().getChildBatchs()) { + Integer r = batch.getRankOrder(); + if (r != null && r > maxRankOrder) { + maxRankOrder = r; + } } + rankOrder += (short) maxRankOrder; + + } else { + + rankOrder = computeRankOrder(target); + } - rankOrder += maxRankOrder; + + } else { + + Preconditions.checkState(source.getRankOrder() != null, "Not using computeRankOrder requires source rankOrder to be not null, but was on batch: " + source); + rankOrder = (short) (int) source.getRankOrder(); + } target.setRankOrder(rankOrder); + } } @@ -606,7 +617,6 @@ public class BatchPersistenceHelper extends AbstractPersistenceService { } - public void beanToEntity(SpeciesAbleBatchFrequency source, SortingBatch target, SortingBatch parentBatch, @@ -661,6 +671,7 @@ public class BatchPersistenceHelper extends AbstractPersistenceService { } + public <B extends SpeciesAbleBatch> B entityToBean(SampleCategoryModel sampleCategoryModel, SortingBatch source, B target) { @@ -777,6 +788,24 @@ public class BatchPersistenceHelper extends AbstractPersistenceService { } + public short computeRankOrder(SortingBatch target) { + + // Start rank order at 1, nothing before it + short rankOrder = (short) 1; + if (target.getParentBatch() != null && target.getParentBatch().getChildBatchs() != null) { + int maxRankOrder = 0; + for (Batch batch : target.getParentBatch().getChildBatchs()) { + Short r = batch.getRankOrder(); + if (r != null && r > maxRankOrder) { + maxRankOrder = r; + } + } + rankOrder += maxRankOrder; + } + return rankOrder; + + } + public Integer convertSampleCategoryValueIntoQualitativeId(Serializable value) { if (value == null) { return null; diff --git a/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java b/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java index 4fa29e1..06aea07 100644 --- a/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java +++ b/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java @@ -421,7 +421,7 @@ public class BenthosBatchPersistenceServiceWriteTest { batch.setFishingOperation(fishingOperationWithEmptyBatch); // Create batch - BenthosBatch createdBatch = service.createBenthosBatch(batch, parentBatchId); + BenthosBatch createdBatch = service.createBenthosBatch(batch, parentBatchId, true); assertBenthosBatch(batch, createdBatch, false); // then reload (for round trip check) diff --git a/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java b/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java index 442c5f3..eb66f50 100644 --- a/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java +++ b/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java @@ -410,7 +410,7 @@ public class SpeciesBatchPersistenceServiceWriteTest { batch.setFishingOperation(fishingOperationWithEmptyBatch); // Create batch - SpeciesBatch createdBatch = service.createSpeciesBatch(batch, parentBatchId); + SpeciesBatch createdBatch = service.createSpeciesBatch(batch, parentBatchId, true); assertSpeciesBatch(batch, createdBatch, false); // then reload (for round trip check) 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 48d68f1..6d25201 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 @@ -1288,8 +1288,8 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer } @Override - public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId) { - return driver.createSpeciesBatch(bean, parentBatchId); + public SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId, boolean computeRankOrder) { + return driver.createSpeciesBatch(bean, parentBatchId, computeRankOrder); } @Override @@ -1348,8 +1348,8 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer } @Override - public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId) { - return driver.createBenthosBatch(bean, parentBatchId); + public BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId, boolean computeRankOrder) { + return driver.createBenthosBatch(bean, parentBatchId, computeRankOrder); } @Override diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java index 212a9ef..3b71d00 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/bigfin/BigfinImportService.java @@ -454,7 +454,7 @@ public class BigfinImportService extends AbstractTuttiService { batch.setSampleCategoryId(categoryId); batch.setSampleCategoryValue(signsToCaracteristicValue.get(signs)); - batch = persistenceService.createSpeciesBatch(batch, parentBatchId); + batch = persistenceService.createSpeciesBatch(batch, parentBatchId, true); return batch; } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostImportService.java index efb9ef3..6838d5d 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostImportService.java @@ -434,7 +434,7 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } if (existingBatch == null) { - batch = persistenceService.createSpeciesBatch(batch, parentPersistedId); + batch = persistenceService.createSpeciesBatch(batch, parentPersistedId, true); batches.put(row.getId(), batch); } } @@ -698,7 +698,7 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } if (existingBatch == null) { - batch = persistenceService.createBenthosBatch(batch, parentPersistedId); + batch = persistenceService.createBenthosBatch(batch, parentPersistedId, true); batches.put(row.getId(), batch); } } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericformatImportPersistenceHelper.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericformatImportPersistenceHelper.java index d8b38be..c64408c 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericformatImportPersistenceHelper.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericformatImportPersistenceHelper.java @@ -170,7 +170,7 @@ public class GenericformatImportPersistenceHelper { } public SpeciesBatch createSpeciesBatch(SpeciesBatch batch, String parentId) { - return persistenceService.createSpeciesBatch(batch, parentId); + return persistenceService.createSpeciesBatch(batch, parentId, false); } public void saveSpeciesBatchFrequency(String batchId, List<SpeciesBatchFrequency> frequencies) { @@ -187,7 +187,7 @@ public class GenericformatImportPersistenceHelper { } public BenthosBatch createBenthosBatch(BenthosBatch batch, String parentId) { - return persistenceService.createBenthosBatch(batch, parentId); + return persistenceService.createBenthosBatch(batch, parentId, false); } public void saveBenthosBatchFrequency(String batchId, List<BenthosBatchFrequency> frequencies) { diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/consumer/CsvConsumerForCatch.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/consumer/CsvConsumerForCatch.java index 257b877..bd95840 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/consumer/CsvConsumerForCatch.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/consumer/CsvConsumerForCatch.java @@ -253,6 +253,7 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { batch.setSampleCategoryId(sampleCategory.getCategoryId()); batch.setSampleCategoryValue(sampleCategory.getCategoryValue()); batch.setSampleCategoryWeight(sampleCategory.getCategoryWeight()); + batch.setRankOrder(sampleCategory.getRankOrder()); result = batch; operationContext.registerBatchObjectId(batch.getIdAsInt(), sampleCategory.getBatchId()); @@ -284,6 +285,7 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { // add a child result = SpeciesAbleBatchs.createNewChild(batch); result.setId(getNextBatchId()); + result.setRankOrder(sampleCategory.getRankOrder()); result.setSampleCategoryId(sampleCategory.getCategoryId()); result.setSampleCategoryValue(sampleCategory.getCategoryValue()); result.setSampleCategoryWeight(sampleCategory.getCategoryWeight()); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchModel.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchModel.java index 6e66b56..02bf75a 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchModel.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchModel.java @@ -98,7 +98,7 @@ public class CatchModel extends AbstractTuttiImportExportModel<CatchRow> { int categoryOrder = entry.getOrder(); String collectionName = CatchRow.SAMPLE_CATEGORY; newIndexNullableColumnForExport(headerPrefix, collectionName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_VALUE, TuttiCsvUtil.CARACTERISTIC_VALUE_FORMATTER); - newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", collectionName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.INTEGER); + newIndexNullableColumnForExport("Num_Ordre_" + headerPrefix + "_H2", collectionName, categoryOrder, ExportSampleCategory.PROPERTY_RANK_ORDER, TuttiCsvUtil.PRIMITIVE_INTEGER); newIndexNullableColumnForExport("Tot_" + headerPrefix, collectionName, categoryOrder, ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT, TuttiCsvUtil.FLOAT); newIndexNullableColumnForExport("Ech_" + headerPrefix, collectionName, categoryOrder, ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT, TuttiCsvUtil.FLOAT); newIndexNullableColumnForExport("Type_Volume_Poids_" + headerPrefix, collectionName, categoryOrder, ExportSampleCategory.PROPERTY_WEIGHT_OR_VOL_TYPE); @@ -158,7 +158,7 @@ public class CatchModel extends AbstractTuttiImportExportModel<CatchRow> { String headerPrefix = entry.getCode(); newIgnoredColumn(headerPrefix); - newMandatoryColumn("Num_Ordre_" + headerPrefix + "_H2", TuttiCsvUtil.INTEGER, new SampleCategoryValueSetter<Integer>(entry, ExportSampleCategory.PROPERTY_RANK_ORDER)); + newMandatoryColumn("Num_Ordre_" + headerPrefix + "_H2", TuttiCsvUtil.PRIMITIVE_INTEGER, new SampleCategoryValueSetter<Integer>(entry, ExportSampleCategory.PROPERTY_RANK_ORDER)); newMandatoryColumn("Tot_" + headerPrefix, TuttiCsvUtil.FLOAT, new SampleCategoryValueSetter<Float>(entry, ExportSampleCategory.PROPERTY_CATEGORY_WEIGHT)); newMandatoryColumn("Ech_" + headerPrefix, TuttiCsvUtil.FLOAT, new SampleCategoryValueSetter<Float>(entry, ExportSampleCategory.PROPERTY_SAMPLE_WEIGHT)); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/importactions/ImportCatchAction.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/importactions/ImportCatchAction.java index 61bb3e9..2c4578f 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/importactions/ImportCatchAction.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/importactions/ImportCatchAction.java @@ -85,7 +85,7 @@ public class ImportCatchAction extends ImportActionSupport { importContext.increments(t("tutti.service.genericFormat.skip.import.catches")); if (!(importContext.getImportRequest().isImportSpecies() || - importContext.getImportRequest().isImportBenthos())) { + importContext.getImportRequest().isImportBenthos())) { GenericFormatCsvFileResult importFileResult = importContext.getCatchFileResult(); importFileResult.setSkipped(true); } @@ -179,7 +179,9 @@ public class ImportCatchAction extends ImportActionSupport { // reset temporary id to persist batch batch.setId((Integer) null); SpeciesBatch createdBatch = persistenceHelper.createSpeciesBatch(batch, parentId); - + if (log.isInfoEnabled()) { + log.info("Create species batch: " + batch.getSpecies().getName() + "--" + batch.getSampleCategoryWeight() + " -- original rankOrder: " + batch.getRankOrder() + " -- saved rankOrder: " + createdBatch.getRankOrder()); + } Collection<AttachmentRow> attachmentRows = importContext.popAttachmentRows(ObjectTypeCode.BATCH, batchObjectId); persistenceHelper.persistAttachments(createdBatch.getIdAsInt(), attachmentRows); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java index de78272..3034f26 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java @@ -578,7 +578,7 @@ public class PsionImportService extends AbstractTuttiService { sortedCaracteristic); - batch = persistenceService.createSpeciesBatch(batch, null); + batch = persistenceService.createSpeciesBatch(batch, null, true); persistFrequencies(batch, batchModel); @@ -616,7 +616,7 @@ public class PsionImportService extends AbstractTuttiService { PmfmId.SORTED_UNSORTED.getValue(), sortedCaracteristic); - rootBatch = persistenceService.createSpeciesBatch(rootBatch, null); + rootBatch = persistenceService.createSpeciesBatch(rootBatch, null, true); createCategoryBatches(operation, specy, batchs, rootBatch, sortedBatchWeight != null); @@ -640,7 +640,7 @@ public class PsionImportService extends AbstractTuttiService { PmfmId.SORTED_UNSORTED.getValue(), unsortedCaracteristic); - batch = persistenceService.createSpeciesBatch(batch, null); + batch = persistenceService.createSpeciesBatch(batch, null, true); persistFrequencies(batch, batchModel); @@ -655,7 +655,7 @@ public class PsionImportService extends AbstractTuttiService { PmfmId.SORTED_UNSORTED.getValue(), unsortedCaracteristic); - rootBatch = persistenceService.createSpeciesBatch(rootBatch, null); + rootBatch = persistenceService.createSpeciesBatch(rootBatch, null, true); createCategoryBatches(operation, specy, batchs, rootBatch, false); @@ -734,7 +734,7 @@ public class PsionImportService extends AbstractTuttiService { if (TuttiEntities.isNew(childBatch)) { // persist it - childBatch = persistenceService.createSpeciesBatch(childBatch, parentBatch.getId()); + childBatch = persistenceService.createSpeciesBatch(childBatch, parentBatch.getId(), true); parentBatch.addChildBatchs(childBatch); } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportService.java index a5de739..1a73504 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportService.java @@ -463,7 +463,7 @@ public class PupitriImportService extends AbstractTuttiService { PmfmId.SORTED_UNSORTED.getValue(), cqv); - batch = persistenceService.createSpeciesBatch(batch, null); + batch = persistenceService.createSpeciesBatch(batch, null, true); String parentBatchId = batch.getId(); @@ -489,7 +489,7 @@ public class PupitriImportService extends AbstractTuttiService { } } - persistenceService.createSpeciesBatch(childBatch, parentBatchId); + persistenceService.createSpeciesBatch(childBatch, parentBatchId, true); } } else { @@ -515,7 +515,7 @@ public class PupitriImportService extends AbstractTuttiService { batch.setComment(melagComment); } - persistenceService.createSpeciesBatch(batch, null); + persistenceService.createSpeciesBatch(batch, null, true); } } diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportService2Test.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportService2Test.java index b764a0a..9c6d870 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportService2Test.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportService2Test.java @@ -184,7 +184,7 @@ public class BigfinImportService2Test { CaracteristicQualitativeValue qualitativeValue = CaracteristicQualitativeValues.getQualitativeValue(sortedUnsortedCaracteristic, QualitativeValueId.SORTED_VRAC.getValue()); speciesBatch.setSampleCategoryValue(qualitativeValue); - speciesBatch = persistenceService.createSpeciesBatch(speciesBatch, null); + speciesBatch = persistenceService.createSpeciesBatch(speciesBatch, null, true); { String fileContent = "Study name,ID,Date,LOC,STA,COMMENT,GPS X,GPS Y,SP CODE,SPEC,LENGTH (mm),WEIGHT (g),SEX,SIZE,MT,MS\n" + diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java index 17f65a8..96ba18a 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java @@ -1247,7 +1247,7 @@ public class BenthosBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Bent parentBatchId); } entityToSave = getPersistenceService().createBenthosBatch(entityToSave, - parentBatchId); + parentBatchId, true); row.setId(entityToSave.getId()); } else { if (log.isDebugEnabled()) { diff --git a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java index f7390ef..392fd99 100644 --- a/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java +++ b/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java @@ -1269,7 +1269,7 @@ public class SpeciesBatchUIHandler extends AbstractTuttiBatchTableUIHandler<Spec parentBatchId); } catchBean = getPersistenceService().createSpeciesBatch(catchBean, - parentBatchId); + parentBatchId, true); row.setId(catchBean.getId()); } else { if (log.isDebugEnabled()) { -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.