This is an automated email from the git hooks/post-receive script. New commit to branch feature/merge_species_benthos in repository tutti. See https://gitlab.nuiton.org/codelutin/tutti.git commit dfdf9c990ae231e918481edd357b0d8d43d06816 Author: Tony CHEMIT <chemit@codelutin.com> Date: Thu Mar 17 08:46:55 2016 +0100 suppression de BenthosBatch, BenthosBatchFrequency et des contrat SpeciesBatchAble et SpeciesFrequencyBatchAble dans le module service --- .../ifremer/tutti/service/PersistenceService.java | 48 ++++++------ .../ifremer/tutti/service/ValidationService.java | 9 +-- .../catches/ValidateCruiseOperationsService.java | 45 +++++------ .../service/catches/WeightCleaningService.java | 78 +++++++++----------- .../service/catches/WeightComputingService.java | 40 +++++----- .../catches/multipost/MultiPostExportContext.java | 10 +-- .../catches/multipost/MultiPostExportService.java | 28 ++++--- .../catches/multipost/MultiPostImportService.java | 86 ++++++++++------------ .../tutti/service/export/ExportBatchEntry.java | 8 +- .../tutti/service/export/ExportCatchContext.java | 48 ++++++------ .../export/pdf/CatchesPdfExportService.java | 4 +- .../ToConfirmReportFishingOperationData.java | 9 +-- .../toconfirmreport/ToConfirmReportService.java | 10 +-- .../GenericFormatCheckDataService.java | 3 +- .../genericformat/GenericFormatContextSupport.java | 1 - .../GenericFormatExportOperationContext.java | 11 +-- .../GenericFormatImportOperationContext.java | 38 +++++----- .../GenericformatImportPersistenceHelper.java | 10 +-- .../consumer/CsvConsumerForCatch.java | 28 +++---- .../tutti/service/genericformat/csv/CatchRow.java | 4 +- .../exportactions/CreateCatchBatchRowsAction.java | 5 +- .../importactions/ImportCatchAction.java | 26 +++---- .../producer/CsvProducerForCatch.java | 22 +++--- .../producer/CsvProducerForSpecies.java | 5 +- .../data/BenthosBatch-edit-error-validation.xml | 53 ------------- .../BenthosBatch-validate-fatal-validation.xml | 38 ---------- .../tutti/service/BeanValidatorDetectorTest.java | 5 +- .../tutti/service/PersistenceServiceTest.java | 22 +++--- .../service/bigfin/BigfinImportService2Test.java | 10 +-- .../service/bigfin/BigfinImportServiceTest.java | 7 +- .../catches/WeightComputingServiceTest.java | 17 ++--- .../psionimport/PsionImportServiceTest.java | 7 +- .../pupitri/PupitriImportServiceEvo6116Test.java | 17 ++--- .../pupitri/PupitriImportServiceEvo6149Test.java | 11 ++- .../pupitri/PupitriImportServiceEvo6592Test.java | 11 ++- 35 files changed, 307 insertions(+), 467 deletions(-) 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 568e881..2362184 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 @@ -38,8 +38,6 @@ import fr.ifremer.tutti.persistence.entities.TuttiEntity; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -47,8 +45,6 @@ import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; import fr.ifremer.tutti.persistence.entities.data.Program; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; @@ -160,20 +156,20 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer return sourceList; } - public interface FrequencyFunction<S extends SpeciesAbleBatch, F extends SpeciesAbleBatchFrequency> extends Function<S, List<F>> { + public interface FrequencyFunction extends Function<SpeciesBatch, List<SpeciesBatchFrequency>> { } - public FrequencyFunction<SpeciesBatch, SpeciesBatchFrequency> newSpeciesFrequenciesFunction() { + public FrequencyFunction newSpeciesFrequenciesFunction() { return input -> getAllSpeciesBatchFrequency(input.getIdAsInt()); } - public FrequencyFunction<BenthosBatch, BenthosBatchFrequency> newBenthosFrequenciesFunction() { + public FrequencyFunction newBenthosFrequenciesFunction() { return input -> getAllBenthosBatchFrequency(input.getIdAsInt()); } - public <F extends SpeciesAbleBatchFrequency> Float countFrequenciesWeight(List<F> frequencies, boolean stopIfNullFound) { + public Float countFrequenciesWeight(List<SpeciesBatchFrequency> frequencies, boolean stopIfNullFound) { Float result = null; - for (F frequency : frequencies) { + for (SpeciesBatchFrequency frequency : frequencies) { Float w = frequency.getWeight(); if (w == null) { @@ -190,9 +186,9 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer return result; } - public <F extends SpeciesAbleBatchFrequency> Integer countFrequenciesNumber(List<F> frequencies, boolean stopIfNullFound) { + public Integer countFrequenciesNumber(List<SpeciesBatchFrequency> frequencies, boolean stopIfNullFound) { Integer result = null; - for (F frequency : frequencies) { + for (SpeciesBatchFrequency frequency : frequencies) { Integer number = frequency.getNumber(); if (number == null) { @@ -235,7 +231,7 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer @Override public ProgramDataModel loadCruise(String programId, Integer cruiseId, Integer... fishingOperationIds) { - return driver.loadCruise(programId, cruiseId, fishingOperationIds); + return driver.loadCruise(programId, cruiseId, fishingOperationIds); } @Override @@ -621,7 +617,7 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer } TIME_LOG.log(t0, "Persistence driver *" + - driver.getImplementationName() + "* opened."); + driver.getImplementationName() + "* opened."); } @Override @@ -638,7 +634,7 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer IOUtils.closeQuietly(driver); TIME_LOG.log(t0, "Persistence driver *" + - driverName + "* closed."); + driverName + "* closed."); } //------------------------------------------------------------------------// @@ -893,17 +889,17 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer } @Override - public boolean isVracBatch(SpeciesAbleBatch speciesBatch) { + public boolean isVracBatch(SpeciesBatch speciesBatch) { return driver.isVracBatch(speciesBatch); } @Override - public boolean isHorsVracBatch(SpeciesAbleBatch speciesBatch) { + public boolean isHorsVracBatch(SpeciesBatch speciesBatch) { return driver.isHorsVracBatch(speciesBatch); } @Override - public Predicate<SpeciesAbleBatch> getVracBatchPredicate() { + public Predicate<SpeciesBatch> getVracBatchPredicate() { return driver.getVracBatchPredicate(); } @@ -1429,22 +1425,22 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer //------------------------------------------------------------------------// @Override - public BatchContainer<BenthosBatch> getRootBenthosBatch(Integer fishingOperationId, boolean validateTree) throws InvalidBatchModelException { + public BatchContainer<SpeciesBatch> getRootBenthosBatch(Integer fishingOperationId, boolean validateTree) throws InvalidBatchModelException { return driver.getRootBenthosBatch(fishingOperationId, validateTree); } @Override - public BenthosBatch createBenthosBatch(BenthosBatch bean, Integer parentBatchId, boolean computeRankOrder) { + public SpeciesBatch createBenthosBatch(SpeciesBatch bean, Integer parentBatchId, boolean computeRankOrder) { return driver.createBenthosBatch(bean, parentBatchId, computeRankOrder); } @Override - public Collection<BenthosBatch> createBenthosBatches(Integer fishingOperationId, Collection<BenthosBatch> beans) { + public Collection<SpeciesBatch> createBenthosBatches(Integer fishingOperationId, Collection<SpeciesBatch> beans) { return driver.createBenthosBatches(fishingOperationId, beans); } @Override - public BenthosBatch saveBenthosBatch(BenthosBatch bean) { + public SpeciesBatch saveBenthosBatch(SpeciesBatch bean) { return driver.saveBenthosBatch(bean); } @@ -1464,23 +1460,23 @@ public class PersistenceService extends AbstractTuttiService implements TuttiPer } @Override - public List<BenthosBatch> getAllBenthosBatchToConfirm(Integer fishingOperationId) throws InvalidBatchModelException { + public List<SpeciesBatch> getAllBenthosBatchToConfirm(Integer fishingOperationId) throws InvalidBatchModelException { return driver.getAllBenthosBatchToConfirm(fishingOperationId); } @Override - public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(Integer benthosBatchId) { + public List<SpeciesBatchFrequency> getAllBenthosBatchFrequency(Integer benthosBatchId) { return driver.getAllBenthosBatchFrequency(benthosBatchId); } @Override - public Multimap<Species, BenthosBatchFrequency> getAllBenthosBatchFrequencyForBatch(BatchContainer<BenthosBatch> batchContainer) { + public Multimap<Species, SpeciesBatchFrequency> getAllBenthosBatchFrequencyForBatch(BatchContainer<SpeciesBatch> batchContainer) { return driver.getAllBenthosBatchFrequencyForBatch(batchContainer); } @Override - public List<BenthosBatchFrequency> saveBenthosBatchFrequency(Integer benthosBatchId, - List<BenthosBatchFrequency> frequencies) { + public List<SpeciesBatchFrequency> saveBenthosBatchFrequency(Integer benthosBatchId, + List<SpeciesBatchFrequency> frequencies) { return driver.saveBenthosBatchFrequency(benthosBatchId, frequencies); } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/ValidationService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/ValidationService.java index 495e75f..4c40301 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/ValidationService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/ValidationService.java @@ -23,7 +23,6 @@ package fr.ifremer.tutti.service; */ import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -100,13 +99,13 @@ public class ValidationService implements TuttiService { return validator.validate(speciesBatch); } - public NuitonValidatorResult validateValidateBenthosBatch(BenthosBatch benthosBatch) { - NuitonValidator<BenthosBatch> validator = NuitonValidatorFactory.newValidator(BenthosBatch.class, VALIDATION_CONTEXT_VALIDATE); + public NuitonValidatorResult validateValidateBenthosBatch(SpeciesBatch benthosBatch) { + NuitonValidator<SpeciesBatch> validator = NuitonValidatorFactory.newValidator(SpeciesBatch.class, VALIDATION_CONTEXT_VALIDATE); return validator.validate(benthosBatch); } - public NuitonValidatorResult validateEditBenthosBatch(BenthosBatch benthosBatch) { - NuitonValidator<BenthosBatch> validator = NuitonValidatorFactory.newValidator(BenthosBatch.class, VALIDATION_CONTEXT_EDIT); + public NuitonValidatorResult validateEditBenthosBatch(SpeciesBatch benthosBatch) { + NuitonValidator<SpeciesBatch> validator = NuitonValidatorFactory.newValidator(SpeciesBatch.class, VALIDATION_CONTEXT_EDIT); return validator.validate(benthosBatch); } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java index 17a347c..5dc7cf4 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java @@ -28,8 +28,6 @@ import fr.ifremer.tutti.persistence.InvalidBatchModelException; import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -216,8 +214,7 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { * @param fishingOperation the operation to validate * @param validator the validatpr containing the messages. */ - protected void checkOperation(FishingOperation fishingOperation, - NuitonValidatorResult validator) { + protected void checkOperation(FishingOperation fishingOperation, NuitonValidatorResult validator) { Integer fishingOperationId = fishingOperation.getIdAsInt(); @@ -228,7 +225,7 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { if (!withCatchBatch) { if (log.isWarnEnabled()) { log.warn("Skip fishing operation " + fishingOperation + - " since no catchBatch associated."); + " since no catchBatch associated."); } Map<String, List<String>> errorMap = Maps.newHashMap(); errorMap.put("catches", Lists.newArrayList(t("tutti.validator.warning.fishingOperation.batch.notFound"))); @@ -314,15 +311,15 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, true); } - BatchContainer<BenthosBatch> rootBenthosBatch = null; + BatchContainer<SpeciesBatch> rootBenthosBatch = null; error = false; if (isCatchBatch) { rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, true); if (rootBenthosBatch != null) { - List<BenthosBatch> roots = rootBenthosBatch.getChildren(); + List<SpeciesBatch> roots = rootBenthosBatch.getChildren(); - for (BenthosBatch batch : roots) { + for (SpeciesBatch batch : roots) { NuitonValidatorResult benthosValidatorResult = validationService.validateValidateBenthosBatch(batch); transfertValidatorResult(benthosValidatorResult, errors); @@ -396,7 +393,7 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { if (isSpeciesBatchInvalid(batch)) { String species = speciesDecorator.toString(batch.getSpecies()); String categoryValue = decoratorService.getDecorator(batch.getSampleCategoryValue()) - .toString(batch.getSampleCategoryValue()); + .toString(batch.getSampleCategoryValue()); warnings.add(t("tutti.validator.warning.species.protocolNotRespected", species, categoryValue)); } } @@ -407,11 +404,11 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { if (rootBenthosBatch != null) { List<String> warnings = new ArrayList<>(); - for (BenthosBatch batch : rootBenthosBatch.getChildren()) { + for (SpeciesBatch batch : rootBenthosBatch.getChildren()) { if (isBenthosBatchInvalid(batch)) { String species = speciesDecorator.toString(batch.getSpecies()); String categoryValue = decoratorService.getDecorator(batch.getSampleCategoryValue()) - .toString(batch.getSampleCategoryValue()); + .toString(batch.getSampleCategoryValue()); warnings.add(t("tutti.validator.warning.benthos.protocolNotRespected", species, categoryValue)); } } @@ -433,8 +430,7 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { * @param frequencies the frequencies of the batch * @return true if the batch respects the protocol, false otherwise */ - public boolean isSpeciesBatchValid(SpeciesBatch batch, - List<SpeciesBatchFrequency> frequencies) { + public boolean isSpeciesBatchValid(SpeciesBatch batch, List<SpeciesBatchFrequency> frequencies) { boolean result = true; TuttiProtocol protocol = persistenceService.getProtocol(); @@ -453,9 +449,9 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { browsingBatch = browsingBatch.getParentBatch(); } result = mandatoryCategories.isEmpty() && - (speciesProtocol.getLengthStepPmfmId() != null - || CollectionUtils.isNotEmpty(frequencies) - || batch.getNumber() != null); + (speciesProtocol.getLengthStepPmfmId() != null + || CollectionUtils.isNotEmpty(frequencies) + || batch.getNumber() != null); } } return result; @@ -489,16 +485,16 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { * @param batch the batch to check * @return true if the batch or one of its children does not respect the protocol, false otherwise */ - protected boolean isBenthosBatchInvalid(BenthosBatch batch) { + protected boolean isBenthosBatchInvalid(SpeciesBatch batch) { if (batch.isChildBatchsEmpty()) { - List<BenthosBatchFrequency> frequencies = + List<SpeciesBatchFrequency> frequencies = persistenceService.getAllBenthosBatchFrequency(batch.getIdAsInt()); return !isBenthosBatchValid( batch, frequencies); } - for (BenthosBatch child : batch.getChildBatchs()) { + for (SpeciesBatch child : batch.getChildBatchs()) { boolean invalid = isBenthosBatchInvalid(child); if (invalid) { return true; @@ -532,8 +528,7 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { * @param frequencies the frequencies of the batch * @return true if the batch respects the protocol, false otherwise */ - public boolean isBenthosBatchValid(BenthosBatch batch, - List<BenthosBatchFrequency> frequencies) { + public boolean isBenthosBatchValid(SpeciesBatch batch, List<SpeciesBatchFrequency> frequencies) { TuttiProtocol protocol = persistenceService.getProtocol(); @@ -549,15 +544,15 @@ public class ValidateCruiseOperationsService extends AbstractTuttiService { List<Integer> mandatoryCategories = speciesProtocol.getMandatorySampleCategoryId(); - BenthosBatch browsingBatch = batch; + SpeciesBatch browsingBatch = batch; while (browsingBatch.getParentBatch() != null) { mandatoryCategories.remove(browsingBatch.getSampleCategoryId()); browsingBatch = browsingBatch.getParentBatch(); } result = mandatoryCategories.isEmpty() && - (speciesProtocol.getLengthStepPmfmId() != null - || CollectionUtils.isNotEmpty(frequencies) - || batch.getNumber() != null); + (speciesProtocol.getLengthStepPmfmId() != null + || CollectionUtils.isNotEmpty(frequencies) + || batch.getNumber() != null); } } return result; diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightCleaningService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightCleaningService.java index 4421a52..92f8ef4 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightCleaningService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightCleaningService.java @@ -29,13 +29,9 @@ import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -75,9 +71,9 @@ public class WeightCleaningService extends AbstractTuttiService { protected SampleCategoryModel sampleCategoryModel; - protected FrequencyFunction<SpeciesBatch, SpeciesBatchFrequency> speciesFrequencyFunction; + protected FrequencyFunction speciesFrequencyFunction; - protected FrequencyFunction<BenthosBatch, BenthosBatchFrequency> benthosFrequencyFunction; + protected FrequencyFunction benthosFrequencyFunction; protected WeightUnit benthosWeightUnit; @@ -135,7 +131,7 @@ public class WeightCleaningService extends AbstractTuttiService { if (!withCatchBatch) { if (log.isWarnEnabled()) { log.warn("Skip fishing operation " + fishingOperation + - " since no catchBatch associated."); + " since no catchBatch associated."); } continue; } @@ -229,11 +225,11 @@ public class WeightCleaningService extends AbstractTuttiService { // check benthos batches - BatchContainer<BenthosBatch> benthosBatch = + BatchContainer<SpeciesBatch> benthosBatch = persistenceService.getRootBenthosBatch( fishingOperationId, true); - for (BenthosBatch batch : benthosBatch.getChildren()) { + for (SpeciesBatch batch : benthosBatch.getChildren()) { checkBatch(benthosBatchPrefix, benthosWeightUnit, @@ -247,7 +243,7 @@ public class WeightCleaningService extends AbstractTuttiService { if (log.isWarnEnabled()) { log.warn("Skip fishing operation " + fishingOperationId + - " since no catchBatch associated."); + " since no catchBatch associated."); } } @@ -293,12 +289,12 @@ public class WeightCleaningService extends AbstractTuttiService { // clean benthos batches - Set<BenthosBatch> benthosToSave = Sets.newHashSet(); - BatchContainer<BenthosBatch> benthosBatch = + Set<SpeciesBatch> benthosToSave = Sets.newHashSet(); + BatchContainer<SpeciesBatch> benthosBatch = persistenceService.getRootBenthosBatch( fishingOperationId, true); - for (BenthosBatch batch : benthosBatch.getChildren()) { + for (SpeciesBatch batch : benthosBatch.getChildren()) { cleanBatch(benthosBatchPrefix, benthosWeightUnit, @@ -321,7 +317,7 @@ public class WeightCleaningService extends AbstractTuttiService { persistenceService.saveSpeciesBatch(toSave); } - for (BenthosBatch toSave : benthosToSave) { + for (SpeciesBatch toSave : benthosToSave) { toSave.setFishingOperation(fishingOperation); persistenceService.saveBenthosBatch(toSave); } @@ -333,7 +329,7 @@ public class WeightCleaningService extends AbstractTuttiService { if (log.isWarnEnabled()) { log.warn("Skip fishing operation " + fishingOperationId + - " since no catchBatch associated."); + " since no catchBatch associated."); } } @@ -341,18 +337,16 @@ public class WeightCleaningService extends AbstractTuttiService { } - protected <B extends SpeciesAbleBatch, F extends SpeciesAbleBatchFrequency> void checkBatch(String batchPrefix, - WeightUnit weightUnit, - B batch, - Multimap<String, String> result, - FrequencyFunction<B, F> frequencyFunction) { + protected void checkBatch(String batchPrefix, + WeightUnit weightUnit, + SpeciesBatch batch, + Multimap<String, String> result, + FrequencyFunction frequencyFunction) { if (!batch.isChildBatchsEmpty()) { // check childs - for (SpeciesAbleBatch child : batch.getChildBatchs()) { - - B childBatch = (B) child; + for (SpeciesBatch childBatch : batch.getChildBatchs()) { // check batch sample category weight (before childs) String message = checkSampleCategoryWeightRedundant(weightUnit, batch, childBatch); @@ -403,18 +397,16 @@ public class WeightCleaningService extends AbstractTuttiService { } } - protected <B extends SpeciesAbleBatch, F extends SpeciesAbleBatchFrequency> void cleanBatch(String batchPrefix, - WeightUnit weightUnit, - B batch, - Set<B> result, - FrequencyFunction<B, F> frequencyFunction) { + protected void cleanBatch(String batchPrefix, + WeightUnit weightUnit, + SpeciesBatch batch, + Set<SpeciesBatch> result, + FrequencyFunction frequencyFunction) { if (!batch.isChildBatchsEmpty()) { // check childs - for (SpeciesAbleBatch child : batch.getChildBatchs()) { - - B childBatch = (B) child; + for (SpeciesBatch childBatch : batch.getChildBatchs()) { // check batch sample category weight String message = checkSampleCategoryWeightRedundant(weightUnit, batch, childBatch); @@ -472,8 +464,8 @@ public class WeightCleaningService extends AbstractTuttiService { } protected String checkSampleCategoryWeightRedundant(WeightUnit weightUnit, - SpeciesAbleBatch parentBatch, - SpeciesAbleBatch batch) { + SpeciesBatch parentBatch, + SpeciesBatch batch) { Preconditions.checkNotNull(parentBatch); @@ -484,7 +476,7 @@ public class WeightCleaningService extends AbstractTuttiService { Float parentSampleCategoryWeight = parentBatch.getSampleCategoryWeight(); if (sampleCategoryWeight != null && parentSampleCategoryWeight != null && - Weights.isEqualWeight(parentSampleCategoryWeight, sampleCategoryWeight)) { + Weights.isEqualWeight(parentSampleCategoryWeight, sampleCategoryWeight)) { result = t("tutti.service.operations.cleanWeights.error.redundant.sampleCategoryWeight", weightUnit.fromEntity(sampleCategoryWeight), @@ -498,9 +490,9 @@ public class WeightCleaningService extends AbstractTuttiService { } - protected <B extends SpeciesAbleBatch, F extends SpeciesAbleBatchFrequency> String checkFrequencyWeightRedundant(WeightUnit weightUnit, - B batch, - FrequencyFunction<B, F> frequencyFunction) { + protected String checkFrequencyWeightRedundant(WeightUnit weightUnit, + SpeciesBatch batch, + FrequencyFunction frequencyFunction) { Preconditions.checkState(batch.isChildBatchsEmpty()); String result = null; @@ -510,7 +502,7 @@ public class WeightCleaningService extends AbstractTuttiService { if (weight != null) { // check if there is some frequencies - List<F> frequencies = frequencyFunction.apply(batch); + List<SpeciesBatchFrequency> frequencies = frequencyFunction.apply(batch); Float frequenciesWeigth = persistenceService.countFrequenciesWeight(frequencies, true); @@ -526,7 +518,7 @@ public class WeightCleaningService extends AbstractTuttiService { } protected String checkWeightRedundant(WeightUnit weightUnit, - SpeciesAbleBatch batch) { + SpeciesBatch batch) { Preconditions.checkState(batch.isChildBatchsEmpty()); @@ -547,17 +539,17 @@ public class WeightCleaningService extends AbstractTuttiService { } protected String getBatchLabel(String type, WeightUnit weightUnit, - SpeciesAbleBatch batch) { + SpeciesBatch batch) { StringBuilder sb = new StringBuilder("[ " + type); String species = decoratorService.getDecoratorByType(Species.class).toString(batch.getSpecies()); sb.append(" ").append(species); List<String> categories = Lists.newArrayList(); - SpeciesAbleBatch b = batch; + SpeciesBatch b = batch; while (b.getParentBatch() != null) { String categoryValue = decoratorService.getDecorator(b.getSampleCategoryValue()) - .toString(b.getSampleCategoryValue()); + .toString(b.getSampleCategoryValue()); categories.add(0, categoryValue + " / " + weightUnit.fromEntity(b.getSampleCategoryWeight())); b = b.getParentBatch(); } @@ -569,7 +561,7 @@ public class WeightCleaningService extends AbstractTuttiService { return sb.toString(); } - protected String getCategoryLabel(SpeciesAbleBatch batch) { + protected String getCategoryLabel(SpeciesBatch batch) { SampleCategoryModelEntry category = sampleCategoryModel.getCategoryById(batch.getSampleCategoryId()); return category.getLabel(); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java index a286255..cb84112 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java @@ -23,8 +23,6 @@ package fr.ifremer.tutti.service.catches; */ import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; @@ -76,7 +74,7 @@ public class WeightComputingService extends AbstractTuttiService { */ public void computeCatchBatchWeights(CatchBatch catchBatch, BatchContainer<SpeciesBatch> rootSpeciesBatch, - BatchContainer<BenthosBatch> rootBenthosBatch, + BatchContainer<SpeciesBatch> rootBenthosBatch, BatchContainer<MarineLitterBatch> rootMarineLitterBatch) { // Species @@ -139,8 +137,8 @@ public class WeightComputingService extends AbstractTuttiService { Float benthosTotalComputedUnsortedWeight = 0f; if (rootBenthosBatch != null) { - List<BenthosBatch> benthosBatches = rootBenthosBatch.getChildren(); - for (BenthosBatch row : benthosBatches) { + List<SpeciesBatch> benthosBatches = rootBenthosBatch.getChildren(); + for (SpeciesBatch row : benthosBatches) { Float weight = Numbers.getValueOrComputedValue( row.getSampleCategoryWeight(), row.getSampleCategoryComputedWeight()); @@ -470,18 +468,18 @@ public class WeightComputingService extends AbstractTuttiService { private int currentBenthosRowIndex; - public BatchContainer<BenthosBatch> getComputedBenthosBatches(Integer operationId) { + public BatchContainer<SpeciesBatch> getComputedBenthosBatches(Integer operationId) { - BatchContainer<BenthosBatch> rootBenthosBatch = null; + BatchContainer<SpeciesBatch> rootBenthosBatch = null; if (persistenceService.isFishingOperationWithCatchBatch(operationId)) { rootBenthosBatch = persistenceService.getRootBenthosBatch(operationId, false); currentBenthosRowIndex = 0; if (rootBenthosBatch != null) { - List<BenthosBatch> roots = rootBenthosBatch.getChildren(); + List<SpeciesBatch> roots = rootBenthosBatch.getChildren(); - for (BenthosBatch batch : roots) { + for (SpeciesBatch batch : roots) { computeBenthosBatch(batch); } } @@ -490,7 +488,7 @@ public class WeightComputingService extends AbstractTuttiService { return rootBenthosBatch; } - public Float computeBenthosBatch(BenthosBatch batch) { + public Float computeBenthosBatch(SpeciesBatch batch) { Float result = null; int thisIndex = currentBenthosRowIndex++; Float categoryWeight = batch.getSampleCategoryWeight(); @@ -501,7 +499,7 @@ public class WeightComputingService extends AbstractTuttiService { NuitonValidatorResult validation = validationService.validateEditBenthosBatch(batch); if (!validation.isValid()) { - List<String> messages = validation.getErrorMessages(BenthosBatch.PROPERTY_WEIGHT); + List<String> messages = validation.getErrorMessages(SpeciesBatch.PROPERTY_WEIGHT); String categoryLabel = getCategoryLabel(batch.getSampleCategoryId()); throw new TuttiWeightComputingException(t(messages.get(0), @@ -510,16 +508,16 @@ public class WeightComputingService extends AbstractTuttiService { categoryValue, batch.getWeight(), batch.getSampleCategoryWeight()), - BenthosBatch.PROPERTY_WEIGHT, + SpeciesBatch.PROPERTY_WEIGHT, thisIndex); } - List<BenthosBatch> children = batch.getChildBatchs(); + List<SpeciesBatch> children = batch.getChildBatchs(); // if the row is not a leaf if (!batch.isChildBatchsEmpty()) { Float sum = 0f; // make the sum of the children weights - for (BenthosBatch child : children) { + for (SpeciesBatch child : children) { Float weight = computeBenthosBatch(child); if (weight == null) { sum = null; @@ -543,7 +541,7 @@ public class WeightComputingService extends AbstractTuttiService { categoryValue, categoryWeight, sum), - BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, + SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, thisIndex); } else { @@ -557,12 +555,12 @@ public class WeightComputingService extends AbstractTuttiService { batch.setComputedWeight(null); - List<BenthosBatchFrequency> frequencies = persistenceService.getAllBenthosBatchFrequency(batch.getIdAsInt()); + List<SpeciesBatchFrequency> frequencies = persistenceService.getAllBenthosBatchFrequency(batch.getIdAsInt()); if (CollectionUtils.isNotEmpty(frequencies)) { // if there are frequencies, then compute their weight Float frequencyWeight = 0f; - for (BenthosBatchFrequency frequency : frequencies) { + for (SpeciesBatchFrequency frequency : frequencies) { Float w = frequency.getWeight(); if (w == null) { @@ -593,7 +591,7 @@ public class WeightComputingService extends AbstractTuttiService { categoryValue, rowWeight, categoryWeight), - BenthosBatch.PROPERTY_WEIGHT, + SpeciesBatch.PROPERTY_WEIGHT, thisIndex); } else if (categoryWeight == null && frequencyWeight != null) { @@ -619,7 +617,7 @@ public class WeightComputingService extends AbstractTuttiService { categoryValue, frequencyWeight, categoryWeight), - BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, + SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, thisIndex); } else if (rowWeight == null) { @@ -634,7 +632,7 @@ public class WeightComputingService extends AbstractTuttiService { // compute number from frequencies Integer frequencyNumber = 0; - for (BenthosBatchFrequency frequency : frequencies) { + for (SpeciesBatchFrequency frequency : frequencies) { Integer c = frequency.getNumber(); frequencyNumber += c; } @@ -653,7 +651,7 @@ public class WeightComputingService extends AbstractTuttiService { species, categoryLabel, categoryValue), - BenthosBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, + SpeciesBatch.PROPERTY_SAMPLE_CATEGORY_WEIGHT, thisIndex); } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportContext.java index a822f01..caadec3 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportContext.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportContext.java @@ -31,8 +31,8 @@ import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchFrequency; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.catches.multipost.csv.AccidentalCatchRow; @@ -192,7 +192,7 @@ public class MultiPostExportContext implements MultiPostConstants, Closeable { } } - public <B extends SpeciesAbleBatch> void addSpeciesOrBenthosBatch(String batchId, String parentId, B batch) { + public void addSpeciesOrBenthosBatch(String batchId, String parentId, SpeciesBatch batch) { CatchRow row = new CatchRow(); row.setId(batchId); @@ -213,9 +213,9 @@ public class MultiPostExportContext implements MultiPostConstants, Closeable { } - public <F extends SpeciesAbleBatchFrequency> void addFrequencies(String rowId, List<F> frequencies) { + public void addFrequencies(String rowId, List<SpeciesBatchFrequency> frequencies) { - for (F frequency : frequencies) { + for (SpeciesBatchFrequency frequency : frequencies) { CatchFrequencyRow frequencyRow = new CatchFrequencyRow(); frequencyRow.setBatchId(rowId); frequencyRow.setLengthStepCaracteristic(frequency.getLengthStepCaracteristic()); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportService.java index 23ba72d..aa67b61 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportService.java @@ -26,8 +26,6 @@ import com.google.common.collect.Lists; import fr.ifremer.adagio.core.dao.referential.ObjectTypeCode; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; @@ -201,7 +199,7 @@ public class MultiPostExportService extends AbstractTuttiService implements Mult // Export frequencies if (exportFrequencies) { - addFrequencies(exportContext, speciesBatch); + addSpeciesFrequencies(exportContext, speciesBatch); exportContext.storeFrequencies(); } @@ -251,9 +249,9 @@ public class MultiPostExportService extends AbstractTuttiService implements Mult // Export benthos catch, frequencies and individual observations - BatchContainer<BenthosBatch> benthosBatchContainer = persistenceService.getRootBenthosBatch(operationId, false); + BatchContainer<SpeciesBatch> benthosBatchContainer = persistenceService.getRootBenthosBatch(operationId, false); - for (BenthosBatch batch : benthosBatchContainer.getChildren()) { + for (SpeciesBatch batch : benthosBatchContainer.getChildren()) { addBenthos(exportContext, batch, null, exportFrequencies); } @@ -364,7 +362,7 @@ public class MultiPostExportService extends AbstractTuttiService implements Mult exportContext.addSpeciesOrBenthosBatch(id, parentId, batch); if (addFrequencies) { - List<SpeciesBatchFrequency> frequencies = getFrequencies(batch); + List<SpeciesBatchFrequency> frequencies = getSpeciesFrequencies(batch); exportContext.addFrequencies(id, frequencies); } @@ -374,20 +372,20 @@ public class MultiPostExportService extends AbstractTuttiService implements Mult } - protected void addFrequencies(MultiPostExportContext exportContext, SpeciesBatch batch) { + protected void addSpeciesFrequencies(MultiPostExportContext exportContext, SpeciesBatch batch) { String id = context.generateId(CatchRow.class); - List<SpeciesBatchFrequency> frequencies = getFrequencies(batch); + List<SpeciesBatchFrequency> frequencies = getSpeciesFrequencies(batch); exportContext.addFrequencies(id, frequencies); for (SpeciesBatch child : batch.getChildBatchs()) { - addFrequencies(exportContext, child); + addSpeciesFrequencies(exportContext, child); } } - protected List<SpeciesBatchFrequency> getFrequencies(SpeciesBatch batch) { + protected List<SpeciesBatchFrequency> getSpeciesFrequencies(SpeciesBatch batch) { List<SpeciesBatchFrequency> frequencies = persistenceService.getAllSpeciesBatchFrequency(batch.getIdAsInt()); frequencies.forEach(speciesBatchFrequency -> speciesBatchFrequency.setBatch(batch)); @@ -395,25 +393,25 @@ public class MultiPostExportService extends AbstractTuttiService implements Mult } - protected void addBenthos(MultiPostExportContext exportContext, BenthosBatch batch, String parentId, boolean addFrequencies) { + protected void addBenthos(MultiPostExportContext exportContext, SpeciesBatch batch, String parentId, boolean addFrequencies) { String id = context.generateId(CatchRow.class); exportContext.addSpeciesOrBenthosBatch(id, parentId, batch); if (addFrequencies) { - List<BenthosBatchFrequency> frequencies = getFrequencies(batch); + List<SpeciesBatchFrequency> frequencies = getBenthosFrequencies(batch); exportContext.addFrequencies(id, frequencies); } - for (BenthosBatch child : batch.getChildBatchs()) { + for (SpeciesBatch child : batch.getChildBatchs()) { addBenthos(exportContext, child, id, addFrequencies); } } - protected List<BenthosBatchFrequency> getFrequencies(BenthosBatch batch) { + protected List<SpeciesBatchFrequency> getBenthosFrequencies(SpeciesBatch batch) { - List<BenthosBatchFrequency> frequencies = persistenceService.getAllBenthosBatchFrequency(batch.getIdAsInt()); + List<SpeciesBatchFrequency> frequencies = persistenceService.getAllBenthosBatchFrequency(batch.getIdAsInt()); frequencies.forEach(speciesBatchFrequency -> speciesBatchFrequency.setBatch(batch)); return frequencies; 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 1b2fd1c..cee399d 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 @@ -34,11 +34,6 @@ import fr.ifremer.tutti.persistence.entities.data.AccidentalBatchs; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.Attachments; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequencys; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchs; -import fr.ifremer.tutti.persistence.entities.data.SampleEntity; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; @@ -47,8 +42,7 @@ import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatchs; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchFrequency; +import fr.ifremer.tutti.persistence.entities.data.SampleEntity; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencys; @@ -582,27 +576,27 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult importContext.checkSameOperation(WEIGHTS_FILE, weightsModel); Map<String, Object> notImportedData = new HashMap<>(); - Map<String, BenthosBatch> notImportedBatches = new LinkedHashMap<>(); + Map<String, SpeciesBatch> notImportedBatches = new LinkedHashMap<>(); - BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(operation.getIdAsInt(), false); + BatchContainer<SpeciesBatch> benthosBatches = persistenceService.getRootBenthosBatch(operation.getIdAsInt(), false); // Import batches // map containing the batches by their persistence id - Map<String, BenthosBatch> batches = importBenthosBatches(importContext, benthosBatches, notImportedBatches); + Map<String, SpeciesBatch> batches = importBenthosBatches(importContext, benthosBatches, notImportedBatches); // Import frequencies if (importFrequencies) { - ListMultimap<String, BenthosBatchFrequency> frequencyListMultimap = importFrequencies(importContext, + ListMultimap<String, SpeciesBatchFrequency> frequencyListMultimap = importFrequencies(importContext, batches, notImportedBatches, - BenthosBatchFrequencys::newBenthosBatchFrequency); + SpeciesBatchFrequencys::newBenthosBatchFrequency); for (String batchId : frequencyListMultimap.keySet()) { - List<BenthosBatchFrequency> frequencies = frequencyListMultimap.get(batchId); - BenthosBatch speciesBatch = batches.get(batchId); + List<SpeciesBatchFrequency> frequencies = frequencyListMultimap.get(batchId); + SpeciesBatch speciesBatch = batches.get(batchId); frequencies.forEach(speciesBatchFrequency -> speciesBatchFrequency.setBatch(speciesBatch)); persistenceService.saveBenthosBatchFrequency(speciesBatch.getIdAsInt(), frequencies); @@ -651,10 +645,10 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } - protected Map<String, BenthosBatch> importBenthosBatches(MultiPostImportContext importContext, - BatchContainer<BenthosBatch> benthosBatches, - Map<String, BenthosBatch> notImportedBatches) throws IOException { - Map<String, BenthosBatch> batches = new HashMap<>(); + protected Map<String, SpeciesBatch> importBenthosBatches(MultiPostImportContext importContext, + BatchContainer<SpeciesBatch> benthosBatches, + Map<String, SpeciesBatch> notImportedBatches) throws IOException { + Map<String, SpeciesBatch> batches = new HashMap<>(); try (Reader reader = importContext.newFileReader(BENTHOS_FILE)) { @@ -666,7 +660,7 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult for (CatchRow row : importer) { // create batch - BenthosBatch batch = BenthosBatchs.newBenthosBatch(); + SpeciesBatch batch = SpeciesBatchs.newBenthosBatch(); batch.setFishingOperation(operation); Species species = row.getSpecies(); @@ -687,14 +681,14 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult // get parent batch String parentId = row.getParentId(); Integer parentPersistedId = null; - BenthosBatch parent = null; + SpeciesBatch parent = null; if (StringUtils.isNotEmpty(parentId)) { parent = batches.get(parentId); parentPersistedId = parent.getIdAsInt(); } - BenthosBatch existingBatch = null; - List<BenthosBatch> batchesToBrowse; + SpeciesBatch existingBatch = null; + List<SpeciesBatch> batchesToBrowse; if (parent == null) { batchesToBrowse = benthosBatches.getChildren(); } else { @@ -704,7 +698,7 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult // check if the parent has already a batch with the caracteristic value // and if the children batch are categorized with the same caracterstic if (batchesToBrowse != null) { - for (BenthosBatch bb : batchesToBrowse) { + for (SpeciesBatch bb : batchesToBrowse) { if (bb.getSpecies().equals(species) && (!bb.getSampleCategoryId().equals(batch.getSampleCategoryId()) || bb.getSampleCategoryValue().equals(value))) { @@ -731,10 +725,10 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } // protected void importBenthosFrequencies(MultiPostImportContext importContext, -// Map<String, BenthosBatch> batches, -// Map<String, BenthosBatch> notImportedBatches) throws IOException { +// Map<String, SpeciesBatch> batches, +// Map<String, SpeciesBatch> notImportedBatches) throws IOException { // -// ListMultimap<Integer, BenthosBatchFrequency> frequencyMap = ArrayListMultimap.create(); +// ListMultimap<Integer, SpeciesBatchFrequency> frequencyMap = ArrayListMultimap.create(); // // try (Reader reader = importContext.newFileReader(FREQUENCIES_FILE)) { // @@ -744,9 +738,9 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult // // for (CatchFrequencyRow frequencyRow : importer) { // if (notImportedBatches.get(frequencyRow.getBatchId()) == null) { -// BenthosBatch batch = batches.get(frequencyRow.getBatchId()); +// SpeciesBatch batch = batches.get(frequencyRow.getBatchId()); // if (batch != null) { -// BenthosBatchFrequency frequency = BenthosBatchFrequencys.newBenthosBatchFrequency(); +// SpeciesBatchFrequency frequency = BenthosBatchFrequencys.newBenthosBatchFrequency(); // frequency.setLengthStepCaracteristic(frequencyRow.getLengthStepCaracteristic()); // frequency.setLengthStep(frequencyRow.getLengthStep()); // frequency.setNumber(frequencyRow.getNumber()); @@ -761,7 +755,7 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult // } // // for (Integer batchId : frequencyMap.keySet()) { -// List<BenthosBatchFrequency> frequencies = frequencyMap.get(batchId); +// List<SpeciesBatchFrequency> frequencies = frequencyMap.get(batchId); // persistenceService.saveBenthosBatchFrequency(batchId, frequencies); // } // @@ -1184,7 +1178,7 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } protected <B extends SampleEntity> void importCaracteristics(MultiPostImportContext importContext, - Map<String, B> batches) throws IOException { + Map<String, B> batches) throws IOException { try (Reader reader = importContext.newFileReader(CARACTERISTIC_FILE)) { @@ -1217,9 +1211,9 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } - protected <B extends SpeciesAbleBatch> Map<String, IndividualObservationBatch> importIndividualObservationBatches(MultiPostImportContext importContext, - Map<String, B> speciesOrBenthosBatches, - Map<String, B> notImportedBatches) throws IOException { + protected Map<String, IndividualObservationBatch> importIndividualObservationBatches(MultiPostImportContext importContext, + Map<String, SpeciesBatch> speciesOrBenthosBatches, + Map<String, SpeciesBatch> notImportedBatches) throws IOException { Map<String, IndividualObservationBatch> batches = new LinkedHashMap<>(); @@ -1241,7 +1235,7 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult // do not import these batch continue; } - B speciesOfBenthosBatch = speciesOrBenthosBatches.get(speciesBatchId); + SpeciesBatch speciesOfBenthosBatch = speciesOrBenthosBatches.get(speciesBatchId); if (speciesOfBenthosBatch == null) { // not found (FIXME Should ne an error) continue; @@ -1270,12 +1264,12 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } - protected <B extends SpeciesAbleBatch, F extends SpeciesAbleBatchFrequency> ListMultimap<String, F> importFrequencies(MultiPostImportContext importContext, - Map<String, B> batches, - Map<String, B> notImportedBatches, - Supplier<F> newFrequencySupplier) throws IOException { + protected ListMultimap<String, SpeciesBatchFrequency> importFrequencies(MultiPostImportContext importContext, + Map<String, SpeciesBatch> batches, + Map<String, SpeciesBatch> notImportedBatches, + Supplier<SpeciesBatchFrequency> newFrequencySupplier) throws IOException { - ListMultimap<String, F> frequencyMap = ArrayListMultimap.create(); + ListMultimap<String, SpeciesBatchFrequency> frequencyMap = ArrayListMultimap.create(); try (Reader reader = importContext.newFileReader(FREQUENCIES_FILE)) { @@ -1290,14 +1284,14 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult // not imported continue; } - B batch = batches.get(frequencyRowBatchId); + SpeciesBatch batch = batches.get(frequencyRowBatchId); if (batch == null) { // not imported (FIXME Should be an error ?) continue; } - F frequency = newFrequencySupplier.get(); + SpeciesBatchFrequency frequency = newFrequencySupplier.get(); frequency.setLengthStepCaracteristic(frequencyRow.getLengthStepCaracteristic()); frequency.setLengthStep(frequencyRow.getLengthStep()); frequency.setNumber(frequencyRow.getNumber()); @@ -1313,9 +1307,9 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } - protected <B extends SpeciesAbleBatch, F extends SpeciesAbleBatchFrequency> List<F> importFrequencies(MultiPostImportContext importContext, B speciesBatch, Supplier<F> newFrequencySupplier) throws IOException { + protected List<SpeciesBatchFrequency> importFrequencies(MultiPostImportContext importContext, SpeciesBatch speciesBatch, Supplier<SpeciesBatchFrequency> newFrequencySupplier) throws IOException { - List<F> frequenciesToSave = new LinkedList<>(); + List<SpeciesBatchFrequency> frequenciesToSave = new LinkedList<>(); try (Reader reader = importContext.newFileReader(FREQUENCIES_FILE)) { @@ -1338,7 +1332,7 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } - F frequency = newFrequencySupplier.get(); + SpeciesBatchFrequency frequency = newFrequencySupplier.get(); frequency.setLengthStepCaracteristic(frequencyRow.getLengthStepCaracteristic()); frequency.setLengthStep(frequencyRow.getLengthStep()); frequency.setNumber(frequencyRow.getNumber()); @@ -1355,8 +1349,8 @@ public class MultiPostImportService extends AbstractTuttiService implements Mult } - protected <B extends SpeciesAbleBatch> Map<String, IndividualObservationBatch> importIndividualObservationBatches(MultiPostImportContext importContext, - B speciesOfBenthosBatch) throws IOException { + protected Map<String, IndividualObservationBatch> importIndividualObservationBatches(MultiPostImportContext importContext, + SpeciesBatch speciesOfBenthosBatch) throws IOException { Map<String, IndividualObservationBatch> batches = new LinkedHashMap<>(); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java index dec51ea..b6c9083 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportBatchEntry.java @@ -22,7 +22,7 @@ package fr.ifremer.tutti.service.export; * #L% */ -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import org.apache.commons.lang3.mutable.MutableInt; import java.util.Map; @@ -36,7 +36,7 @@ import java.util.TreeMap; */ public class ExportBatchEntry { - protected final SpeciesAbleBatch batch; + protected final SpeciesBatch batch; protected float sortedWeight; @@ -51,12 +51,12 @@ public class ExportBatchEntry { */ protected Map<Float, MutableInt> frequencies; - public ExportBatchEntry(SpeciesAbleBatch batch) { + public ExportBatchEntry(SpeciesBatch batch) { this.batch = batch; this.frequencies = new TreeMap<>(); } - public SpeciesAbleBatch getBatch() { + public SpeciesBatch getBatch() { return batch; } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java index d85ced5..dcfe7ce 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/ExportCatchContext.java @@ -27,13 +27,9 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -62,15 +58,15 @@ public class ExportCatchContext { final BatchContainer<SpeciesBatch> rootSpeciesBatch; - final BatchContainer<BenthosBatch> rootBenthosBatch; + final BatchContainer<SpeciesBatch> rootBenthosBatch; final BatchContainer<MarineLitterBatch> marineLitterBatches; final Multimap<Species, SpeciesBatchFrequency> speciesFrequencies; - final Multimap<Species, BenthosBatchFrequency> benthosFrequencies; + final Multimap<Species, SpeciesBatchFrequency> benthosFrequencies; - final Predicate<SpeciesAbleBatch> vracPredicate; + final Predicate<SpeciesBatch> vracPredicate; public static ExportCatchContext newExportContext(PersistenceService persistenceService, WeightComputingService weightComputingService, @@ -86,7 +82,7 @@ public class ExportCatchContext { BatchContainer<SpeciesBatch> rootSpeciesBatch = weightComputingService.getComputedSpeciesBatches(fishingOperationId); - BatchContainer<BenthosBatch> rootBenthosBatch = + BatchContainer<SpeciesBatch> rootBenthosBatch = weightComputingService.getComputedBenthosBatches(fishingOperationId); BatchContainer<MarineLitterBatch> marineLitterBatches = @@ -99,7 +95,7 @@ public class ExportCatchContext { marineLitterBatches); Multimap<Species, SpeciesBatchFrequency> speciesFrequencies; - Multimap<Species, BenthosBatchFrequency> benthosFrequencies; + Multimap<Species, SpeciesBatchFrequency> benthosFrequencies; if (loadFrequencies) { @@ -110,7 +106,7 @@ public class ExportCatchContext { benthosFrequencies = null; } - Predicate<SpeciesAbleBatch> vracPredicate = persistenceService.getVracBatchPredicate(); + Predicate<SpeciesBatch> vracPredicate = persistenceService.getVracBatchPredicate(); return new ExportCatchContext(vracPredicate, fishingOperation, @@ -123,13 +119,13 @@ public class ExportCatchContext { } - private ExportCatchContext(Predicate<SpeciesAbleBatch> vracPredicate, + private ExportCatchContext(Predicate<SpeciesBatch> vracPredicate, FishingOperation fishingOperation, CatchBatch catchBatch, BatchContainer<SpeciesBatch> rootSpeciesBatch, Multimap<Species, SpeciesBatchFrequency> speciesFrequencies, - BatchContainer<BenthosBatch> rootBenthosBatch, - Multimap<Species, BenthosBatchFrequency> benthosFrequencies, + BatchContainer<SpeciesBatch> rootBenthosBatch, + Multimap<Species, SpeciesBatchFrequency> benthosFrequencies, BatchContainer<MarineLitterBatch> marineLitterBatches) { this.vracPredicate = vracPredicate; this.fishingOperation = fishingOperation; @@ -153,9 +149,9 @@ public class ExportCatchContext { public float getCatchTotalSortedWeight() { return catchBatch.getSpeciesTotalSampleSortedComputedWeight() + - catchBatch.getBenthosTotalSampleSortedComputedWeight() + - catchBatch.getSpeciesTotalUnsortedComputedWeight() + - catchBatch.getBenthosTotalUnsortedComputedWeight(); + catchBatch.getBenthosTotalSampleSortedComputedWeight() + + catchBatch.getSpeciesTotalUnsortedComputedWeight() + + catchBatch.getBenthosTotalUnsortedComputedWeight(); } public float getSpeciesTotalSortedWeight() { @@ -169,7 +165,7 @@ public class ExportCatchContext { catchBatch.getBenthosTotalSortedWeight(), catchBatch.getBenthosTotalSortedComputedWeight()); } - + public boolean withSpeciesBatches() { return rootSpeciesBatch != null && !rootSpeciesBatch.isEmptyChildren(); } @@ -228,8 +224,8 @@ public class ExportCatchContext { // ratio total species weight / total sorted sampled species weight float rate = getBenthosElevationRate(); - List<BenthosBatch> batches = rootBenthosBatch.getChildren(); - for (BenthosBatch batch : batches) { + List<SpeciesBatch> batches = rootBenthosBatch.getChildren(); + for (SpeciesBatch batch : batches) { ExportBatchEntry aCatch = createExportBatchCatch( batch, @@ -293,7 +289,7 @@ public class ExportCatchContext { return result; } - public boolean isVracBatch(SpeciesAbleBatch batch) { + public boolean isVracBatch(SpeciesBatch batch) { return vracPredicate.apply(batch); } @@ -325,7 +321,7 @@ public class ExportCatchContext { return result; } - protected ExportBatchEntry createExportBatchCatch(SpeciesAbleBatch batch, + protected ExportBatchEntry createExportBatchCatch(SpeciesBatch batch, Map<Species, ExportBatchEntry> catches, float ratio, boolean computeNumber) { @@ -361,7 +357,7 @@ public class ExportCatchContext { return ktch; } - protected float computeNumber(SpeciesAbleBatch batch, float rf) { + protected float computeNumber(SpeciesBatch batch, float rf) { float result; float weight = Numbers.getValueOrComputedValue( @@ -397,7 +393,7 @@ public class ExportCatchContext { // get total weight of all childs float totalWeight = 0.f; - for (SpeciesAbleBatch child : batch.getChildBatchs()) { + for (SpeciesBatch child : batch.getChildBatchs()) { totalWeight += Numbers.getValueOrComputedValue( child.getSampleCategoryWeight(), child.getSampleCategoryComputedWeight()); @@ -407,7 +403,7 @@ public class ExportCatchContext { float rf2 = rf * weight / totalWeight; // sum result of each child - for (SpeciesAbleBatch child : batch.getChildBatchs()) { + for (SpeciesBatch child : batch.getChildBatchs()) { result += computeNumber(child, rf2); } @@ -416,8 +412,8 @@ public class ExportCatchContext { return result; } - protected <F extends SpeciesAbleBatchFrequency> void addFrequencies(ExportBatchEntry aCatch, - Multimap<Species, F> frequencies) { + protected <F extends SpeciesBatchFrequency> void addFrequencies(ExportBatchEntry aCatch, + Multimap<Species, F> frequencies) { Species species = aCatch.getBatch().getSpecies(); Collection<F> batchFrequencies = frequencies.get(species); if (CollectionUtils.isNotEmpty(batchFrequencies)) { diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java index d542760..1b7f8fc 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/pdf/CatchesPdfExportService.java @@ -25,7 +25,7 @@ package fr.ifremer.tutti.service.export.pdf; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.persistence.entities.referential.Speciess; import fr.ifremer.tutti.persistence.entities.referential.TaxonCache; @@ -205,7 +205,7 @@ public class CatchesPdfExportService extends AbstractTuttiService { for (ExportBatchEntry entry : speciesBatchEntries) { - SpeciesAbleBatch batch = entry.getBatch(); + SpeciesBatch batch = entry.getBatch(); Species species = batch.getSpecies(); taxonCache.load(species); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/toconfirmreport/ToConfirmReportFishingOperationData.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/toconfirmreport/ToConfirmReportFishingOperationData.java index 5e8c1a2..1a93fa5 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/toconfirmreport/ToConfirmReportFishingOperationData.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/toconfirmreport/ToConfirmReportFishingOperationData.java @@ -24,7 +24,6 @@ package fr.ifremer.tutti.service.export.toconfirmreport; * #L% */ -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; @@ -70,7 +69,7 @@ public class ToConfirmReportFishingOperationData { List<SpeciesBatch> speciesBatchToConfirm = persistenceService.getAllSpeciesBatchToConfirm(fishingOperationId); - List<BenthosBatch> benthosBatchToConfirm = persistenceService.getAllBenthosBatchToConfirm(fishingOperationId); + List<SpeciesBatch> benthosBatchToConfirm = persistenceService.getAllBenthosBatchToConfirm(fishingOperationId); if (CollectionUtils.isEmpty(speciesBatchToConfirm) && CollectionUtils.isEmpty(benthosBatchToConfirm)) { @@ -102,7 +101,7 @@ public class ToConfirmReportFishingOperationData { final List<SpeciesBatch> speciesBatchToConfirm; - final List<BenthosBatch> benthosBatchToConfirm; + final List<SpeciesBatch> benthosBatchToConfirm; public FishingOperation getFishingOperation() { return fishingOperation; @@ -120,7 +119,7 @@ public class ToConfirmReportFishingOperationData { return CollectionUtils.isNotEmpty(speciesBatchToConfirm); } - public List<BenthosBatch> getBenthosBatchToConfirm() { + public List<SpeciesBatch> getBenthosBatchToConfirm() { return benthosBatchToConfirm; } @@ -131,7 +130,7 @@ public class ToConfirmReportFishingOperationData { private ToConfirmReportFishingOperationData(FishingOperation fishingOperation, CatchBatch catchBatch, List<SpeciesBatch> speciesBatchToConfirm, - List<BenthosBatch> benthosBatchToConfirm) { + List<SpeciesBatch> benthosBatchToConfirm) { this.fishingOperation = fishingOperation; this.catchBatch = catchBatch; this.speciesBatchToConfirm = speciesBatchToConfirm; diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/toconfirmreport/ToConfirmReportService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/toconfirmreport/ToConfirmReportService.java index 303db0c..401519e 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/export/toconfirmreport/ToConfirmReportService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/export/toconfirmreport/ToConfirmReportService.java @@ -25,9 +25,7 @@ package fr.ifremer.tutti.service.export.toconfirmreport; */ import fr.ifremer.tutti.persistence.ProgressionModel; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -160,7 +158,7 @@ public class ToConfirmReportService extends AbstractTuttiService { if (fishingOperationData.isWithBenthosBatchToConfirm()) { - List<BenthosBatch> benthosBatchEntries = fishingOperationData.getBenthosBatchToConfirm(); + List<SpeciesBatch> benthosBatchEntries = fishingOperationData.getBenthosBatchToConfirm(); benthosCache.loadInBatches(benthosBatchEntries); benthosCatchList = createBatchBeans(benthosWeightUnit, benthosBatchEntries); @@ -175,11 +173,11 @@ public class ToConfirmReportService extends AbstractTuttiService { } - protected <A extends SpeciesAbleBatch> List<ToConfirmReportBatchEntryBean> createBatchBeans(WeightUnit weightUnit, List<A> batchEntries) { + protected List<ToConfirmReportBatchEntryBean> createBatchBeans(WeightUnit weightUnit, List<SpeciesBatch> batchEntries) { List<ToConfirmReportBatchEntryBean> catchList = new ArrayList<>(); - for (SpeciesAbleBatch batch : batchEntries) { + for (SpeciesBatch batch : batchEntries) { Species species = batch.getSpecies(); @@ -209,7 +207,7 @@ public class ToConfirmReportService extends AbstractTuttiService { return catchList; } - protected String getBatchDecoratedSampleCategoryValue(SpeciesAbleBatch batch) { + protected String getBatchDecoratedSampleCategoryValue(SpeciesBatch batch) { Serializable sampleCategoryValue = batch.getSampleCategoryValue(); return decoratorService.getDecorator(sampleCategoryValue).toString(sampleCategoryValue); } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatCheckDataService.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatCheckDataService.java index e0f9152..bab7eb0 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatCheckDataService.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatCheckDataService.java @@ -27,7 +27,6 @@ package fr.ifremer.tutti.service.genericformat; import com.google.common.base.Preconditions; import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -173,7 +172,7 @@ public class GenericFormatCheckDataService extends AbstractTuttiService { rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, false); } - BatchContainer<BenthosBatch> rootBenthosBatch; + BatchContainer<SpeciesBatch> rootBenthosBatch; try { rootBenthosBatch = weightComputingService.getComputedBenthosBatches(fishingOperationId); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatContextSupport.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatContextSupport.java index f6f8f98..8c0a9ff 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatContextSupport.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatContextSupport.java @@ -76,7 +76,6 @@ import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; -import java.util.List; import java.util.Map; import java.util.Set; diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportOperationContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportOperationContext.java index e08a469..e694318 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportOperationContext.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatExportOperationContext.java @@ -26,15 +26,12 @@ package fr.ifremer.tutti.service.genericformat; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; @@ -75,7 +72,7 @@ public class GenericFormatExportOperationContext { private BatchContainer<SpeciesBatch> rootSpeciesBatch; - private BatchContainer<BenthosBatch> rootBenthosBatch; + private BatchContainer<SpeciesBatch> rootBenthosBatch; private List<IndividualObservationBatch> individualObservations; @@ -223,7 +220,7 @@ public class GenericFormatExportOperationContext { return rootSpeciesBatch; } - public BatchContainer<BenthosBatch> getRootBenthosBatch() { + public BatchContainer<SpeciesBatch> getRootBenthosBatch() { return rootBenthosBatch; } @@ -255,11 +252,11 @@ public class GenericFormatExportOperationContext { return accidentalBatches; } - public boolean isVracBatch(SpeciesAbleBatch batch) { + public boolean isVracBatch(SpeciesBatch batch) { return persistenceService.isVracBatch(batch); } - public List<BenthosBatchFrequency> getAllBenthosBatchFrequency(Integer id) { + public List<SpeciesBatchFrequency> getAllBenthosBatchFrequency(Integer id) { return persistenceService.getAllBenthosBatchFrequency(id); } diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatImportOperationContext.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatImportOperationContext.java index 7a51135..bf65e20 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatImportOperationContext.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/GenericFormatImportOperationContext.java @@ -29,15 +29,13 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableList; import fr.ifremer.tutti.persistence.entities.CaracteristicMap; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.persistence.model.OperationDataModel; @@ -85,13 +83,13 @@ public class GenericFormatImportOperationContext implements Closeable { private final ArrayListMultimap<Integer, SpeciesBatchFrequency> speciesFrequencies; - private final Map<Integer, BenthosBatch> vracBenthosBatches; + private final Map<Integer, SpeciesBatch> vracBenthosBatches; - private final Map<Integer, BenthosBatch> horsVracBenthosBatches; + private final Map<Integer, SpeciesBatch> horsVracBenthosBatches; private final Map<Integer, Integer> batchesObjectIds; - private final ArrayListMultimap<Integer, BenthosBatchFrequency> benthosFrequencies; + private final ArrayListMultimap<Integer, SpeciesBatchFrequency> benthosFrequencies; private final CaracteristicMap gearUseFeatures; @@ -186,7 +184,7 @@ public class GenericFormatImportOperationContext implements Closeable { return getSpeciesBatchMap(vrac).get(referenceTaxonId); } - public BenthosBatch getBenthosBatch(boolean vrac, Integer referenceTaxonId) { + public SpeciesBatch getBenthosBatch(boolean vrac, Integer referenceTaxonId) { return getBenthosBatchMap(vrac).get(referenceTaxonId); } @@ -214,7 +212,7 @@ public class GenericFormatImportOperationContext implements Closeable { getSpeciesBatchMap(vrac).put(speciesBatch.getSpecies().getReferenceTaxonId(), speciesBatch); } - public void addBenthosBatch(boolean vrac, BenthosBatch benthosBatch) { + public void addBenthosBatch(boolean vrac, SpeciesBatch benthosBatch) { getBenthosBatchMap(vrac).put(benthosBatch.getSpecies().getReferenceTaxonId(), benthosBatch); } @@ -222,7 +220,7 @@ public class GenericFormatImportOperationContext implements Closeable { speciesFrequencies.put(batch.getIdAsInt(), frequency); } - public void addBenthosFrequency(BenthosBatch batch, BenthosBatchFrequency frequency) { + public void addBenthosFrequency(SpeciesBatch batch, SpeciesBatchFrequency frequency) { benthosFrequencies.put(batch.getIdAsInt(), frequency); } @@ -242,17 +240,17 @@ public class GenericFormatImportOperationContext implements Closeable { return ImmutableList.copyOf(individualObservationBatchesById.values()); } - public int getNbSpeciesTaxon() { - Set<Species> speciesSet= new HashSet<>(); - SpeciesAbleBatchs.grabSpeciesChildBatchs(vracSpeciesBatches.values(), speciesSet); - SpeciesAbleBatchs.grabSpeciesChildBatchs(horsVracSpeciesBatches.values(), speciesSet); + public int getNbSpeciesTaxon() { + Set<Species> speciesSet = new HashSet<>(); + SpeciesBatchs.grabSpeciesChildBatchs(vracSpeciesBatches.values(), speciesSet); + SpeciesBatchs.grabSpeciesChildBatchs(horsVracSpeciesBatches.values(), speciesSet); return speciesSet.size(); } - public int getNbBenthosTaxon() { - Set<Species> speciesSet= new HashSet<>(); - SpeciesAbleBatchs.grabSpeciesChildBatchs(vracBenthosBatches.values(), speciesSet); - SpeciesAbleBatchs.grabSpeciesChildBatchs(horsVracBenthosBatches.values(), speciesSet); + public int getNbBenthosTaxon() { + Set<Species> speciesSet = new HashSet<>(); + SpeciesBatchs.grabSpeciesChildBatchs(vracBenthosBatches.values(), speciesSet); + SpeciesBatchs.grabSpeciesChildBatchs(horsVracBenthosBatches.values(), speciesSet); return speciesSet.size(); } @@ -260,11 +258,11 @@ public class GenericFormatImportOperationContext implements Closeable { return ImmutableList.copyOf(getSpeciesBatchMap(vrac).values()); } - public Collection<BenthosBatch> getBenthosBatches(boolean vrac) { + public Collection<SpeciesBatch> getBenthosBatches(boolean vrac) { return ImmutableList.copyOf(getBenthosBatchMap(vrac).values()); } - public List<BenthosBatchFrequency> getBenthosFrequencies(BenthosBatch benthosBatch) { + public List<SpeciesBatchFrequency> getBenthosFrequencies(SpeciesBatch benthosBatch) { return benthosFrequencies.get(benthosBatch.getIdAsInt()); } @@ -284,7 +282,7 @@ public class GenericFormatImportOperationContext implements Closeable { return vrac ? vracSpeciesBatches : horsVracSpeciesBatches; } - private Map<Integer, BenthosBatch> getBenthosBatchMap(boolean vrac) { + private Map<Integer, SpeciesBatch> getBenthosBatchMap(boolean vrac) { return vrac ? vracBenthosBatches : horsVracBenthosBatches; } 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 26feeef..bee006e 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 @@ -29,8 +29,6 @@ import fr.ifremer.adagio.core.dao.referential.ObjectTypeCode; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -183,18 +181,18 @@ public class GenericformatImportPersistenceHelper { } - public BenthosBatch createBenthosBatch(BenthosBatch batch, Integer parentId) { + public SpeciesBatch createBenthosBatch(SpeciesBatch batch, Integer parentId) { return persistenceService.createBenthosBatch(batch, parentId, false); } - public void saveBenthosBatchFrequency(Integer batchId, List<BenthosBatchFrequency> frequencies) { + public void saveBenthosBatchFrequency(Integer batchId, List<SpeciesBatchFrequency> frequencies) { persistenceService.saveBenthosBatchFrequency(batchId, frequencies); } public void deleteBenthosBatchForFishingOperation(Integer fishingOperationId) { - BatchContainer<BenthosBatch> rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, false); - for (BenthosBatch batch : rootBenthosBatch.getChildren()) { + BatchContainer<SpeciesBatch> rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, false); + for (SpeciesBatch batch : rootBenthosBatch.getChildren()) { persistenceService.deleteBenthosBatch(batch.getIdAsInt()); } 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 6f9ec6b..52a04e3 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 @@ -26,13 +26,7 @@ package fr.ifremer.tutti.service.genericformat.consumer; import com.google.common.base.Predicate; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequencys; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchs; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencys; @@ -106,7 +100,7 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { } - if (bean.getFrequencyWeight()!=null && Weights.isEqualWeight(bean.getFrequencyWeight(), 0f)) { + if (bean.getFrequencyWeight() != null && Weights.isEqualWeight(bean.getFrequencyWeight(), 0f)) { // Cant have a Weight 0.0 addCheckError(row, new FrequencyWeigthNullValueException(operationContext.getFishingOperation())); @@ -196,13 +190,13 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { Species species = bean.getSpecies(); boolean vrac = bean.isVrac(); - BenthosBatch batch = operationContext.getBenthosBatch(vrac, species.getReferenceTaxonId()); + SpeciesBatch batch = operationContext.getBenthosBatch(vrac, species.getReferenceTaxonId()); if (batch == null) { // create root batch - batch = BenthosBatchs.newBenthosBatch(); + batch = SpeciesBatchs.newBenthosBatch(); batch.setId(getNextBatchId()); batch.setSpecies(species); batch.setSpeciesToConfirm(bean.isSpeciesToConfirm()); @@ -220,7 +214,7 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { if (withFrequency) { - BenthosBatchFrequency frequency = BenthosBatchFrequencys.newBenthosBatchFrequency(); + SpeciesBatchFrequency frequency = SpeciesBatchFrequencys.newBenthosBatchFrequency(); frequency.setBatch(batch); frequency.setLengthStepCaracteristic(bean.getFrequencyLengthStepCaracteristic()); frequency.setLengthStep(bean.getFrequencyLengthStep()); @@ -241,7 +235,7 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { } - protected <A extends SpeciesAbleBatch> A fillBatchCategories(GenericFormatImportOperationContext operationContext, A batch, CatchRow bean) { + protected SpeciesBatch fillBatchCategories(GenericFormatImportOperationContext operationContext, SpeciesBatch batch, CatchRow bean) { for (ExportSampleCategory exportSampleCategory : bean.getFilledSampleCategories()) { batch = fillBatchCategories(operationContext, batch, exportSampleCategory); @@ -251,9 +245,9 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { } - protected <A extends SpeciesAbleBatch> A fillBatchCategories(GenericFormatImportOperationContext operationContext, A batch, ExportSampleCategory sampleCategory) { + protected SpeciesBatch fillBatchCategories(GenericFormatImportOperationContext operationContext, SpeciesBatch batch, ExportSampleCategory sampleCategory) { - A result = null; + SpeciesBatch result = null; if (batch.getSampleCategoryId() == null) { @@ -270,17 +264,17 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { } else { if (batch.getSampleCategoryId().equals(sampleCategory.getCategoryId()) && - batch.getSampleCategoryValue().equals(sampleCategory.getCategoryValue())) { + batch.getSampleCategoryValue().equals(sampleCategory.getCategoryValue())) { result = batch; } else if (!batch.isChildBatchsEmpty()) { // got some childs, try to find a matching one - for (A childBatch : SpeciesAbleBatchs.getChildBatchs(batch)) { + for (SpeciesBatch childBatch : batch.getChildBatchs()) { if (childBatch.getSampleCategoryId().equals(sampleCategory.getCategoryId()) && - childBatch.getSampleCategoryValue().equals(sampleCategory.getCategoryValue())) { + childBatch.getSampleCategoryValue().equals(sampleCategory.getCategoryValue())) { // matching child result = childBatch; @@ -293,7 +287,7 @@ public class CsvConsumerForCatch extends CsvComsumer<CatchRow, CatchModel> { if (result == null) { // add a child - result = SpeciesAbleBatchs.createNewChild(batch); + result = SpeciesBatchs.createNewChild(batch); result.setId(getNextBatchId()); result.setRankOrder(sampleCategory.getRankOrder()); result.setSampleCategoryId(sampleCategory.getCategoryId()); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java index e9f4011..422a561 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/csv/CatchRow.java @@ -24,7 +24,7 @@ package fr.ifremer.tutti.service.genericformat.csv; import com.google.common.base.Preconditions; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchFrequency; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -143,7 +143,7 @@ public class CatchRow extends RowWithOperationContextSupport { this.sampleCategory.set(order, sampleCategory); } - public void setFrequency(SpeciesAbleBatchFrequency frequency) { + public void setFrequency(SpeciesBatchFrequency frequency) { Preconditions.checkNotNull(frequency); setFrequencyLengthStepCaracteristic(frequency.getLengthStepCaracteristic()); setFrequencyLengthStep(frequency.getLengthStep()); diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/exportactions/CreateCatchBatchRowsAction.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/exportactions/CreateCatchBatchRowsAction.java index 5dda418..cb7004c 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/exportactions/CreateCatchBatchRowsAction.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/exportactions/CreateCatchBatchRowsAction.java @@ -27,7 +27,6 @@ package fr.ifremer.tutti.service.genericformat.exportactions; import fr.ifremer.adagio.core.dao.referential.ObjectTypeCode; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.service.PersistenceService; @@ -156,7 +155,7 @@ public class CreateCatchBatchRowsAction extends ExportFishingOperationActionSupp private void prepareBenthosBatches(GenericFormatExportContext exportContext, GenericFormatExportOperationContext operationContext) { - BatchContainer<BenthosBatch> rootSpeciesBatch = operationContext.getRootBenthosBatch(); + BatchContainer<SpeciesBatch> rootSpeciesBatch = operationContext.getRootBenthosBatch(); // Warning! This will also add the survey code to batch species CsvProducerForSpecies producerForSpecies = exportContext.getProducerForSpecies(); @@ -168,7 +167,7 @@ public class CreateCatchBatchRowsAction extends ExportFishingOperationActionSupp List<AttachmentRow> attachmentRows = new ArrayList<>(); - for (BenthosBatch benthosBatch : rootSpeciesBatch.getChildren()) { + for (SpeciesBatch benthosBatch : rootSpeciesBatch.getChildren()) { List<Attachment> attachments = persistenceService.getAllAttachments(ObjectTypeCode.BATCH, benthosBatch.getIdAsInt()); producerForAttachment.addAttachments(attachments, attachmentRows); } 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 55521a5..a6685c5 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 @@ -26,8 +26,6 @@ package fr.ifremer.tutti.service.genericformat.importactions; import fr.ifremer.adagio.core.dao.referential.ObjectTypeCode; import fr.ifremer.tutti.persistence.ProgressionModel; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; @@ -73,10 +71,10 @@ public class ImportCatchAction extends ImportActionSupport { @Override protected boolean canExecute() { return importContext.isTechnicalFilesValid() - && importContext.getSurveyFileResult().isValid() - && importContext.getOperationFileResult().isValid() - && (importContext.getImportRequest().isImportSpecies() || - importContext.getImportRequest().isImportBenthos()); + && importContext.getSurveyFileResult().isValid() + && importContext.getOperationFileResult().isValid() + && (importContext.getImportRequest().isImportSpecies() || + importContext.getImportRequest().isImportBenthos()); } @Override @@ -85,7 +83,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); } @@ -121,7 +119,7 @@ public class ImportCatchAction extends ImportActionSupport { persistSpeciesBatches(); } - if(importContext.getImportRequest().isImportBenthos()) { + if (importContext.getImportRequest().isImportBenthos()) { persistBenthosBatches(); } @@ -251,7 +249,7 @@ public class ImportCatchAction extends ImportActionSupport { if (fishingOperationContext.withBenthosBatches(true)) { - Collection<BenthosBatch> batches = fishingOperationContext.getBenthosBatches(true); + Collection<SpeciesBatch> batches = fishingOperationContext.getBenthosBatches(true); if (log.isInfoEnabled()) { log.info("Persist " + batches.size() + " VRAC benthos batch(es) of " + operationStr + " for cruise: " + cruiseStr); } @@ -261,7 +259,7 @@ public class ImportCatchAction extends ImportActionSupport { if (fishingOperationContext.withBenthosBatches(false)) { - Collection<BenthosBatch> batches = fishingOperationContext.getBenthosBatches(false); + Collection<SpeciesBatch> batches = fishingOperationContext.getBenthosBatches(false); if (log.isInfoEnabled()) { log.info("Persist " + batches.size() + " HORS VRAC benthos batch(es) of " + operationStr + " for cruise: " + cruiseContext.getCruiseLabel()); } @@ -272,22 +270,22 @@ public class ImportCatchAction extends ImportActionSupport { } } - private void persistBenthosBatches(GenericFormatImportOperationContext fishingOperationContext, Collection<BenthosBatch> batches, Integer parentId) { + private void persistBenthosBatches(GenericFormatImportOperationContext fishingOperationContext, Collection<SpeciesBatch> batches, Integer parentId) { int rankOrder = 1; - for (BenthosBatch batch : batches) { + for (SpeciesBatch batch : batches) { batch.setRankOrder(rankOrder++); Integer batchObjectId = fishingOperationContext.getBatchObjectId(batch.getIdAsInt()); - List<BenthosBatchFrequency> frequencies = fishingOperationContext.getBenthosFrequencies(batch); + List<SpeciesBatchFrequency> frequencies = fishingOperationContext.getBenthosFrequencies(batch); // reset temporary id to persist batch batch.setId((Integer) null); - BenthosBatch createdBatch = persistenceHelper.createBenthosBatch(batch, parentId); + SpeciesBatch createdBatch = persistenceHelper.createBenthosBatch(batch, parentId); 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/genericformat/producer/CsvProducerForCatch.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java index 251b6f1..dba9f60 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForCatch.java @@ -25,8 +25,6 @@ package fr.ifremer.tutti.service.genericformat.producer; */ import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; @@ -73,7 +71,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { BatchContainer<SpeciesBatch> rootSpeciesBatch = operationExportContext.getRootSpeciesBatch(); - BatchContainer<BenthosBatch> rootBenthosBatch = operationExportContext.getRootBenthosBatch(); + BatchContainer<SpeciesBatch> rootBenthosBatch = operationExportContext.getRootBenthosBatch(); Caracteristic weightMeasuredCaracteristic = operationExportContext.getWeightMeasuredCaracteristic(); String batchWeightUnit = weightMeasuredCaracteristic.getUnit(); @@ -102,7 +100,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { List<CatchRow> rows = new ArrayList<>(); - BatchContainer<BenthosBatch> rootBenthosBatch = operationExportContext.getRootBenthosBatch(); + BatchContainer<SpeciesBatch> rootBenthosBatch = operationExportContext.getRootBenthosBatch(); Caracteristic weightMeasuredCaracteristic = operationExportContext.getWeightMeasuredCaracteristic(); String batchWeightUnit = weightMeasuredCaracteristic.getUnit(); @@ -144,12 +142,12 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { } protected void addBenthosBatches(GenericFormatExportOperationContext operationExportContext, - BatchContainer<BenthosBatch> rootBenthosBatch, + BatchContainer<SpeciesBatch> rootBenthosBatch, Float benthosCatchRaisingFactor, String batchWeightUnit, List<CatchRow> rows) { - for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) { + for (SpeciesBatch benthosBatch : rootBenthosBatch.getChildren()) { boolean vracBatch = operationExportContext.isVracBatch(benthosBatch); @@ -317,7 +315,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { // use concrete frequency weight referenceWeight = batchFrequency.getWeight(); - frequencyWeights+= referenceWeight; + frequencyWeights += referenceWeight; } setRaisingFactor(row, totalBatchWeight, referenceWeight); @@ -370,7 +368,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { protected void addBenthosBatch(GenericFormatExportOperationContext operationExportContext, CatchRow currentRow, List<CatchRow> rows, - BenthosBatch benthosBatch, + SpeciesBatch benthosBatch, float totalBatchWeight) { Integer number = Numbers.getValueOrComputedValue(benthosBatch.getNumber(), @@ -397,7 +395,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { // on a leaf, get frequencies - List<BenthosBatchFrequency> benthosBatchFrequency = + List<SpeciesBatchFrequency> benthosBatchFrequency = operationExportContext.getAllBenthosBatchFrequency(benthosBatch.getIdAsInt()); if (CollectionUtils.isEmpty(benthosBatchFrequency)) { @@ -446,7 +444,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { float frequencyWeights = 0f; Set<CatchRow> frequencyRows = new LinkedHashSet<>(); - for (BenthosBatchFrequency batchFrequency : benthosBatchFrequency) { + for (SpeciesBatchFrequency batchFrequency : benthosBatchFrequency) { CatchRow row = currentRow.copy(); row.setFrequency(batchFrequency); frequencyRows.add(row); @@ -456,7 +454,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { // use concrete frequency weight referenceWeight = batchFrequency.getWeight(); - frequencyWeights+=referenceWeight; + frequencyWeights += referenceWeight; } setRaisingFactor(row, totalBatchWeight, referenceWeight); @@ -476,7 +474,7 @@ public class CsvProducerForCatch extends CsvProducer<CatchRow, CatchModel> { float sampleComputedWeight = 0f; - for (BenthosBatch childBatch : benthosBatch.getChildBatchs()) { + for (SpeciesBatch childBatch : benthosBatch.getChildBatchs()) { // always use a copy, otherwise sample categories can be shared by brothers CatchRow childRow = currentRow.copy(); addBenthosBatch(operationExportContext, diff --git a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForSpecies.java b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForSpecies.java index b0412fb..5f34473 100644 --- a/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForSpecies.java +++ b/tutti-service/src/main/java/fr/ifremer/tutti/service/genericformat/producer/CsvProducerForSpecies.java @@ -27,7 +27,6 @@ package fr.ifremer.tutti.service.genericformat.producer; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.service.csv.CsvProducer; @@ -66,9 +65,9 @@ public class CsvProducerForSpecies extends CsvProducer<SpeciesExportRow, Species } - public void prepareBenthosBatchRows(BatchContainer<BenthosBatch> rootBenthosBatch) { + public void prepareBenthosBatchRows(BatchContainer<SpeciesBatch> rootBenthosBatch) { - for (BenthosBatch benthosBatch : rootBenthosBatch.getChildren()) { + for (SpeciesBatch benthosBatch : rootBenthosBatch.getChildren()) { addSpecies(benthosBatch.getSpecies()); } diff --git a/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/BenthosBatch-edit-error-validation.xml b/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/BenthosBatch-edit-error-validation.xml deleted file mode 100644 index 6678a97..0000000 --- a/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/BenthosBatch-edit-error-validation.xml +++ /dev/null @@ -1,53 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - Tutti :: Service - $Id$ - $HeadURL$ - %% - Copyright (C) 2012 - 2014 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> - -<!DOCTYPE validators PUBLIC - "-//Apache Struts//XWork Validator 1.0.3//EN" - "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> -<validators> - - <field name="species"> - <field-validator type="required" short-circuit="true"> - <message>tutti.validator.error.benthosBatch.species.required</message> - </field-validator> - </field> - - <field name="weight"> - <field-validator type="fieldexpression" short-circuit="true"> - <param name="expression"> - <![CDATA[ !(sampleCategoryWeight == null && weight != null) ]]> - </param> - <message>tutti.service.operations.computeWeights.error.benthos.incoherentRowWeightCategory</message> - </field-validator> - - <field-validator type="fieldexpression" short-circuit="true"> - <param name="expression"> - <![CDATA[ weight == null || sampleCategoryWeight == null || weight <= sampleCategoryWeight ]]> - </param> - <message>tutti.service.operations.computeWeights.error.benthos.incoherentSampleWeight</message> - </field-validator> - </field> - -</validators> diff --git a/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/BenthosBatch-validate-fatal-validation.xml b/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/BenthosBatch-validate-fatal-validation.xml deleted file mode 100644 index 4ddb9a0..0000000 --- a/tutti-service/src/main/resources/fr/ifremer/tutti/persistence/entities/data/BenthosBatch-validate-fatal-validation.xml +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - Tutti :: Service - $Id:$ - $HeadURL:$ - %% - Copyright (C) 2012 - 2014 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as - published by the Free Software Foundation, either version 3 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program. If not, see - <http://www.gnu.org/licenses/gpl-3.0.html>. - #L% - --> - - -<!DOCTYPE validators PUBLIC - "-//Apache Struts//XWork Validator 1.0.3//EN" - "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> -<validators> - - <field name="species"> - <field-validator type="temporaryReferential" short-circuit="true"> - <message>tutti.validator.error.benthosBatch.species.temporary</message> - </field-validator> - </field> - -</validators> diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/BeanValidatorDetectorTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/BeanValidatorDetectorTest.java index 0f530b6..dee857c 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/BeanValidatorDetectorTest.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/BeanValidatorDetectorTest.java @@ -58,7 +58,6 @@ public class BeanValidatorDetectorTest extends AbstractValidatorDetectorTest { public static void setUpClass() throws Exception { ALL_TYPES = new Class[]{ AccidentalBatch.class, - BenthosBatch.class, CatchBatch.class, Cruise.class, FishingOperation.class, @@ -81,7 +80,7 @@ public class BeanValidatorDetectorTest extends AbstractValidatorDetectorTest { SortedSet<NuitonValidator<?>> validators = detectValidators(ALL_TYPES); assertFalse(validators.isEmpty()); - assertEquals(17, validators.size()); + assertEquals(15, validators.size()); } @Test @@ -106,7 +105,6 @@ public class BeanValidatorDetectorTest extends AbstractValidatorDetectorTest { assertValidatorSetWithSameContextName(validators, contextName, AccidentalBatch.class, - BenthosBatch.class, CatchBatch.class, Cruise.class, FishingOperation.class, @@ -126,7 +124,6 @@ public class BeanValidatorDetectorTest extends AbstractValidatorDetectorTest { assertValidatorSetWithSameContextName(validators, contextName, AccidentalBatch.class, - BenthosBatch.class, CatchBatch.class, Cruise.class, FishingOperation.class, diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/PersistenceServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/PersistenceServiceTest.java index 051686b..0d57edb 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/PersistenceServiceTest.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/PersistenceServiceTest.java @@ -28,8 +28,6 @@ import fr.ifremer.tutti.persistence.entities.CaracteristicMap; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; @@ -110,7 +108,7 @@ public class PersistenceServiceTest { Gear source = service.getGear(-4); Gear target = service.getGear(378); - service.replaceGear(source, target,false ); + service.replaceGear(source, target, false); } { @@ -211,7 +209,7 @@ public class PersistenceServiceTest { BatchContainer<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(0, false); assertSpeciesBatch(rootSpeciesBatch, "-1"); - BatchContainer<BenthosBatch> rootBenthosBatch = service.getRootBenthosBatch(0, false); + BatchContainer<SpeciesBatch> rootBenthosBatch = service.getRootBenthosBatch(0, false); assertBenthosBatch(rootBenthosBatch, "-2"); List<IndividualObservationBatch> allIndividualObservationBatch = service.getAllIndividualObservationBatchsForFishingOperation(0); @@ -232,7 +230,7 @@ public class PersistenceServiceTest { BatchContainer<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(0, false); assertSpeciesBatch(rootSpeciesBatch, "15461"); - BatchContainer<BenthosBatch> rootBenthosBatch = service.getRootBenthosBatch(0, false); + BatchContainer<SpeciesBatch> rootBenthosBatch = service.getRootBenthosBatch(0, false); assertBenthosBatch(rootBenthosBatch, "-2"); List<IndividualObservationBatch> allIndividualObservationBatch = service.getAllIndividualObservationBatchsForFishingOperation(0); @@ -246,14 +244,14 @@ public class PersistenceServiceTest { Species source = service.getSpeciesByReferenceTaxonId(-2); Species target = service.getSpeciesByReferenceTaxonId(2); - service.replaceSpecies(source, target,false ); + service.replaceSpecies(source, target, false); } { BatchContainer<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(0, false); assertSpeciesBatch(rootSpeciesBatch, "15461"); - BatchContainer<BenthosBatch> rootBenthosBatch = service.getRootBenthosBatch(0, false); + BatchContainer<SpeciesBatch> rootBenthosBatch = service.getRootBenthosBatch(0, false); assertBenthosBatch(rootBenthosBatch, "15462"); List<IndividualObservationBatch> allIndividualObservationBatch = service.getAllIndividualObservationBatchsForFishingOperation(0); @@ -273,7 +271,7 @@ public class PersistenceServiceTest { BatchContainer<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(0, false); assertSpeciesBatch(rootSpeciesBatch, "15461"); - BatchContainer<BenthosBatch> rootBenthosBatch = service.getRootBenthosBatch(0, false); + BatchContainer<SpeciesBatch> rootBenthosBatch = service.getRootBenthosBatch(0, false); assertBenthosBatch(rootBenthosBatch, "15462"); List<IndividualObservationBatch> allIndividualObservationBatch = service.getAllIndividualObservationBatchsForFishingOperation(0); @@ -373,14 +371,14 @@ public class PersistenceServiceTest { } } - protected void assertBenthosBatch(BatchContainer<BenthosBatch> rootSpeciesBatch, String expectedId) { + protected void assertBenthosBatch(BatchContainer<SpeciesBatch> rootSpeciesBatch, String expectedId) { Assert.assertNotNull(rootSpeciesBatch); Assert.assertNotNull(rootSpeciesBatch.getChildren()); Assert.assertFalse(rootSpeciesBatch.isEmptyChildren()); - for (BenthosBatch batch : rootSpeciesBatch.getChildren()) { + for (SpeciesBatch batch : rootSpeciesBatch.getChildren()) { assertContainsId(batch.getSpecies(), expectedId); - List<BenthosBatchFrequency> frequencies = service.getAllBenthosBatchFrequency(batch.getIdAsInt()); - for (BenthosBatchFrequency frequency : frequencies) { + List<SpeciesBatchFrequency> frequencies = service.getAllBenthosBatchFrequency(batch.getIdAsInt()); + for (SpeciesBatchFrequency frequency : frequencies) { assertContainsId(frequency.getBatch().getSpecies(), expectedId); } } 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 60e7631..b526b34 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 @@ -38,8 +38,6 @@ import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.Cruises; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.FishingOperations; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; @@ -88,7 +86,7 @@ public class BigfinImportService2Test { protected File dataDirectory; - protected Predicate<SpeciesAbleBatch> vracPredicate; + protected Predicate<SpeciesBatch> vracPredicate; public static final String PROGRAM_ID = "CAM-CGFS"; @@ -110,7 +108,7 @@ public class BigfinImportService2Test { dataContext = dbResource.loadContext(PROGRAM_ID); - vracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); + vracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); } @Test @@ -321,7 +319,7 @@ public class BigfinImportService2Test { Assert.assertEquals(5, rootSpeciesBatch.sizeChildren()); Set<Species> speciesSet = new LinkedHashSet<>(); - SpeciesAbleBatchs.grabSpeciesChildBatchs(rootSpeciesBatch.getChildren(), speciesSet); + SpeciesBatchs.grabSpeciesChildBatchs(rootSpeciesBatch.getChildren(), speciesSet); Assert.assertEquals(5, speciesSet.size()); Assert.assertTrue(speciesSet.contains(rajaClaSpecies)); Assert.assertTrue(speciesSet.contains(tracDraSpecies)); @@ -332,7 +330,7 @@ public class BigfinImportService2Test { for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { Set<Integer> sampleCategories = new LinkedHashSet<>(); - SpeciesAbleBatchs.grabSampleCategorieValuesChildBatchs(speciesBatch, sampleCategories); + SpeciesBatchs.grabSampleCategorieValuesChildBatchs(speciesBatch, sampleCategories); List<SpeciesBatchFrequency> allSpeciesBatchFrequency = persistenceService.getAllSpeciesBatchFrequency(speciesBatch.getIdAsInt()); if (rajaClaSpecies.equals(speciesBatch.getSpecies())) { diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java index ef3624e..e024da9 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/bigfin/BigfinImportServiceTest.java @@ -30,9 +30,8 @@ import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.ServiceDbResource; import fr.ifremer.tutti.service.TuttiServiceContext; @@ -74,7 +73,7 @@ public class BigfinImportServiceTest { protected File dataDirectory; - protected Predicate<SpeciesAbleBatch> vracPredicate; + protected Predicate<SpeciesBatch> vracPredicate; @Before public void setUp() throws Exception { @@ -92,7 +91,7 @@ public class BigfinImportServiceTest { dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 1, OPERATION_1_ID); - vracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); + vracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); } @Test diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/WeightComputingServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/WeightComputingServiceTest.java index 7ef3905..abcd9f6 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/WeightComputingServiceTest.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/WeightComputingServiceTest.java @@ -22,9 +22,7 @@ package fr.ifremer.tutti.service.catches; * #L% */ -import org.nuiton.jaxx.application.ApplicationBusinessException; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; @@ -37,6 +35,7 @@ import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; +import org.nuiton.jaxx.application.ApplicationBusinessException; import java.util.List; @@ -111,7 +110,7 @@ public class WeightComputingServiceTest { catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_3_ID); try { - BatchContainer<BenthosBatch> batches = persistenceService.getRootBenthosBatch(OPERATION_3_ID, false); + BatchContainer<SpeciesBatch> batches = persistenceService.getRootBenthosBatch(OPERATION_3_ID, false); weightComputingService.computeCatchBatchWeights(catchBatch, null, batches, null); Assert.fail(); @@ -138,7 +137,7 @@ public class WeightComputingServiceTest { catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_5_ID); try { BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_5_ID, false); - BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_5_ID, false); + BatchContainer<SpeciesBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_5_ID, false); weightComputingService.computeCatchBatchWeights(catchBatch, speciesBatches, benthosBatches, null); Assert.fail(); @@ -164,7 +163,7 @@ public class WeightComputingServiceTest { catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_7_ID); try { BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_7_ID, false); - BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_7_ID, false); + BatchContainer<SpeciesBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_7_ID, false); weightComputingService.computeCatchBatchWeights(catchBatch, speciesBatches, benthosBatches, null); if (log.isInfoEnabled()) { log.info("Weight computing worked on operation #7"); @@ -208,11 +207,11 @@ public class WeightComputingServiceTest { Assert.fail(); } - BatchContainer<BenthosBatch> benthosBatchContainer = persistenceService.getRootBenthosBatch(OPERATION_1_ID, false); - List<BenthosBatch> benthosBatches = benthosBatchContainer.getChildren(); + BatchContainer<SpeciesBatch> benthosBatchContainer = persistenceService.getRootBenthosBatch(OPERATION_1_ID, false); + List<SpeciesBatch> benthosBatches = benthosBatchContainer.getChildren(); for (int i = 0; i < benthosBatches.size() - 1; i++) { try { - BenthosBatch batch = benthosBatches.get(i); + SpeciesBatch batch = benthosBatches.get(i); weightComputingService.computeBenthosBatch(batch); //expected error on species batch #0 : Benthos - Le lot de ABLEHIA - Ablennes hians/V/HV - Vrac n'a pas de poids //expected error on species batch #1 : Benthos - Le lot de ABLU - Abludomelita/V/HV - Vrac n'a pas de poids @@ -228,7 +227,7 @@ public class WeightComputingServiceTest { } } } - BenthosBatch benthosBatch = benthosBatches.get(benthosBatches.size() - 1); + SpeciesBatch benthosBatch = benthosBatches.get(benthosBatches.size() - 1); try { weightComputingService.computeBenthosBatch(benthosBatch); if (log.isInfoEnabled()) { diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java index 73d5b9d..1e037e4 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java @@ -30,9 +30,8 @@ import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.ServiceDbResource; import fr.ifremer.tutti.service.TuttiServiceContext; @@ -82,7 +81,7 @@ public class PsionImportServiceTest { protected File dataDirectory; - protected Predicate<SpeciesAbleBatch> vracPredicate; + protected Predicate<SpeciesBatch> vracPredicate; @Before public void setUp() throws Exception { @@ -105,7 +104,7 @@ public class PsionImportServiceTest { dataContext = dbResource.loadContext(PROGRAM_ID, CRUISE_ID, 3, OPERATION_2_ID, OPERATION_1_ID, OPERATION_3_ID); - vracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); + vracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate(PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.VRAC.getValue()); } @Test diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6116Test.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6116Test.java index 08e044d..87c305a 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6116Test.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6116Test.java @@ -31,9 +31,8 @@ import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; import fr.ifremer.tutti.persistence.entities.referential.Species; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; @@ -104,32 +103,32 @@ public class PupitriImportServiceEvo6116Test extends PupitryImportServiceTestSup ); - Predicate<SpeciesAbleBatch> batchVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> batchVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.SORTED_VRAC.getValue()); - Predicate<SpeciesAbleBatch> batchHorsVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> batchHorsVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.SORTED_HORS_VRAC.getValue()); - Predicate<SpeciesAbleBatch> bigPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> bigPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SIZE_CATEGORY.getValue(), QualitativeValueId.SIZE_BIG.getValue()); - Predicate<SpeciesAbleBatch> smallPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> smallPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SIZE_CATEGORY.getValue(), QualitativeValueId.SIZE_SMALL.getValue()); - Predicate<SpeciesAbleBatch> malePredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> malePredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SEX.getValue(), QualitativeValueId.SEX_MALE.getValue()); - Predicate<SpeciesAbleBatch> femalePredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> femalePredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SEX.getValue(), QualitativeValueId.SEX_FEMALE.getValue()); - Predicate<SpeciesAbleBatch> undefinedPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> undefinedPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SEX.getValue(), QualitativeValueId.SEX_UNDEFINED.getValue()); diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6149Test.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6149Test.java index 466bdd0..755c3ab 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6149Test.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6149Test.java @@ -31,9 +31,8 @@ import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; import fr.ifremer.tutti.persistence.entities.referential.Species; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; @@ -104,20 +103,20 @@ public class PupitriImportServiceEvo6149Test extends PupitryImportServiceTestSup ); - Predicate<SpeciesAbleBatch> batchVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> batchVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.SORTED_VRAC.getValue()); - Predicate<SpeciesAbleBatch> batchHorsVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> batchHorsVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.SORTED_HORS_VRAC.getValue()); - Predicate<SpeciesAbleBatch> bigVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> bigVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SIZE_CATEGORY.getValue(), QualitativeValueId.SIZE_BIG.getValue()); - Predicate<SpeciesAbleBatch> smallVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> smallVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SIZE_CATEGORY.getValue(), QualitativeValueId.SIZE_SMALL.getValue()); diff --git a/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6592Test.java b/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6592Test.java index 5618b00..fb90dda 100644 --- a/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6592Test.java +++ b/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceEvo6592Test.java @@ -31,9 +31,8 @@ import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueId; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; -import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatchs; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; +import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchs; import fr.ifremer.tutti.persistence.entities.referential.Species; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; @@ -107,20 +106,20 @@ public class PupitriImportServiceEvo6592Test extends PupitryImportServiceTestSup ); - Predicate<SpeciesAbleBatch> batchVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> batchVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.SORTED_VRAC.getValue()); - Predicate<SpeciesAbleBatch> batchHorsVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> batchHorsVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SORTED_UNSORTED.getValue(), QualitativeValueId.SORTED_HORS_VRAC.getValue()); - Predicate<SpeciesAbleBatch> bigVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> bigVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SIZE_CATEGORY.getValue(), QualitativeValueId.SIZE_BIG.getValue()); - Predicate<SpeciesAbleBatch> smallVracPredicate = SpeciesAbleBatchs.newSpeciesAbleBatchCategoryPredicate( + Predicate<SpeciesBatch> smallVracPredicate = SpeciesBatchs.newSpeciesAbleBatchCategoryPredicate( PmfmId.SIZE_CATEGORY.getValue(), QualitativeValueId.SIZE_SMALL.getValue()); -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.