Author: tchemit Date: 2014-04-23 00:43:02 +0200 (Wed, 23 Apr 2014) New Revision: 1722 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1722 Log: refs-70 #4958 (need to validate) clean measurement codes improve some codes Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/Cruises.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SynchronizationStatusHelper.java Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementPersistenceHelper.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchTreeHelper.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java trunk/tutti-persistence/src/main/resources/queries-failsafe.hbm.xml trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightCleaningService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostImportService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/WeightComputingServiceTest.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceTest.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -41,7 +41,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.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; @@ -739,8 +738,8 @@ //------------------------------------------------------------------------// @Override - public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException { - return speciesBatchService.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel); + public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, boolean validateTree) throws InvalidBatchModelException { + return speciesBatchService.getRootSpeciesBatch(fishingOperationId, validateTree); } @Override @@ -788,8 +787,8 @@ //------------------------------------------------------------------------// @Override - public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException { - return benthosBatchService.getRootBenthosBatch(fishingOperationId, sampleCategoryModel); + public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, boolean validateTree) throws InvalidBatchModelException { + return benthosBatchService.getRootBenthosBatch(fishingOperationId, validateTree); } @Override Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -39,7 +39,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.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; @@ -496,7 +495,7 @@ } @Override - public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException { + public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, boolean validateTree) throws InvalidBatchModelException { throw notImplemented(); } @@ -541,7 +540,7 @@ } @Override - public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException { + public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, boolean validateTree) throws InvalidBatchModelException { throw notImplemented(); } Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/Cruises.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/Cruises.java (rev 0) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/Cruises.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -0,0 +1,21 @@ +package fr.ifremer.tutti.persistence.entities.data; + +import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus; + +public class Cruises extends AbstractCruises { + + public static boolean isDirty(Cruise cruise) { + String synchronizationStatus = cruise.getSynchronizationStatus(); + return SynchronizationStatus.DIRTY.getValue().equals(synchronizationStatus); + } + + public static boolean isReadyToSynch(Cruise cruise) { + String synchronizationStatus = cruise.getSynchronizationStatus(); + return SynchronizationStatus.READY_TO_SYNCHRONIZE.getValue().equals(synchronizationStatus); + } + + public static boolean isSynch(Cruise cruise) { + String synchronizationStatus = cruise.getSynchronizationStatus(); + return SynchronizationStatus.SYNCHRONIZED.getValue().equals(synchronizationStatus); + } +} Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/Cruises.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -27,6 +27,7 @@ import com.google.common.base.Preconditions; import fr.ifremer.tutti.TuttiConfiguration; import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; +import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Query; @@ -67,19 +68,20 @@ @Resource(name = "tuttiEnumerationFile") protected TuttiEnumerationFile enumeration; + @Resource(name = "tuttiConfiguration") protected TuttiConfiguration config; @Override public void init() { - if (config == null) { - - config = TuttiConfiguration.getInstance(); - - Preconditions.checkNotNull( - config, "No config found in " + - TuttiConfiguration.class.getName() - ); - } +// if (config == null) { +// +// config = TuttiConfiguration.getInstance(); +// +// Preconditions.checkNotNull( +// config, "No config found in " + +// TuttiConfiguration.class.getName() +// ); +// } } @Override @@ -301,6 +303,11 @@ return result; } + + public SampleCategoryModel getSampleCategoryModel() { + return config.getSampleCategoryModel(); + } + private Calendar calendar = new GregorianCalendar(); Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -73,6 +73,9 @@ @Resource(name = "samplePersistenceHelper") protected SamplePersistenceHelper samplePersistenceHelper; + @Resource(name = "synchronizationStatusHelper") + protected SynchronizationStatusHelper synchronizationStatusHelper; + @Override public List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId) { Preconditions.checkNotNull(fishingOperationId); @@ -100,8 +103,11 @@ accidentalBatch.setSpecies(species); // Comment - accidentalBatch.setComment((String) source[colIndex]); + accidentalBatch.setComment((String) source[colIndex++]); + // synchronizationStatus + accidentalBatch.setSynchronizationStatus((String) source[colIndex]); + // Sample Measurements accidentalBatch.setCaracteristics(new CaracteristicMap()); Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -30,7 +30,6 @@ 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.referential.Species; import org.springframework.transaction.annotation.Transactional; @@ -46,7 +45,7 @@ public interface BenthosBatchPersistenceService extends TuttiPersistenceServiceImplementor { //------------------------------------------------------------------------// - //-- Benthos Batch methods --// + //-- BenthosBatch methods --// //------------------------------------------------------------------------// /** @@ -54,13 +53,13 @@ * <p/> * <strong>Note:</strong> All childs of the batch should be loaded here. * - * @param fishingOperationId if of the fishing operation to seek - * @param sampleCategoryModel [optional] sample category model to check + * @param fishingOperationId if of the fishing operation to seek + * @param validateTree flag to validate sample category model * @return the list of root {@link BenthosBatch} * @throws InvalidBatchModelException if batch does not respect the sample category model * @since 1.0 */ - BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException; + BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, boolean validateTree) throws InvalidBatchModelException; @Transactional(readOnly = false) BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId); @@ -85,7 +84,7 @@ void changeBenthosBatchSpecies(String batchId, Species species); //------------------------------------------------------------------------// - //-- SpeciesBatchFrequency methods (for benthos) --// + //-- BenthosBatchFrequency methods --// //------------------------------------------------------------------------// /** Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -45,18 +45,15 @@ 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.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Species; import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper; import fr.ifremer.tutti.persistence.service.batch.BatchTreeHelper; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -90,37 +87,23 @@ @Resource(name = "measurementPersistenceHelper") protected MeasurementPersistenceHelper measurementPersistenceHelper; - protected SampleCategoryModel sampleCategoryModel; - //------------------------------------------------------------------------// //-- Benthos Batch methods --// //------------------------------------------------------------------------// @Override - public void init() { - super.init(); - - sampleCategoryModel = config.getSampleCategoryModel(); - } - - @Override public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, - SampleCategoryModel sampleCategoryModel) { + boolean validateTree) { Preconditions.checkNotNull(fishingOperationId); CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false); - // Vrac / Benthos + // -- Vrac > Benthos > Alive Itemized SortingBatch vracBenthosBatch = batchTreeHelper.getBenthosVracAliveItemizedRootBatch(catchBatch); -// SortingBatch vracBenthosBatch = batchHelper.getSortingBatch( -// catchBatch, -// "Vrac > Benthos > Alive Itemized", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, -// enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED -// ); - BatchContainer<BenthosBatch> result = new BatchContainer<BenthosBatch>(); + SampleCategoryModel sampleCategoryModel = getSampleCategoryModel(); + + BatchContainer<BenthosBatch> result = new BatchContainer<>(); if (vracBenthosBatch != null) { result.setId(vracBenthosBatch.getId()); @@ -134,7 +117,8 @@ } BenthosBatch target = BenthosBatchs.newBenthosBatch(); target.setSpecies(species); - entityToBenthosBatch(source, target); + + entityToBenthosBatch(sampleCategoryModel, source, target); result.addChildren(target); if (log.isDebugEnabled()) { log.debug("Loaded CatchBatch Vrac > Benthos > Alive Itemized > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId()); @@ -142,14 +126,9 @@ } } - // Hors-Vrac / Benthos + // -- Hors Vrac > Benthos SortingBatch horsVracBenthosBatch = batchTreeHelper.getBenthosHorsVracRootBatch(catchBatch); -// SortingBatch horsVracBenthosBatch = batchHelper.getSortingBatch( -// catchBatch, -// "Hors Vrac > Benthos", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS -// ); + if (horsVracBenthosBatch != null) { for (Batch batch : horsVracBenthosBatch.getChildBatchs()) { SortingBatch source = (SortingBatch) batch; @@ -163,7 +142,7 @@ BenthosBatch target = BenthosBatchs.newBenthosBatch(); target.setSpecies(species); - entityToBenthosBatch(source, target); + entityToBenthosBatch(sampleCategoryModel, source, target); result.addChildren(target); if (log.isDebugEnabled()) { log.debug("Loaded CatchBatch Hors Vrac > Benthos > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId()); @@ -171,7 +150,7 @@ } } - if (sampleCategoryModel != null) { + if (validateTree) { // validate with given sample category model batchHelper.validateBenthos(sampleCategoryModel, result); @@ -227,30 +206,31 @@ @Override public void deleteBenthosSubBatch(String id) { - Preconditions.checkNotNull(id); + batchHelper.deleteSpeciesSubBatch(id); - Integer benthosBatchId = Integer.valueOf(id); - - CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(benthosBatchId); - SortingBatch sortingBatch = batchHelper.getSortingBatchById( - catchBatch, benthosBatchId); - - // get his children - Collection<Batch> childBatchs = sortingBatch.getChildBatchs(); - - if (CollectionUtils.isNotEmpty(childBatchs)) { - - for (Batch childBatch : childBatchs) { - - // delete this child and all his children - Integer childBatchId = childBatch.getId(); - - if (log.isDebugEnabled()) { - log.debug("Delete child [" + childBatchId + "] of species batch: " + id); - } - batchHelper.removeWithChildren(childBatchId); - } - } +// Preconditions.checkNotNull(id); +// +// Integer benthosBatchId = Integer.valueOf(id); +// +// CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(benthosBatchId); +// SortingBatch sortingBatch = batchHelper.getSortingBatchById(catchBatch, benthosBatchId); +// +// // get his children +// Collection<Batch> childBatchs = sortingBatch.getChildBatchs(); +// +// if (CollectionUtils.isNotEmpty(childBatchs)) { +// +// for (Batch childBatch : childBatchs) { +// +// // delete this child and all his children +// Integer childBatchId = childBatch.getId(); +// +// if (log.isDebugEnabled()) { +// log.debug("Delete child [" + childBatchId + "] of species batch: " + id); +// } +// batchHelper.removeWithChildren(childBatchId); +// } +// } } @Override @@ -272,12 +252,12 @@ Preconditions.checkNotNull(benthosBatchId); List<SortingBatch> frequencyChilds = batchHelper.getFrequencies( - sampleCategoryModel, benthosBatchId); + benthosBatchId); List<BenthosBatchFrequency> results = Lists.newArrayList(); for (SortingBatch child : frequencyChilds) { BenthosBatchFrequency target = BenthosBatchFrequencys.newBenthosBatchFrequency(); - entityToBenthosBatchFrequency(child, target); + batchHelper.entityToBatchFrequency(child, target); results.add(target); } return Collections.unmodifiableList(results); @@ -335,7 +315,7 @@ // Remember child ids, to remove unchanged item (see at bottom in this method) List<Integer> notUpdatedChildIds = Lists.newArrayList(); List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds( - sampleCategoryModel, parentBatch); + parentBatch); for (SortingBatch child : frequencyChilds) { notUpdatedChildIds.add(child.getId()); } @@ -389,7 +369,8 @@ //-- Internal methods --// //------------------------------------------------------------------------// - protected BenthosBatch entityToBenthosBatch(SortingBatch source, + protected BenthosBatch entityToBenthosBatch(SampleCategoryModel sampleCategoryModel, + SortingBatch source, BenthosBatch target) { Preconditions.checkNotNull(target.getSpecies()); @@ -428,7 +409,7 @@ if (sm.getQualitativeValue() != null) { qualitativeId = sm.getQualitativeValue().getId(); } - setSampleCategoryQualitative( + batchHelper.setSampleCategoryQualitative( target, sm.getPmfm().getId(), sm.getNumericalValue(), @@ -443,9 +424,9 @@ SortingBatch sourceChild = (SortingBatch) batch; BenthosBatch targetChild = BenthosBatchs.newBenthosBatch(); targetChild.setSpecies(target.getSpecies()); - entityToBenthosBatch(sourceChild, targetChild); + entityToBenthosBatch(sampleCategoryModel, sourceChild, targetChild); if (log.isDebugEnabled()) { - log.debug("Loaded CatchBatch Hors Vrac > (Species|Benthos) > " + targetChild.getSpecies().getReferenceTaxonId() + " : " + target.getId()); + log.debug("Loaded CatchBatch Hors Vrac > Benthos > " + targetChild.getSpecies().getReferenceTaxonId() + " : " + target.getId()); } if (targetChild.getSampleCategoryValue() != null) { targetChilds.add(targetChild); @@ -461,31 +442,6 @@ return target; } - protected void entityToBenthosBatchFrequency(SortingBatch source, - BenthosBatchFrequency target) { - - target.setId(source.getId()); - - // Rank order - target.setRankOrder(Integer.valueOf(source.getRankOrder())); - - target.setNumber(source.getIndividualCount()); - target.setWeight(source.getWeight()); - - Preconditions.checkState(source.getSortingMeasurements().size() == 1, "SortingBatch [" + source.getId() + "] need exactly one sortingMeasurement (to store the length step category), but had " + source.getSortingMeasurements().size()); - SortingMeasurement sm = source.getSortingMeasurements().iterator().next(); - Preconditions.checkNotNull(sm.getPmfm(), "SortingMeasurement [" + sm.getId() + "] can not have a null pmfm"); - Preconditions.checkNotNull(sm.getPmfm().getId(), "SortingMeasurement [" + sm.getId() + "] can not have a pmfm with null id"); - - // Length step category - Caracteristic lengthStepCaracteristic = - referentialService.getCaracteristic(sm.getPmfm().getId()); - target.setLengthStepCaracteristic(lengthStepCaracteristic); - - // Length - target.setLengthStep(sm.getNumericalValue()); - } - protected void benthosBatchToEntity(BenthosBatch source, SortingBatch target, String parentBatchId, @@ -672,7 +628,7 @@ if ((source.getLengthStepCaracteristic() != null && source.getLengthStep() != null)) { Integer pmfmId = source.getLengthStepCaracteristic().getIdAsInt(); SortingMeasurement sortingMeasurement = measurementPersistenceHelper.setSortingMeasurement(target, pmfmId, - source.getLengthStep()); + source.getLengthStep()); notChangedSortingMeasurements.remove(sortingMeasurement); } @@ -696,26 +652,4 @@ sortingMeasurements.removeAll(notChangedSortingMeasurements); } } - - public void setSampleCategoryQualitative(BenthosBatch target, - Integer pmfmId, - Float numericalvalue, - String alphanumericalValue, - Integer qualitativeValueId) { - // skip if null or corresponding to the SORTING_TYPE PMFM (Espèce, Benthos, Plancton, etc.) - if (pmfmId == null || pmfmId.equals(enumeration.PMFM_ID_SORTING_TYPE)) { - return; - } - - boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(pmfmId); - Preconditions.checkNotNull(isSamplingCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId); - - target.setSampleCategoryId(pmfmId); - Serializable categoryValue = batchHelper.getSampleCategoryQualitative( - pmfmId, - numericalvalue, - alphanumericalValue, - qualitativeValueId); - target.setSampleCategoryValue(categoryValue); - } } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -72,6 +72,9 @@ @Resource(name = "measurementPersistenceHelper") protected MeasurementPersistenceHelper measurementPersistenceHelper; + @Resource(name = "synchronizationStatusHelper") + protected SynchronizationStatusHelper synchronizationStatusHelper; + //------------------------------------------------------------------------// //-- CatchBatch methods --// //------------------------------------------------------------------------// @@ -92,94 +95,62 @@ fr.ifremer.adagio.core.dao.data.batch.CatchBatch source = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, true); + if (log.isDebugEnabled()) { + log.debug("Loaded CatchBatch: " + source.getId()); + } + + batchTreeHelper.displayCatchBatch(source); + CatchBatch result = new CatchBatchBean(); result.setId(source.getId()); result.setCatchTotalWeight(source.getWeight()); + result.setSynchronizationStatus(source.getSynchronizationStatus()); - if (log.isDebugEnabled()) { - log.debug("Loaded CatchBatch: " + result.getId()); - } - - // Vrac + // -- Vrac SortingBatch vracBatch = batchTreeHelper.getVracBatch(source); -// SortingBatch vracBatch = batchHelper.getSortingBatch( -// source, -// "Vrac", -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_VRAC_ID); if (vracBatch != null) { result.setCatchTotalSortedCarousselWeight(vracBatch.getWeight()); result.setCatchTotalSortedTremisWeight(vracBatch.getWeightBeforeSampling()); - // Vrac > Species + // -- Vrac > Species SortingBatch vracSpeciesBatch = batchTreeHelper.getSpeciesVracRootBatch(vracBatch); -// SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch( -// vracBatch, -// "Vrac > Species", -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); if (vracSpeciesBatch != null) { result.setSpeciesTotalSortedWeight(vracSpeciesBatch.getWeight()); - // Vrac > Species > Inert + // -- Vrac > Species > Inert SortingBatch inertBatch = batchTreeHelper.getSpeciesVracInertRootBatch(vracSpeciesBatch); -// SortingBatch inertBatch = batchHelper.getSortingBatch( -// vracSpeciesBatch, -// "Vrac > Species > Inert", -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT); if (inertBatch != null) { result.setSpeciesTotalInertWeight(inertBatch.getWeight()); } - // Vrac > Species > Alive not itemized + // -- Vrac > Species > Alive not itemized SortingBatch livingNotItemizedBatch = batchTreeHelper.getSpeciesVracAliveNotItemizedRootBatch(vracSpeciesBatch); -// SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch( -// vracSpeciesBatch, -// "Vrac > Species > Alive not itemized", -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED); if (livingNotItemizedBatch != null) { result.setSpeciesTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight()); } } - // Vrac > Benthos + // -- Vrac > Benthos SortingBatch vracBenthosBatch = batchTreeHelper.getBenthosVracRootBatch(vracBatch); -// SortingBatch vracBenthosBatch = batchHelper.getSortingBatch( -// vracBatch, -// "Vrac > Benthos", -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); if (vracBenthosBatch != null) { result.setBenthosTotalSortedWeight(vracBenthosBatch.getWeight()); - // Vrac > Benthos > Inert + // -- Vrac > Benthos > Inert SortingBatch inertBatch = batchTreeHelper.getBenthosVracInertRootBatch(vracBenthosBatch); -// SortingBatch inertBatch = batchHelper.getSortingBatch( -// vracBenthosBatch, -// "Vrac > Benthos > Inert", -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT); if (inertBatch != null) { result.setBenthosTotalInertWeight(inertBatch.getWeight()); } - // Vrac > Benthos > Alive no itemized + // -- Vrac > Benthos > Alive no itemized SortingBatch livingNotItemizedBatch = batchTreeHelper.getBenthosVracAliveNotItemizedRootBatch(vracBenthosBatch); -// SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch( -// vracBenthosBatch, -// "Vrac > Benthos > Alive not itemized", -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED); if (livingNotItemizedBatch != null) { result.setBenthosTotalLivingNotItemizedWeight(livingNotItemizedBatch.getWeight()); @@ -187,52 +158,27 @@ } } - // Hors Vrac + // -- Hors Vrac SortingBatch horsVracBatch = batchTreeHelper.getHorsVracBatch(source); -// SortingBatch horsVracBatch = batchHelper.getSortingBatch( -// source, -// "Hors Vrac", -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_HORS_VRAC_ID); if (horsVracBatch != null) { - // Hors Vrac > Species + // -- Hors Vrac > Species batchTreeHelper.getSpeciesHorsVracRootBatch(horsVracBatch); -// batchHelper.getSortingBatch( -// horsVracBatch, -// "Hors Vrac > Species", -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); - // Hors Vrac > Benthos + // -- Hors Vrac > Benthos batchTreeHelper.getBenthosHorsVracRootBatch(horsVracBatch); -// batchHelper.getSortingBatch( -// horsVracBatch, -// "Hors Vrac > Benthos", -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); - // Hors Vrac > MarineLitter + // -- Hors Vrac > MarineLitter SortingBatch marineLitterBatch = batchTreeHelper.getMarineLitterRootBatch(horsVracBatch); -// SortingBatch marineLitterBatch = batchHelper.getSortingBatch( -// horsVracBatch, -// "Hors Vrac > MarineLitter", -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER); if (marineLitterBatch != null) { result.setMarineLitterTotalWeight(marineLitterBatch.getWeight()); } } - // Non trié + // -- Unsorted SortingBatch unsortedBatch = batchTreeHelper.getRejectedBatch(source); -// SortingBatch unsortedBatch = batchHelper.getSortingBatch( -// source, -// "Unsorted", -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_UNSORTED_ID); if (unsortedBatch != null) { result.setCatchTotalRejectedWeight(unsortedBatch.getWeight()); @@ -248,6 +194,8 @@ Preconditions.checkNotNull(bean.getFishingOperation()); Preconditions.checkNotNull(bean.getFishingOperation().getId()); + bean.setSynchronizationStatus(SynchronizationStatus.DIRTY.getValue()); + fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = fr.ifremer.adagio.core.dao.data.batch.CatchBatch.Factory.newInstance(); catchBatchToEntity(bean, catchBatch); bean = batchHelper.createCatchBatch(bean, catchBatch); @@ -273,6 +221,8 @@ Preconditions.checkNotNull(bean.getFishingOperation()); Preconditions.checkNotNull(bean.getFishingOperation().getId()); + bean.setSynchronizationStatus(SynchronizationStatus.DIRTY.getValue()); + getCurrentSession().enableFetchProfile("batch-with-childs"); getCurrentSession().setFlushMode(FlushMode.COMMIT); fr.ifremer.adagio.core.dao.data.batch.CatchBatch catchBatch = load(CatchBatchImpl.class, bean.getIdAsInt()); @@ -316,8 +266,13 @@ target.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); target.setRankOrder((short) 1); - target.setSynchronizationStatus(SynchronizationStatus.DIRTY.getValue()); + // SynchronizationStatus + String synchronizationStatus = SynchronizationStatus.DIRTY.getValue(); + target.setSynchronizationStatus(synchronizationStatus); + target.getFishingOperation().getFishingTrip().setSynchronizationStatus(synchronizationStatus); + target.getFishingOperation().getFishingTrip().getScientificCruise().setSynchronizationStatus(synchronizationStatus); + // Create lists to store all updates, then remove not updated items Collection<QuantificationMeasurement> quantificationMeasurements = target.getQuantificationMeasurements(); Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet(); @@ -340,10 +295,8 @@ } SortingBatch vracBatch = batchTreeHelper.getVracBatch(target); -// SortingBatch vracBatch = batchHelper.getVracBatch(target); SortingBatch horsVracBatch = batchTreeHelper.getHorsVracBatch(target); -// SortingBatch horsVracBatch = batchHelper.getHorsVracBatch(target); SortingBatch horsVracSpeciesRootBatch = null; SortingBatch horsVracBenthosRootBatch = null; @@ -352,11 +305,8 @@ if (horsVracBatch != null) { horsVracSpeciesRootBatch = batchTreeHelper.getSpeciesHorsVracRootBatch(horsVracBatch); -// horsVracSpeciesRootBatch = batchHelper.getSpeciesHorsVracRootBatch(horsVracBatch); horsVracBenthosRootBatch = batchTreeHelper.getBenthosHorsVracRootBatch(horsVracBatch); -// horsVracBenthosRootBatch = batchHelper.getBenthosHorsVracRootBatch(horsVracBatch); horsVracMarineLitterRootBatch = batchTreeHelper.getMarineLitterRootBatch(horsVracBatch); -// horsVracMarineLitterRootBatch = batchHelper.getMarineLitterRootBatch(horsVracBatch); } SortingBatch speciesVracBatch = null; @@ -371,26 +321,18 @@ if (vracBatch != null) { speciesVracBatch = batchTreeHelper.getSpeciesVracRootBatch(vracBatch); -// speciesVracBatch = batchHelper.getSpeciesVracRootBatch(vracBatch); if (speciesVracBatch != null) { speciesVracAliveNotItemizeRootBatch = batchTreeHelper.getSpeciesVracAliveNotItemizedRootBatch(speciesVracBatch); -// speciesVracAliveNotItemizeRootBatch = batchHelper.getSpeciesVracAliveNotItemizedRootBatch(speciesVracBatch); speciesVracInertRootBatch = batchTreeHelper.getSpeciesVracInertRootBatch(speciesVracBatch); -// speciesVracInertRootBatch = batchHelper.getSpeciesVracInertRootBatch(speciesVracBatch); speciesVracAliveItemizeRootBatch = batchTreeHelper.getSpeciesVracAliveItemizedRootBatch(speciesVracBatch); -// speciesVracAliveItemizeRootBatch = batchHelper.getSpeciesVracAliveItemizeRootBatch(speciesVracBatch); } benthosVracBatch = batchTreeHelper.getBenthosVracRootBatch(vracBatch); -// benthosVracBatch = batchHelper.getBenthosVracRootBatch(vracBatch); if (benthosVracBatch != null) { benthosVracAliveNotItemizeRootBatch = batchTreeHelper.getBenthosVracAliveNotItemizedRootBatch(benthosVracBatch); -// benthosVracAliveNotItemizeRootBatch = batchHelper.getBenthosVracAliveNotItemizedRootBatch(benthosVracBatch); benthosVracInertRootBatch = batchTreeHelper.getBenthosVracInertRootBatch(benthosVracBatch); -// benthosVracInertRootBatch = batchHelper.getBenthosVracInertRootBatch(benthosVracBatch); benthosVracAliveItemizeRootBatch = batchTreeHelper.getBenthosVracAliveItemizedRootBatch(benthosVracBatch); -// benthosVracAliveItemizeRootBatch = batchHelper.getBenthosVracAliveItemizeRootBatch(benthosVracBatch); } } @@ -435,33 +377,23 @@ boolean needUnsorted = batchTreeHelper.getRejectedBatch(target) != null || source.getCatchTotalRejectedWeight() != null; -// boolean needUnsorted = batchHelper.getRejectedBatch(target) != null || - // --------------------------------------------------------------------- - // Vrac - // --------------------------------------------------------------------- - if (needVrac) { - + // -- Vrac vracBatch = batchTreeHelper.getOrCreateVracBatch( target, source.getCatchTotalSortedCarousselWeight(), source.getCatchTotalSortedTremisWeight()); if (needVracSpecies) { - - // --------------------------------------------------------------------- - // Vrac / Species - // --------------------------------------------------------------------- + // -- Vrac > Species speciesVracBatch = batchTreeHelper.getOrCreateSpeciesVracRootBatch( target, vracBatch, source.getSpeciesTotalSortedWeight()); if (needVracSpeciesAliveNotItemized) { - // --------------------------------------------------------------------- - // Vrac / Species / Alive not itemized - // --------------------------------------------------------------------- + // -- Vrac > Species > Alive not itemized batchTreeHelper.getOrCreateSpeciesVracAliveNotItemizedRootBatch( target, speciesVracBatch, @@ -469,9 +401,7 @@ } if (needVracSpeciesInert) { - // --------------------------------------------------------------------- - // Vrac / Species / Inert (not alive) - // --------------------------------------------------------------------- + // -- Vrac > Species > Inert (not alive) batchTreeHelper.getOrCreateSpeciesVracInertRootBatch( target, speciesVracBatch, @@ -479,9 +409,7 @@ } if (needVracSpeciesAliveItemized) { - // --------------------------------------------------------------------- - // Vrac / Species / Alive itemized - // --------------------------------------------------------------------- + // -- Vrac > Species > Alive itemized batchTreeHelper.getOrCreateSpeciesVracAliveItemizedRootBatch( target, speciesVracBatch); @@ -489,19 +417,14 @@ } if (needVracBenthos) { - - // --------------------------------------------------------------------- - // Vrac > Benthos - // --------------------------------------------------------------------- + // -- Vrac > Benthos benthosVracBatch = batchTreeHelper.getOrCreateBenthosVracRootBatch( target, vracBatch, source.getBenthosTotalSortedWeight()); if (needVracBenthosAliveNotItemized) { - // --------------------------------------------------------------------- - // Vrac / Benthos / Alive not itemized - // --------------------------------------------------------------------- + // -- Vrac > Benthos > Alive not itemized batchTreeHelper.getOrCreateBenthosVracAliveNotItemizedRootBatch( target, benthosVracBatch, @@ -509,9 +432,7 @@ } if (needVracBenthosInert) { - // --------------------------------------------------------------------- - // Vrac / Benthos / Inert (not alive) - // --------------------------------------------------------------------- + // -- Vrac > Benthos > Inert (not alive) batchTreeHelper.getOrCreateBenthosVracInertRootBatch( target, benthosVracBatch, @@ -519,9 +440,7 @@ } if (needVracBenthosAliveItemized) { - // --------------------------------------------------------------------- - // Vrac / Benthos / Alive itemized - // --------------------------------------------------------------------- + // -- Vrac > Benthos > Alive itemized batchTreeHelper.getOrCreateBenthosVracAliveItemizedRootBatch( target, benthosVracBatch); @@ -531,34 +450,25 @@ } if (needHorsVrac) { - - // --------------------------------------------------------------------- - // Hors Vrac - // --------------------------------------------------------------------- + // -- Hors Vrac horsVracBatch = batchTreeHelper.getOrCreateHorsVracBatch(target); if (needHorsVracSpecies) { - // --------------------------------------------------------------------- - // Hors Vrac > Species - // --------------------------------------------------------------------- + // -- Hors Vrac > Species batchTreeHelper.getOrCreateSpeciesHorsVracRootBatch( target, horsVracBatch); } if (needHorsVracBenthos) { - // --------------------------------------------------------------------- - // Hors Vrac > Benthos - // --------------------------------------------------------------------- + // -- Hors Vrac > Benthos batchTreeHelper.getOrCreateBenthosHorsVracRootBatch( target, horsVracBatch); } if (needHorsVracMarineLitter) { - // --------------------------------------------------------------------- - // Hors Vrac > MarineLitter - // --------------------------------------------------------------------- + // -- Hors Vrac > MarineLitter batchTreeHelper.getOrCreateMarineLitterRootBatch( target, horsVracBatch, @@ -567,9 +477,7 @@ } if (needUnsorted) { - // --------------------------------------------------------------------- - // Unsorted (=rejected) - // --------------------------------------------------------------------- + // -- Unsorted (=rejected) batchTreeHelper.getOrCreateRejectedBatch( target, source.getCatchTotalRejectedWeight()); } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -34,7 +34,6 @@ import fr.ifremer.adagio.core.dao.administration.user.PersonDao; import fr.ifremer.adagio.core.dao.administration.user.PersonImpl; import fr.ifremer.adagio.core.dao.data.measure.GearPhysicalMeasurement; -import fr.ifremer.adagio.core.dao.data.measure.SurveyMeasurement; import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip; import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.ObservedFishingTrip; import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise; @@ -51,12 +50,9 @@ import fr.ifremer.adagio.core.dao.referential.location.Location; import fr.ifremer.adagio.core.dao.referential.location.LocationDao; import fr.ifremer.adagio.core.dao.referential.location.LocationImpl; -import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm; import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmDao; -import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmImpl; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueDao; -import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl; import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus; import fr.ifremer.tutti.persistence.dao.GearPhysicalFeaturesDaoTutti; import fr.ifremer.tutti.persistence.entities.CaracteristicMap; @@ -151,6 +147,12 @@ @Resource(name = "gearPhysicalFeaturesDaoTutti") protected GearPhysicalFeaturesDaoTutti gearPhysicalFeaturesDao; + @Resource(name = "measurementPersistenceHelper") + protected MeasurementPersistenceHelper measurementPersistenceHelper; + + @Resource(name = "synchronizationStatusHelper") + protected SynchronizationStatusHelper synchronizationStatusHelper; + @Override public List<Cruise> getAllCruise(String programId) { Iterator<Object[]> list = queryList( @@ -164,6 +166,7 @@ target.setId(String.valueOf(source[0])); target.setName((String) source[1]); target.setBeginDate((Date) source[2]); + target.setSynchronizationStatus((String) source[3]); result.add(target); } return Collections.unmodifiableList(result); @@ -202,13 +205,18 @@ // name result.setName((String) source[index++]); + // begin Date result.setBeginDate((Date) source[index++]); + + // end Date result.setEndDate((Date) source[index++]); + // vessel String vesselCode = (String) source[index++]; Vessel vessel = referentialService.getVessel(vesselCode); result.setVessel(vessel); + // head of sort room List<Person> headOfMissions = Lists.newArrayList(); result.setHeadOfMission(headOfMissions); List<Person> headOfSortRoom = Lists.newArrayList(); @@ -218,9 +226,13 @@ Person manager = referentialService.getPerson(managerId); headOfMissions.add(manager); + // comment result.setComment((String) source[index++]); - // load surverPart + // synchronizationStatus + result.setSynchronizationStatus((String) source[index++]); + + // surverPart result.setSurveyPart((String) source[index]); // get secondary gears from fishingOperation (first load from Allegro DB only) @@ -291,6 +303,7 @@ scientificCruiseDao.create(scientificCruise); bean.setId(String.valueOf(scientificCruise.getId())); + bean.setSynchronizationStatus(scientificCruise.getSynchronizationStatus()); return bean; } @@ -314,10 +327,6 @@ "Could not retrieve cruise with id=" + bean.getId()); } -// boolean vesselChanged = ObjectUtils.notEqual( -// bean.getVessel().getId(), -// scientificCruise.getVessel().getCode()); - cruiseToEntity(bean, scientificCruise); scientificCruiseDao.update(scientificCruise); @@ -361,6 +370,7 @@ } } + bean.setSynchronizationStatus(scientificCruise.getSynchronizationStatus()); return bean; } @@ -546,7 +556,7 @@ // Retrieve entities : FishingTrip ObservedFishingTrip fishingTrip; - if (target.getFishingTrips() == null || target.getFishingTrips().size() == 0) { + if (CollectionUtils.isEmpty(target.getFishingTrips())) { fishingTrip = ObservedFishingTrip.Factory.newInstance(); if (target.getFishingTrips() == null) { target.setFishingTrips(Lists.newArrayList((FishingTrip) fishingTrip)); @@ -585,7 +595,6 @@ } // Default values : - target.setSynchronizationStatus(SynchronizationStatus.DIRTY.getValue()); if (target.getCreationDate() == null) { target.setCreationDate(newCreateDate()); } @@ -602,9 +611,11 @@ fishingTrip.setRecorderPerson(target.getRecorderPerson()); fishingTrip.setRecorderDepartment(target.getRecorderDepartment()); fishingTrip.setCreationDate(target.getCreationDate()); - fishingTrip.setSynchronizationStatus(target.getSynchronizationStatus()); fishingTrip.setQualityFlag(qualityFlagNotQualified); + // SynchronizationStatus + synchronizationStatusHelper.setDirty(fishingTrip); + // DepartureLocation Location departureLocation = load(LocationImpl.class, Integer.valueOf(source.getDepartureLocation().getId())); fishingTrip.setDepartureLocation(departureLocation); @@ -616,11 +627,11 @@ if (StringUtils.isEmpty(source.getSurveyPart())) { // remove surveyMeasurement if exists - removeSurveyMeasurement(fishingTrip, enumeration.PMFM_ID_SURVEY_PART); + measurementPersistenceHelper.removeSurveyMeasurement(fishingTrip, enumeration.PMFM_ID_SURVEY_PART); } else { // update it or create it - setSurveyMeasurement(fishingTrip, enumeration.PMFM_ID_SURVEY_PART, null, source.getSurveyPart(), null); + measurementPersistenceHelper.setSurveyMeasurement(fishingTrip, enumeration.PMFM_ID_SURVEY_PART, null, source.getSurveyPart(), null); } // Gear @@ -755,82 +766,82 @@ fishingTrip.getVesselPersonFeatures().addAll(vesselPersonFeaturesMap.values()); } - protected SurveyMeasurement getSurveyMeasurement(FishingTrip fishingTrip, - Integer pmfmId) { - SurveyMeasurement result = null; - - for (SurveyMeasurement vum : fishingTrip.getSurveyMeasurements()) { - if (pmfmId.equals(vum.getPmfm().getId())) { - result = vum; - break; - } - } - - return result; - } - - protected SurveyMeasurement createSurveyMeasurement(FishingTrip fishingTrip, - Integer pmfmId, - Float numericalValue, - String alphanumericalValue, - Integer qualitativevalueId) { - - SurveyMeasurement result = SurveyMeasurement.Factory.newInstance(); - result.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); - result.setDepartment(fishingTrip.getRecorderDepartment()); - Pmfm pmfm = load(PmfmImpl.class, pmfmId); - result.setPmfm(pmfm); - result.setFishingTrip(fishingTrip); - - if (alphanumericalValue != null) { - result.setAlphanumericalValue(alphanumericalValue); - } else if (numericalValue != null) { - result.setNumericalValue(numericalValue); - } else if (qualitativevalueId != null) { - result.setQualitativeValue(load(QualitativeValueImpl.class, qualitativevalueId)); - } - - // add it to fishingTrip - if (fishingTrip.getSurveyMeasurements() == null) { - - //create new set of measurements - fishingTrip.setSurveyMeasurements(Sets.<SurveyMeasurement>newHashSet()); - } - - fishingTrip.getSurveyMeasurements().add(result); - - return result; - } - - protected SurveyMeasurement setSurveyMeasurement(FishingTrip fishingTrip, - Integer pmfmId, - Float numericalValue, - String alphanumericalValue, - Integer qualitativevalueId) { - SurveyMeasurement result = getSurveyMeasurement(fishingTrip, pmfmId); - - if (result == null) { - result = createSurveyMeasurement(fishingTrip, - pmfmId, - numericalValue, - alphanumericalValue, - qualitativevalueId); - } - - return result; - } - - protected SurveyMeasurement removeSurveyMeasurement(FishingTrip fishingTrip, - Integer pmfmId) { - SurveyMeasurement result = getSurveyMeasurement(fishingTrip, pmfmId); - - if (result != null) { - - // measurement found, remove it - result.setFishingTrip(null); - fishingTrip.getSurveyMeasurements().remove(result); - } - - return result; - } +// public SurveyMeasurement getSurveyMeasurement(FishingTrip fishingTrip, +// Integer pmfmId) { +// SurveyMeasurement result = null; +// +// for (SurveyMeasurement vum : fishingTrip.getSurveyMeasurements()) { +// if (pmfmId.equals(vum.getPmfm().getId())) { +// result = vum; +// break; +// } +// } +// +// return result; +// } +// +// protected SurveyMeasurement createSurveyMeasurement(FishingTrip fishingTrip, +// Integer pmfmId, +// Float numericalValue, +// String alphanumericalValue, +// Integer qualitativevalueId) { +// +// SurveyMeasurement result = SurveyMeasurement.Factory.newInstance(); +// result.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); +// result.setDepartment(fishingTrip.getRecorderDepartment()); +// Pmfm pmfm = load(PmfmImpl.class, pmfmId); +// result.setPmfm(pmfm); +// result.setFishingTrip(fishingTrip); +// +// if (alphanumericalValue != null) { +// result.setAlphanumericalValue(alphanumericalValue); +// } else if (numericalValue != null) { +// result.setNumericalValue(numericalValue); +// } else if (qualitativevalueId != null) { +// result.setQualitativeValue(load(QualitativeValueImpl.class, qualitativevalueId)); +// } +// +// // add it to fishingTrip +// if (fishingTrip.getSurveyMeasurements() == null) { +// +// //create new set of measurements +// fishingTrip.setSurveyMeasurements(Sets.<SurveyMeasurement>newHashSet()); +// } +// +// fishingTrip.getSurveyMeasurements().add(result); +// +// return result; +// } +// +// protected SurveyMeasurement setSurveyMeasurement(FishingTrip fishingTrip, +// Integer pmfmId, +// Float numericalValue, +// String alphanumericalValue, +// Integer qualitativevalueId) { +// SurveyMeasurement result = getSurveyMeasurement(fishingTrip, pmfmId); +// +// if (result == null) { +// result = createSurveyMeasurement(fishingTrip, +// pmfmId, +// numericalValue, +// alphanumericalValue, +// qualitativevalueId); +// } +// +// return result; +// } +// +// protected SurveyMeasurement removeSurveyMeasurement(FishingTrip fishingTrip, +// Integer pmfmId) { +// SurveyMeasurement result = getSurveyMeasurement(fishingTrip, pmfmId); +// +// if (result != null) { +// +// // measurement found, remove it +// result.setFishingTrip(null); +// fishingTrip.getSurveyMeasurements().remove(result); +// } +// +// return result; +// } } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -62,6 +62,7 @@ import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmImpl; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl; +import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus; import fr.ifremer.adagio.core.service.referential.location.LocationService; import fr.ifremer.tutti.persistence.dao.GearPhysicalFeaturesDaoTutti; import fr.ifremer.tutti.persistence.entities.CaracteristicMap; @@ -153,6 +154,9 @@ @Resource(name = "locationDao") protected LocationExtendDao locationDao; + @Resource(name = "synchronizationStatusHelper") + protected SynchronizationStatusHelper synchronizationStatusHelper; + protected static Float DEFAULT_EMPTY_LATITUDE = 0.0001f; protected static Float DEFAULT_EMPTY_LONGITUDE = 0.0001f; @@ -218,6 +222,9 @@ fishingOperation.setFishingOperationNumber(Integer.valueOf(name)); } + // SynchronizationStatus + fishingOperation.setSynchronizationStatus((String)source[colIndex++]); + // If not found, compute it using a counter (see "order by startDateTime" in HQL query) if (fishingOperation.getFishingOperationNumber() == null) { fishingOperation.setFishingOperationNumber(fishingOperationRankOrder); @@ -276,6 +283,10 @@ if (StringUtils.isNotBlank(name)) { result.setFishingOperationNumber(Integer.valueOf(name)); } + + // SynchronizationStatus + result.setSynchronizationStatus((String)source[colIndex++]); + Short rankOrder = (Short) source[colIndex++]; // If not found, compute it using a counter (see "order by startDateTime" in HQL query) @@ -736,6 +747,12 @@ // Link to parent fishing trip target.setFishingTrip(fishingTrip); + // SynchronizationStatus + String synchronizationStatus = SynchronizationStatus.DIRTY.getValue(); + fishingTrip.setSynchronizationStatus(synchronizationStatus); + scientificCruise.setSynchronizationStatus(synchronizationStatus); + + // Retrieve entities : VesselPosition (start and end) VesselPosition startPosition = null; VesselPosition endPosition = null; @@ -881,7 +898,7 @@ } // Store into Gear Use Features - GearUseMeasurement gum = setGearUseMeasurement(scientificCruise, gearUseFeatures, enumeration.PMFM_ID_MULTIRIG_AGGREGATION, null, source.getMultirigAggregation(), null); + GearUseMeasurement gum = measurementPersistenceHelper.setGearUseMeasurement(scientificCruise, gearUseFeatures, enumeration.PMFM_ID_MULTIRIG_AGGREGATION, null, source.getMultirigAggregation(), null); notChangedGearUseMeasurements.remove(gum); } @@ -1100,7 +1117,7 @@ CaracteristicMap gearUseCaracteristics = source.getGearUseFeatures(); if (MapUtils.isNotEmpty(gearUseCaracteristics)) { for (Caracteristic caracteristic : gearUseCaracteristics.keySet()) { - GearUseMeasurement gum = setGearUseMeasurement( + GearUseMeasurement gum = measurementPersistenceHelper.setGearUseMeasurement( scientificCruise, gearUseFeatures, caracteristic, @@ -1318,63 +1335,63 @@ return vesselUseMeasurement; } - protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, - Integer pmfmId, - Float numericalValue, - String alphanumericalValue, - Integer qualitativevalueId) { - GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, pmfmId, true); +// protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, +// Integer pmfmId, +// Float numericalValue, +// String alphanumericalValue, +// Integer qualitativevalueId) { +// GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, pmfmId, true); +// +// if (alphanumericalValue != null) { +// gearUseMeasurement.setAlphanumericalValue(alphanumericalValue); +// } else if (numericalValue != null) { +// gearUseMeasurement.setNumericalValue(numericalValue); +// } else if (qualitativevalueId != null) { +// QualitativeValue qv = load(QualitativeValueImpl.class, qualitativevalueId); +// gearUseMeasurement.setQualitativeValue(qv); +// } +// +// return gearUseMeasurement; +// } - if (alphanumericalValue != null) { - gearUseMeasurement.setAlphanumericalValue(alphanumericalValue); - } else if (numericalValue != null) { - gearUseMeasurement.setNumericalValue(numericalValue); - } else if (qualitativevalueId != null) { - QualitativeValue qv = load(QualitativeValueImpl.class, qualitativevalueId); - gearUseMeasurement.setQualitativeValue(qv); - } +// protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, +// Caracteristic caracteristic, Serializable value) { +// GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, Integer.valueOf(caracteristic.getId()), true); +// measurementPersistenceHelper.setMeasurement(gearUseMeasurement, caracteristic, value); +// return gearUseMeasurement; +// } +// +// protected GearUseMeasurement getGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, +// Integer pmfmId, boolean createIfNotExists) { +// GearUseMeasurement gearUseMeasurement = null; +// if (gearUseFeatures.getGearUseMeasurements() != null) { +// for (GearUseMeasurement vum : gearUseFeatures.getGearUseMeasurements()) { +// if (pmfmId.equals(vum.getPmfm().getId())) { +// gearUseMeasurement = vum; +// break; +// } +// } +// } +// if (gearUseMeasurement == null) { +// if (!createIfNotExists) { +// return null; +// } +// gearUseMeasurement = GearUseMeasurement.Factory.newInstance(); +// gearUseMeasurement.setGearUseFeatures(gearUseFeatures); +// if (gearUseFeatures.getGearUseMeasurements() == null) { +// gearUseFeatures.setGearUseMeasurements(Sets.newHashSet(gearUseMeasurement)); +// } else { +// gearUseFeatures.getGearUseMeasurements().add(gearUseMeasurement); +// } +// gearUseMeasurement.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); +// gearUseMeasurement.setDepartment(scientificCruise.getRecorderDepartment()); +// Pmfm pmfm = (Pmfm) getCurrentSession().load(PmfmImpl.class, pmfmId); +// gearUseMeasurement.setPmfm(pmfm); +// } +// +// return gearUseMeasurement; +// } - return gearUseMeasurement; - } - - protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, - Caracteristic caracteristic, Serializable value) { - GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, Integer.valueOf(caracteristic.getId()), true); - measurementPersistenceHelper.setMeasurement(gearUseMeasurement, caracteristic, value); - return gearUseMeasurement; - } - - protected GearUseMeasurement getGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, - Integer pmfmId, boolean createIfNotExists) { - GearUseMeasurement gearUseMeasurement = null; - if (gearUseFeatures.getGearUseMeasurements() != null) { - for (GearUseMeasurement vum : gearUseFeatures.getGearUseMeasurements()) { - if (pmfmId.equals(vum.getPmfm().getId())) { - gearUseMeasurement = vum; - break; - } - } - } - if (gearUseMeasurement == null) { - if (!createIfNotExists) { - return null; - } - gearUseMeasurement = GearUseMeasurement.Factory.newInstance(); - gearUseMeasurement.setGearUseFeatures(gearUseFeatures); - if (gearUseFeatures.getGearUseMeasurements() == null) { - gearUseFeatures.setGearUseMeasurements(Sets.newHashSet(gearUseMeasurement)); - } else { - gearUseFeatures.getGearUseMeasurements().add(gearUseMeasurement); - } - gearUseMeasurement.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); - gearUseMeasurement.setDepartment(scientificCruise.getRecorderDepartment()); - Pmfm pmfm = (Pmfm) getCurrentSession().load(PmfmImpl.class, pmfmId); - gearUseMeasurement.setPmfm(pmfm); - } - - return gearUseMeasurement; - } - protected void setOperationVesselAssociation(Operation target, List<String> vesselCodes) { boolean noOperationVesselAssociations = Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -82,6 +82,9 @@ @Resource(name = "batchPersistenceHelper") protected BatchPersistenceHelper batchHelper; + @Resource(name = "synchronizationStatusHelper") + protected SynchronizationStatusHelper synchronizationStatusHelper; + @Override public List<IndividualObservationBatch> getAllIndividualObservationBatch(String fishingOperationId) { Preconditions.checkNotNull(fishingOperationId); @@ -118,6 +121,9 @@ // Comment batch.setComment((String) source[colIndex]); + // synchronizationStatus + batch.setSynchronizationStatus((String) source[colIndex]); + // Sample Measurements batch.setCaracteristics(new CaracteristicMap()); Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementPersistenceHelper.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementPersistenceHelper.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementPersistenceHelper.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -25,12 +25,21 @@ */ import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; import fr.ifremer.adagio.core.dao.data.batch.Batch; import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao; import fr.ifremer.adagio.core.dao.data.batch.SortingBatch; +import fr.ifremer.adagio.core.dao.data.measure.GearUseMeasurement; import fr.ifremer.adagio.core.dao.data.measure.Measurement; import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement; import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement; +import fr.ifremer.adagio.core.dao.data.measure.SurveyMeasurement; +import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip; +import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise; +import fr.ifremer.adagio.core.dao.data.vessel.feature.use.GearUseFeatures; +import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl; +import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm; +import fr.ifremer.adagio.core.dao.referential.pmfm.PmfmImpl; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValue; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; @@ -82,6 +91,10 @@ } } + //------------------------------------------------------------------------// + //-- SortingMeasurement --// + //------------------------------------------------------------------------// + public SortingMeasurement setSortingMeasurement( SortingBatch sortingBatch, Integer pmfmId, @@ -111,6 +124,170 @@ return catchBatchDao.getInheritedSortingMeasurement(sortingBatch, enumeration.PMFM_ID_SORTED_UNSORTED); } + //------------------------------------------------------------------------// + //-- GearUseMeasurement --// + //------------------------------------------------------------------------// + + public GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, + Integer pmfmId, + Float numericalValue, + String alphanumericalValue, + Integer qualitativevalueId) { + GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, pmfmId, true); + + if (alphanumericalValue != null) { + gearUseMeasurement.setAlphanumericalValue(alphanumericalValue); + } else if (numericalValue != null) { + gearUseMeasurement.setNumericalValue(numericalValue); + } else if (qualitativevalueId != null) { + QualitativeValue qv = load(QualitativeValueImpl.class, qualitativevalueId); + gearUseMeasurement.setQualitativeValue(qv); + } + + return gearUseMeasurement; + } + + protected GearUseMeasurement setGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, + Caracteristic caracteristic, Serializable value) { + GearUseMeasurement gearUseMeasurement = getGearUseMeasurement(scientificCruise, gearUseFeatures, Integer.valueOf(caracteristic.getId()), true); + setMeasurement(gearUseMeasurement, caracteristic, value); + return gearUseMeasurement; + } + + protected GearUseMeasurement getGearUseMeasurement(ScientificCruise scientificCruise, GearUseFeatures gearUseFeatures, + Integer pmfmId, boolean createIfNotExists) { + GearUseMeasurement gearUseMeasurement = null; + if (gearUseFeatures.getGearUseMeasurements() != null) { + for (GearUseMeasurement vum : gearUseFeatures.getGearUseMeasurements()) { + if (pmfmId.equals(vum.getPmfm().getId())) { + gearUseMeasurement = vum; + break; + } + } + } + if (gearUseMeasurement == null) { + if (!createIfNotExists) { + return null; + } + gearUseMeasurement = GearUseMeasurement.Factory.newInstance(); + gearUseMeasurement.setGearUseFeatures(gearUseFeatures); + if (gearUseFeatures.getGearUseMeasurements() == null) { + gearUseFeatures.setGearUseMeasurements(Sets.newHashSet(gearUseMeasurement)); + } else { + gearUseFeatures.getGearUseMeasurements().add(gearUseMeasurement); + } + gearUseMeasurement.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); + gearUseMeasurement.setDepartment(scientificCruise.getRecorderDepartment()); + Pmfm pmfm = (Pmfm) getCurrentSession().load(PmfmImpl.class, pmfmId); + gearUseMeasurement.setPmfm(pmfm); + } + + return gearUseMeasurement; + } + + + //------------------------------------------------------------------------// + //-- Misc --// + //------------------------------------------------------------------------// + + public String toString(Measurement measurement) { + Pmfm pmfm = load(PmfmImpl.class, measurement.getPmfm().getId()); + String value = null; + if (measurement.getQualitativeValue() != null) { + QualitativeValue qualitativeValue = measurement.getQualitativeValue(); + String qualitativeName = load(QualitativeValueImpl.class, qualitativeValue.getId()).getName(); + + value = qualitativeName + " (" + qualitativeValue.getId() + ")"; + } else if (measurement.getNumericalValue() != null) { + value = "" + measurement.getNumericalValue(); + } else if (measurement.getAlphanumericalValue() != null) { + value = measurement.getAlphanumericalValue(); + } + return pmfm.getParameter().getName() + " (" + pmfm.getId() + ") / " + value; + } + + //------------------------------------------------------------------------// + //-- SurveyMeasurement --// + //------------------------------------------------------------------------// + + public SurveyMeasurement setSurveyMeasurement(FishingTrip fishingTrip, + Integer pmfmId, + Float numericalValue, + String alphanumericalValue, + Integer qualitativevalueId) { + SurveyMeasurement result = getSurveyMeasurement(fishingTrip, pmfmId); + + if (result == null) { + result = createSurveyMeasurement(fishingTrip, + pmfmId, + numericalValue, + alphanumericalValue, + qualitativevalueId); + } + + return result; + } + + public SurveyMeasurement removeSurveyMeasurement(FishingTrip fishingTrip, + Integer pmfmId) { + SurveyMeasurement result = getSurveyMeasurement(fishingTrip, pmfmId); + + if (result != null) { + + // measurement found, remove it + result.setFishingTrip(null); + fishingTrip.getSurveyMeasurements().remove(result); + } + + return result; + } + + protected SurveyMeasurement createSurveyMeasurement(FishingTrip fishingTrip, + Integer pmfmId, + Float numericalValue, + String alphanumericalValue, + Integer qualitativevalueId) { + + SurveyMeasurement result = SurveyMeasurement.Factory.newInstance(); + result.setQualityFlag(load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED)); + result.setDepartment(fishingTrip.getRecorderDepartment()); + Pmfm pmfm = load(PmfmImpl.class, pmfmId); + result.setPmfm(pmfm); + result.setFishingTrip(fishingTrip); + + if (alphanumericalValue != null) { + result.setAlphanumericalValue(alphanumericalValue); + } else if (numericalValue != null) { + result.setNumericalValue(numericalValue); + } else if (qualitativevalueId != null) { + result.setQualitativeValue(load(QualitativeValueImpl.class, qualitativevalueId)); + } + + // add it to fishingTrip + if (fishingTrip.getSurveyMeasurements() == null) { + + //create new set of measurements + fishingTrip.setSurveyMeasurements(Sets.<SurveyMeasurement>newHashSet()); + } + + fishingTrip.getSurveyMeasurements().add(result); + + return result; + } + + protected SurveyMeasurement getSurveyMeasurement(FishingTrip fishingTrip, Integer pmfmId) { + SurveyMeasurement result = null; + + for (SurveyMeasurement vum : fishingTrip.getSurveyMeasurements()) { + if (pmfmId.equals(vum.getPmfm().getId())) { + result = vum; + break; + } + } + + return result; + } + protected Integer getRecorderDepartmentId() { // TODO BL : voir si on peut récupérer le departement (du 1er saisisseur ?) return enumeration.DEPARTMENT_ID_UNKNOWN_RECORDER_DEPARTMENT; Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -28,7 +28,6 @@ import fr.ifremer.tutti.persistence.InvalidBatchModelException; import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -55,14 +54,14 @@ * <p/> * <strong>Note:</strong> All childs of the batch should be loaded here. * - * @param fishingOperationId if of the fishing operation to seek - * @param sampleCategoryModel [optional] sample category model to check + * @param fishingOperationId if of the fishing operation to seek + * @param validateTree flag to validate sample category model * @return the list of root {@link SpeciesBatch} * @throws InvalidBatchModelException if batch does not respect the sample category model * @since 2.4 */ BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, - SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException; + boolean validateTree) throws InvalidBatchModelException; @Transactional(readOnly = false) SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId); @@ -87,7 +86,7 @@ void changeSpeciesBatchSpecies(String batchId, Species species); //------------------------------------------------------------------------// - //-- SpeciesBatchFrequency methods (for species) --// + //-- SpeciesBatchFrequency methods --// //------------------------------------------------------------------------// /** Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -45,18 +45,15 @@ import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequencys; 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.service.batch.BatchPersistenceHelper; import fr.ifremer.tutti.persistence.service.batch.BatchTreeHelper; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import javax.annotation.Resource; -import java.io.Serializable; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -90,40 +87,26 @@ @Resource(name = "measurementPersistenceHelper") protected MeasurementPersistenceHelper measurementPersistenceHelper; - protected SampleCategoryModel sampleCategoryModel; - - @Override - public void init() { - super.init(); - - sampleCategoryModel = config.getSampleCategoryModel(); - } - //------------------------------------------------------------------------// //-- SpeciesBatch methods --// //------------------------------------------------------------------------// @Override public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, - SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException { + boolean validateTree) throws InvalidBatchModelException { Preconditions.checkNotNull(fishingOperationId); CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false); - // Vrac / Species + // -- Vrac > Species > Alive Itemized SortingBatch vracSpeciesBatch = batchTreeHelper.getSpeciesVracAliveItemizedRootBatch(catchBatch); -// SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch( -// catchBatch, -// "Vrac > Species > Alive Itemized", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, -// enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED -// ); // container of speciesBatch is arbitraty put on vrac type (there is // no common ancestor for all species batch). - BatchContainer<SpeciesBatch> result = new BatchContainer<SpeciesBatch>(); + BatchContainer<SpeciesBatch> result = new BatchContainer<>(); + SampleCategoryModel sampleCategoryModel = getSampleCategoryModel(); + if (vracSpeciesBatch != null) { result.setId(vracSpeciesBatch.getId()); @@ -141,7 +124,8 @@ } SpeciesBatch target = SpeciesBatchs.newSpeciesBatch(); target.setSpecies(species); - entityToSpeciesBatch(source, target); + + entityToSpeciesBatch(sampleCategoryModel, source, target); result.addChildren(target); if (log.isDebugEnabled()) { @@ -150,13 +134,9 @@ } } - // Hors-Vrac / Species + // -- Hors Vrac > Species SortingBatch horsVracSpeciesBatch = batchTreeHelper.getSpeciesHorsVracRootBatch(catchBatch); -// SortingBatch horsVracSpeciesBatch = batchHelper.getSortingBatch( -// catchBatch, -// "Hors Vrac > Species", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + if (horsVracSpeciesBatch != null) { for (Batch batch : horsVracSpeciesBatch.getChildBatchs()) { SortingBatch source = (SortingBatch) batch; @@ -171,7 +151,7 @@ } SpeciesBatch target = SpeciesBatchs.newSpeciesBatch(); target.setSpecies(species); - entityToSpeciesBatch(source, target); + entityToSpeciesBatch(sampleCategoryModel, source, target); result.addChildren(target); if (log.isDebugEnabled()) { log.debug("Loaded CatchBatch Hors Vrac > Species > " + target.getSpecies().getReferenceTaxonId() + ": " + target.getId()); @@ -179,7 +159,7 @@ } } - if (sampleCategoryModel != null) { + if (validateTree) { // validate with given sample category model batchHelper.validateSpecies(sampleCategoryModel, result); @@ -235,30 +215,7 @@ @Override public void deleteSpeciesSubBatch(String id) { - Preconditions.checkNotNull(id); - - Integer speciesBatchId = Integer.valueOf(id); - - CatchBatch catchBatch = batchHelper.getRootCatchBatchByBatchId(speciesBatchId); - SortingBatch sortingBatch = batchHelper.getSortingBatchById( - catchBatch, speciesBatchId); - - // get his children - Collection<Batch> childBatchs = sortingBatch.getChildBatchs(); - - if (CollectionUtils.isNotEmpty(childBatchs)) { - - for (Batch childBatch : childBatchs) { - - // delete this child and all his children - Integer childBatchId = childBatch.getId(); - - if (log.isDebugEnabled()) { - log.debug("Delete child [" + childBatchId + "] of species batch: " + id); - } - batchHelper.removeWithChildren(childBatchId); - } - } + batchHelper.deleteSpeciesSubBatch(id); } @Override @@ -283,13 +240,13 @@ Preconditions.checkNotNull(speciesBatchId); List<SortingBatch> frequencyChilds = - batchHelper.getFrequencies(sampleCategoryModel, speciesBatchId); + batchHelper.getFrequencies(speciesBatchId); List<SpeciesBatchFrequency> results = Lists.newArrayList(); for (SortingBatch child : frequencyChilds) { SpeciesBatchFrequency target = SpeciesBatchFrequencys.newSpeciesBatchFrequency(); - entityToSpeciesBatchFrequency(child, target); + batchHelper.entityToBatchFrequency(child, target); results.add(target); } return Collections.unmodifiableList(results); @@ -353,7 +310,7 @@ // Remember child ids, to remove unchanged item (see at bottom in this method) List<Integer> notUpdatedChildIds = Lists.newArrayList(); - List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(sampleCategoryModel, parentBatch); + List<SortingBatch> frequencyChilds = batchHelper.getFrequencyChilds(parentBatch); for (SortingBatch child : frequencyChilds) { notUpdatedChildIds.add(child.getId()); } @@ -426,7 +383,7 @@ //-- Internal methods --// //------------------------------------------------------------------------// - protected SpeciesBatch entityToSpeciesBatch(SortingBatch source, + protected SpeciesBatch entityToSpeciesBatch(SampleCategoryModel sampleCategoryModel, SortingBatch source, SpeciesBatch target) { Preconditions.checkNotNull(target.getSpecies()); @@ -461,13 +418,12 @@ boolean isFrequency = batchHelper.isFrequencyBatch(sampleCategoryModel, source); -// boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(sm.getPmfm().getId()); if (!isFrequency) { Integer qualitativeId = null; if (sm.getQualitativeValue() != null) { qualitativeId = sm.getQualitativeValue().getId(); } - setSampleCategoryQualitative( + batchHelper.setSampleCategoryQualitative( target, sm.getPmfm().getId(), sm.getNumericalValue(), @@ -482,7 +438,7 @@ SortingBatch sourceChild = (SortingBatch) batch; SpeciesBatch targetChild = SpeciesBatchs.newSpeciesBatch(); targetChild.setSpecies(target.getSpecies()); - entityToSpeciesBatch(sourceChild, targetChild); + entityToSpeciesBatch(sampleCategoryModel, sourceChild, targetChild); if (log.isDebugEnabled()) { log.debug("Loaded CatchBatch (Vrac|Hors Vrac) > Species > " + targetChild.getSpecies().getReferenceTaxonId() + " : " + target.getId()); } @@ -500,31 +456,6 @@ return target; } - protected void entityToSpeciesBatchFrequency(SortingBatch source, - SpeciesBatchFrequency target) { - - target.setId(source.getId()); - - // Rank order - target.setRankOrder(Integer.valueOf(source.getRankOrder())); - - target.setNumber(source.getIndividualCount()); - target.setWeight(source.getWeight()); - - Preconditions.checkState(source.getSortingMeasurements().size() == 1, "SortingBatch [" + source.getId() + "] need exactly one sortingMeasurement (to store the length step category), but had " + source.getSortingMeasurements().size()); - SortingMeasurement sm = source.getSortingMeasurements().iterator().next(); - Preconditions.checkNotNull(sm.getPmfm(), "SortingMeasurement [" + sm.getId() + "] can not have a null pmfm"); - Preconditions.checkNotNull(sm.getPmfm().getId(), "SortingMeasurement [" + sm.getId() + "] can not have a pmfm with null id"); - - // Length step category - Caracteristic lengthStepCaracteristic = - referentialService.getCaracteristic(sm.getPmfm().getId()); - target.setLengthStepCaracteristic(lengthStepCaracteristic); - - // Length - target.setLengthStep(sm.getNumericalValue()); - } - protected void speciesBatchToEntity(SpeciesBatch source, SortingBatch target, String parentBatchId, @@ -738,26 +669,4 @@ } } - protected void setSampleCategoryQualitative(SpeciesBatch target, - Integer pmfmId, - Float numericalvalue, - String alphanumericalValue, - Integer qualitativeValueId) { - // skip if null or corresponding to the SORTING_TYPE PMFM (Espèce, Benthos, Plancton, etc.) - if (pmfmId == null || pmfmId.equals(enumeration.PMFM_ID_SORTING_TYPE)) { - return; - } - - boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(pmfmId); - Preconditions.checkNotNull(isSamplingCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId); - - target.setSampleCategoryId(pmfmId); - Serializable categoryValue = batchHelper.getSampleCategoryQualitative( - pmfmId, - numericalvalue, - alphanumericalValue, - qualitativeValueId); - target.setSampleCategoryValue(categoryValue); - } - } Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SynchronizationStatusHelper.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SynchronizationStatusHelper.java (rev 0) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SynchronizationStatusHelper.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -0,0 +1,85 @@ +package fr.ifremer.tutti.persistence.service; + +import fr.ifremer.adagio.core.dao.data.batch.Batch; +import fr.ifremer.adagio.core.dao.data.batch.CatchBatch; +import fr.ifremer.adagio.core.dao.data.sample.Sample; +import fr.ifremer.adagio.core.dao.data.survey.fishingTrip.FishingTrip; +import fr.ifremer.adagio.core.dao.data.survey.scientificCruise.ScientificCruise; +import fr.ifremer.adagio.core.dao.technical.synchronization.SynchronizationStatus; +import org.hibernate.type.IntegerType; +import org.hibernate.type.StringType; +import org.springframework.stereotype.Component; + +/** + * Helper around SynchronizationStatus. + * <p/> + * Created on 4/22/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 3.5 + */ +@Component("synchronizationStatusHelper") +public class SynchronizationStatusHelper extends AbstractPersistenceService { + + public void setDirty(ScientificCruise scientificCruise) { + String synchronizationStatus = getDirtyValue(); + scientificCruise.setSynchronizationStatus(synchronizationStatus); + } + + public void setDirty(FishingTrip fishingTrip) { + String synchronizationStatus = getDirtyValue(); + fishingTrip.setSynchronizationStatus(synchronizationStatus); + setDirty(fishingTrip.getScientificCruise()); + } + + public void setDirty(CatchBatch catchBatch) { + String synchronizationStatus = getDirtyValue(); + catchBatch.setSynchronizationStatus(synchronizationStatus); + setDirty(catchBatch.getFishingOperation().getFishingTrip()); + } + + public void setDirty(Sample sample) { + String synchronizationStatus = getDirtyValue(); + sample.setSynchronizationStatus(synchronizationStatus); + Batch batch = sample.getBatch(); + if (batch != null && batch instanceof CatchBatch) { + setDirty((CatchBatch) batch); + } else { + setDirty(sample.getFishingOperation().getFishingTrip()); + } + } + + public void setReadyToSynch(String cruiseId) { + + String oldStatus = getDirtyValue(); + String newStatus = SynchronizationStatus.READY_TO_SYNCHRONIZE.getValue(); + + // update scientificCruise + queryUpdate("updateScientificCruiseSynchronizationStatus", + "cruiseId", IntegerType.INSTANCE, cruiseId, + "oldStatus", StringType.INSTANCE, oldStatus, + "newStatus", StringType.INSTANCE, newStatus); + + // update fishingTrip + queryUpdate("updateFishingTripSynchronizationStatus", + "cruiseId", IntegerType.INSTANCE, cruiseId, + "oldStatus", StringType.INSTANCE, oldStatus, + "newStatus", StringType.INSTANCE, newStatus); + + // update catchBatch + queryUpdate("updateCatchBatchSynchronizationStatus", + "cruiseId", IntegerType.INSTANCE, cruiseId, + "oldStatus", StringType.INSTANCE, oldStatus, + "newStatus", StringType.INSTANCE, newStatus); + + // update sample + queryUpdate("updateSampleSynchronizationStatus", + "cruiseId", IntegerType.INSTANCE, cruiseId, + "oldStatus", StringType.INSTANCE, oldStatus, + "newStatus", StringType.INSTANCE, newStatus); + } + + protected String getDirtyValue() { + return SynchronizationStatus.DIRTY.getValue(); + } +} Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SynchronizationStatusHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -42,6 +42,8 @@ import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; 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.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; @@ -51,6 +53,8 @@ import fr.ifremer.tutti.persistence.service.IndividualObservationBatchPersistenceService; import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Component; @@ -58,6 +62,7 @@ import javax.annotation.Resource; import java.io.Serializable; import java.text.MessageFormat; +import java.util.Collection; import java.util.List; import static org.nuiton.i18n.I18n.t; @@ -71,9 +76,9 @@ @Component("batchPersistenceHelper") public class BatchPersistenceHelper extends AbstractPersistenceService { -// /** Logger. */ -// private static final Log log = -// LogFactory.getLog(BatchPersistenceHelper.class); + /** Logger. */ + private static final Log log = + LogFactory.getLog(BatchPersistenceHelper.class); @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; @@ -93,9 +98,6 @@ @Resource(name = "scientificCruiseCatchBatchValidator") protected TuttiCatchBatchValidator catchBatchValidator; -// @Resource(name = "measurementPersistenceHelper") -// protected MeasurementPersistenceHelper measurementPersistenceHelper; - @Resource(name = "batchTreeHelper") protected BatchTreeHelper batchTreeHelper; @@ -219,18 +221,11 @@ catchBatchDao.updateSortingBatch(sortingBatch, parentCatchBatch); } -// public SortingMeasurement getInheritedSortingMeasurement(SortingBatch sortingBatch) { -// return catchBatchDao.getInheritedSortingMeasurement(sortingBatch, enumeration.PMFM_ID_SORTED_UNSORTED); -// } - -// public QuantificationMeasurement setWeightMeasurementQuantificationMeasurement(Batch batch, Float weightValue) { -// return catchBatchDao.setQuantificationMeasurement(batch, enumeration.PMFM_ID_WEIGHT_MEASURED, getRecorderDepartmentId(), weightValue, true); -// } - - public List<SortingBatch> getFrequencyChilds(SampleCategoryModel sampleCategoryModel, - SortingBatch sortingBatch) { + public List<SortingBatch> getFrequencyChilds(SortingBatch sortingBatch) { List<SortingBatch> result = Lists.newArrayList(); + SampleCategoryModel sampleCategoryModel = getSampleCategoryModel(); + for (Batch batch : sortingBatch.getChildBatchs()) { SortingBatch child = (SortingBatch) batch; if (isFrequencyBatch(sampleCategoryModel, child)) { @@ -240,16 +235,15 @@ return result; } - public List<SortingBatch> getFrequencies(SampleCategoryModel sampleCategoryModel, - String batchId) { + public List<SortingBatch> getFrequencies(String batchId) { Preconditions.checkNotNull(batchId); Integer sortingBatchId = Integer.valueOf(batchId); CatchBatch catchBatch = getRootCatchBatchByBatchId(sortingBatchId); SortingBatch sortingBatch = catchBatchDao.getSortingBatchById( catchBatch, sortingBatchId); - List<SortingBatch> frequencyChilds = getFrequencyChilds(sampleCategoryModel, - sortingBatch); + List<SortingBatch> frequencyChilds = getFrequencyChilds( + sortingBatch); return frequencyChilds; } @@ -331,69 +325,41 @@ if (enumeration.QUALITATIVE_VRAC_ID.equals(qualitativeValueId)) { - // get vrac / Species / Alive itemized batch + // -- Vrac > Species > Alive itemized parentBatch = batchTreeHelper.getSpeciesVracAliveItemizedRootBatch(catchBatch); -// parentBatch = getSortingBatch( -// catchBatch, -// "Vrac > Species > Alive Itemized", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, -// enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED); if (parentBatch == null) { - // get vrac batch - + // -- Vrac SortingBatch vracBatch = batchTreeHelper.getVracBatch(catchBatch); -// SortingBatch vracBatch = getSortingBatch( -// catchBatch, -// "Vrac", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID); if (vracBatch == null) { - - // create vrac batch vracBatch = batchTreeHelper.getOrCreateVracBatch(catchBatch, null, null); } - // get vrac > species batch - + // -- Vrac > Species SortingBatch vracSpeciesBatch = batchTreeHelper.getSpeciesVracRootBatch(vracBatch); -// SortingBatch vracSpeciesBatch = getSortingBatch( -// vracBatch, -// "Vrac > Species", -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); if (vracSpeciesBatch == null) { - - // create vrac > species batch vracSpeciesBatch = batchTreeHelper.getOrCreateSpeciesVracRootBatch(catchBatch, vracBatch, null); } - // create vrac > species > Alive itemized batch - + // -- Vrac > Species > Alive itemized parentBatch = batchTreeHelper.getOrCreateSpeciesVracAliveItemizedRootBatch(catchBatch, vracSpeciesBatch); } } else if (enumeration.QUALITATIVE_HORS_VRAC_ID.equals(qualitativeValueId)) { - // get hors vrac > Species batch + // -- Hors Vrac > Species parentBatch = batchTreeHelper.getSpeciesHorsVracRootBatch(catchBatch); -// parentBatch = getSortingBatch( -// catchBatch, -// "Hors vrac > Species", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); if (parentBatch == null) { - // get (or create) hors vrac batch + // -- Hors Vrac SortingBatch horsVracBatch = batchTreeHelper.getOrCreateHorsVracBatch(catchBatch); - // create hors vrac > species batch - parentBatch = batchTreeHelper.getOrCreateSpeciesHorsVracRootBatch( - catchBatch, - horsVracBatch); + // -- Hors Vrac > Species + parentBatch = batchTreeHelper.getOrCreateSpeciesHorsVracRootBatch(catchBatch, horsVracBatch); } } else { @@ -438,70 +404,41 @@ if (enumeration.QUALITATIVE_VRAC_ID.equals(qualitativeValueId)) { - // Vrac > Benthos > Alive Itemized + // -- Vrac > Benthos > Alive Itemized parentBatch = batchTreeHelper.getBenthosVracAliveItemizedRootBatch(catchBatch); -// parentBatch = getSortingBatch( -// catchBatch, -// "Vrac > Species > Alive Itemized", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID, -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, -// enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED); if (parentBatch == null) { - // get vrac batch - + // -- Vrac SortingBatch vracBatch = batchTreeHelper.getVracBatch(catchBatch); -// SortingBatch vracBatch = getSortingBatch( -// catchBatch, -// "Vrac", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID); if (vracBatch == null) { - - // create vrac batch vracBatch = batchTreeHelper.getOrCreateVracBatch(catchBatch, null, null); } - // get vrac > Benthos batch - + // -- Vrac > Benthos SortingBatch vracBenthosBatch = batchTreeHelper.getBenthosVracRootBatch(vracBatch); -// SortingBatch vracBenthosBatch = getSortingBatch( -// vracBatch, -// "Vrac > Benthos", -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); if (vracBenthosBatch == null) { - - // create vrac > Benthos batch vracBenthosBatch = batchTreeHelper.getOrCreateBenthosVracRootBatch(catchBatch, vracBatch, null); } - // create vrac > Benthos > Alive itemized batch - + // -- Vrac > Benthos > Alive itemized parentBatch = batchTreeHelper.getOrCreateBenthosVracAliveItemizedRootBatch(catchBatch, vracBenthosBatch); } } else if (enumeration.QUALITATIVE_HORS_VRAC_ID.equals(qualitativeValueId)) { - // get hors-vrac > Benthos batch + // -- Hors Vrac > Benthos parentBatch = batchTreeHelper.getBenthosHorsVracRootBatch(catchBatch); -// parentBatch = getSortingBatch( -// catchBatch, -// "Hors vrac > Benthos", -// enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, -// enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); if (parentBatch == null) { - // get (or create) hors vrac batch - + // -- Hors Vrac SortingBatch horsVracBatch = batchTreeHelper.getOrCreateHorsVracBatch(catchBatch); - // create hors vrac > Benthos batch - parentBatch = batchTreeHelper.getOrCreateBenthosHorsVracRootBatch( - catchBatch, - horsVracBatch); + // -- Hors Vrac > Benthos + parentBatch = batchTreeHelper.getOrCreateBenthosHorsVracRootBatch(catchBatch, horsVracBatch); } } else { @@ -518,12 +455,15 @@ Preconditions.checkNotNull(target); + // -- Hors Vrac > Marine Litter SortingBatch parentBatch = batchTreeHelper.getMarineLitterRootBatch(catchBatch); if (parentBatch == null) { + // -- Hors Vrac SortingBatch horsVracBatch = batchTreeHelper.getOrCreateHorsVracBatch(catchBatch); + // -- Hors Vrac > Marine Litter parentBatch = batchTreeHelper.getOrCreateMarineLitterRootBatch(catchBatch, horsVracBatch, null); } @@ -545,342 +485,80 @@ return qualitativeValueId; } -// public SortingBatch getSortingBatch(Batch source, -// String debugMessage, -// Integer... ids) { -// -// return getSortingBatch(source.getChildBatchs(), debugMessage, ids); -// } + public void deleteSpeciesSubBatch(String id) { + Preconditions.checkNotNull(id); -// public SortingBatch getSortingBatch(Collection<Batch> childs, -// String debugMessage, -// Integer... ids) { -// -// int nbParams = ids.length / 2; -// -// Object[] params = new Object[nbParams * 3]; -// for (int i = 0; i < nbParams; i++) { -// Integer sortingPmfmId = ids[2 * i]; -// Integer sortingQualitativeValueId = ids[2 * i + 1]; -// params[3 * i] = CatchBatchExtendDao.PMFM_ID; -// params[3 * i + 1] = sortingPmfmId; -// params[3 * i + 2] = sortingQualitativeValueId; -// } -// SortingBatch result = catchBatchDao.getSortingBatch(childs, params); -// if (result != null && debugMessage != null && log.isDebugEnabled()) { -// log.debug("Loaded " + debugMessage + ": " + result.getId()); -// } -// return result; -// } + Integer speciesBatchId = Integer.valueOf(id); -// public SortingBatch getVracBatch(CatchBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_VRAC_ID -// ); -// } + CatchBatch catchBatch = getRootCatchBatchByBatchId(speciesBatchId); + SortingBatch sortingBatch = getSortingBatchById(catchBatch, speciesBatchId); -// public SortingBatch getOrCreateVracBatch(CatchBatch batch, -// Float weight, -// Float weightBeforeSampling) { -// return getOrCreate( -// batch, -// batch, -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_VRAC_ID, -// weight, -// weightBeforeSampling, -// (short) 1 -// ); -// } + // get his children + Collection<Batch> childBatchs = sortingBatch.getChildBatchs(); -// public SortingBatch getSpeciesVracRootBatch(SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES -// ); -// } + if (CollectionUtils.isNotEmpty(childBatchs)) { -// public SortingBatch getOrCreateSpeciesVracRootBatch(CatchBatch target, -// SortingBatch batch, -// Float totalWeight) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, -// totalWeight, -// (short) 1 -// ); -// } + for (Batch childBatch : childBatchs) { -// public SortingBatch getSpeciesVracAliveNotItemizedRootBatch(SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED -// ); -// } + // delete this child and all his children + Integer childBatchId = childBatch.getId(); -// public SortingBatch getOrCreateSpeciesVracAliveNotItemizedRootBatch(CatchBatch target, -// SortingBatch batch, -// Float totalWeight) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED, -// totalWeight, -// (short) 1 -// ); -// } + if (log.isDebugEnabled()) { + log.debug("Delete child [" + childBatchId + "] of species batch: " + id); + } + removeWithChildren(childBatchId); + } + } + } -// public SortingBatch getSpeciesVracInertRootBatch(SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT -// ); -// } -// public SortingBatch getOrCreateSpeciesVracInertRootBatch(CatchBatch target, -// SortingBatch batch, -// Float totalWeight) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT, -// totalWeight, -// (short) 2 -// ); -// } + public <S extends SpeciesAbleBatch> void setSampleCategoryQualitative(S target, + Integer pmfmId, + Float numericalvalue, + String alphanumericalValue, + Integer qualitativeValueId) { + // skip if null or corresponding to the SORTING_TYPE PMFM (Espèce, Benthos, Plancton, etc.) + if (pmfmId == null || pmfmId.equals(enumeration.PMFM_ID_SORTING_TYPE)) { + return; + } + SampleCategoryModel sampleCategoryModel = getSampleCategoryModel(); -// public SortingBatch getSpeciesVracAliveItemizeRootBatch( -// SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED -// ); -// } + boolean isSamplingCategory = sampleCategoryModel.containsCategoryId(pmfmId); + Preconditions.checkNotNull(isSamplingCategory, "Unable to find corresponding SampleCategoryEnum for PMFM.ID : " + pmfmId); -// public SortingBatch getOrCreateSpeciesVracAliveItemizedRootBatch(CatchBatch target, -// SortingBatch batch) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED, -// null, -// (short) 3 -// ); -// } + target.setSampleCategoryId(pmfmId); + Serializable categoryValue = getSampleCategoryQualitative( + pmfmId, + numericalvalue, + alphanumericalValue, + qualitativeValueId); + target.setSampleCategoryValue(categoryValue); + } -// public SortingBatch getBenthosVracRootBatch( -// SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS -// ); -// } + public <F extends SpeciesAbleBatchFrequency & TuttiEntity> void entityToBatchFrequency(SortingBatch source, + F target) { -// public SortingBatch getOrCreateBenthosVracRootBatch(CatchBatch target, -// SortingBatch batch, -// Float totalWeight) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, -// totalWeight, -// (short) 2 -// ); -// } + target.setId(source.getId()); -// public SortingBatch getBenthosVracAliveNotItemizedRootBatch( -// SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED -// ); -// } + // Rank order + target.setRankOrder(Integer.valueOf(source.getRankOrder())); -// public SortingBatch getOrCreateBenthosVracAliveNotItemizedRootBatch(CatchBatch target, -// SortingBatch batch, -// Float totalWeight) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED, -// totalWeight, -// (short) 1 -// ); -// } + target.setNumber(source.getIndividualCount()); + target.setWeight(source.getWeight()); -// public SortingBatch getBenthosVracInertRootBatch(SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT -// ); -// } + Preconditions.checkState(source.getSortingMeasurements().size() == 1, "SortingBatch [" + source.getId() + "] need exactly one sortingMeasurement (to store the length step category), but had " + source.getSortingMeasurements().size()); + SortingMeasurement sm = source.getSortingMeasurements().iterator().next(); + Preconditions.checkNotNull(sm.getPmfm(), "SortingMeasurement [" + sm.getId() + "] can not have a null pmfm"); + Preconditions.checkNotNull(sm.getPmfm().getId(), "SortingMeasurement [" + sm.getId() + "] can not have a pmfm with null id"); -// public SortingBatch getOrCreateBenthosVracInertRootBatch(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target, -// SortingBatch batch, -// Float totalWeight) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT, -// totalWeight, -// (short) 2 -// ); -// } + // Length step category + Caracteristic lengthStepCaracteristic = referentialService.getCaracteristic(sm.getPmfm().getId()); + target.setLengthStepCaracteristic(lengthStepCaracteristic); -// public SortingBatch getBenthosVracAliveItemizeRootBatch(SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED -// ); -// } + // Length + target.setLengthStep(sm.getNumericalValue()); + } -// public SortingBatch getOrCreateBenthosVracAliveItemizedRootBatch(CatchBatch target, -// SortingBatch batch) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE_2, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED, -// null, -// (short) 3 -// ); -// } - -// public SortingBatch getHorsVracBatch(CatchBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_HORS_VRAC_ID -// ); -// } - -// public SortingBatch getOrCreateHorsVracBatch(CatchBatch batch) { -// return getOrCreate( -// batch, -// batch, -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_HORS_VRAC_ID, -// null, -// (short) 2 -// ); -// } - -// public SortingBatch getSpeciesHorsVracRootBatch(SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES -// ); -// } - -// public SortingBatch getOrCreateSpeciesHorsVracRootBatch(CatchBatch target, -// SortingBatch batch) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, -// null, -// (short) 1 -// ); -// } - -// public SortingBatch getBenthosHorsVracRootBatch(SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS -// ); -// } - -// public SortingBatch getOrCreateBenthosHorsVracRootBatch(CatchBatch target, -// SortingBatch batch) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, -// null, -// (short) 2 -// ); -// } - -// public SortingBatch getMarineLitterRootBatch(SortingBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER -// ); -// } - -// public SortingBatch getOrCreateMarineLitterRootBatch(CatchBatch target, -// SortingBatch batch, -// Float totalWeight) { -// return getOrCreate( -// target, -// batch, -// enumeration.PMFM_ID_SORTING_TYPE, -// enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER, -// totalWeight, -// (short) 3 -// ); -// } - -// public SortingBatch getRejectedBatch(CatchBatch batch) { -// return get( -// batch, -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_UNSORTED_ID -// ); -// } - -// public SortingBatch getOrCreateRejectedBatch(CatchBatch batch, -// Float weight) { -// -// return getOrCreate( -// batch, -// batch, -// enumeration.PMFM_ID_SORTED_UNSORTED, -// enumeration.QUALITATIVE_UNSORTED_ID, -// weight, -// (short) 3 -// ); -// } - -// public SortingMeasurement setSortingMeasurement( -// SortingBatch sortingBatch, -// Integer pmfmId, -// Serializable value) { -// Preconditions.checkNotNull(pmfmId); -// Preconditions.checkNotNull(value); -// -// Caracteristic caracteristic = referentialService.getCaracteristic(pmfmId); -// SortingMeasurement sortingMeasurement = catchBatchDao.getSortingMeasurement( -// sortingBatch, pmfmId, getRecorderDepartmentId(), true); -// measurementPersistenceHelper.setMeasurement(sortingMeasurement, -// caracteristic, -// value); -// return sortingMeasurement; -// } - public Serializable getSampleCategoryQualitative(Integer pmfmId, Float numericalvalue, String alphanumericalValue, Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchTreeHelper.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchTreeHelper.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchTreeHelper.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -3,22 +3,19 @@ import com.google.common.base.Joiner; import com.google.common.collect.Sets; import fr.ifremer.adagio.core.dao.data.batch.Batch; +import fr.ifremer.adagio.core.dao.data.batch.Batchs; import fr.ifremer.adagio.core.dao.data.batch.CatchBatch; import fr.ifremer.adagio.core.dao.data.batch.CatchBatchExtendDao; import fr.ifremer.adagio.core.dao.data.batch.SortingBatch; import fr.ifremer.adagio.core.dao.data.measure.QuantificationMeasurement; import fr.ifremer.adagio.core.dao.data.measure.SortingMeasurement; import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl; -import fr.ifremer.adagio.core.dao.referential.pmfm.Pmfm; import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxon; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; -import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValues; -import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxonImpl; import fr.ifremer.tutti.persistence.service.AbstractPersistenceService; import fr.ifremer.tutti.persistence.service.MeasurementPersistenceHelper; -import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.logging.Log; @@ -47,15 +44,14 @@ /** Logger. */ private static final Log log = LogFactory.getLog(BatchTreeHelper.class); - @Resource(name = "referentialPersistenceService") - protected ReferentialPersistenceService referentialService; - @Resource(name = "measurementPersistenceHelper") protected MeasurementPersistenceHelper measurementPersistenceHelper; @Resource(name = "catchBatchDao") protected CatchBatchExtendDao catchBatchDao; + protected Comparator<Batch> batchComparator = Batchs.newRankOrderComparator(); + //------------------------------------------------------------------------// //-- Get CatchBatch navigation methods --// //------------------------------------------------------------------------// @@ -161,7 +157,7 @@ public SortingBatch getSpeciesVracAliveNotItemizedRootBatch(SortingBatch batch) { return getSortingBatch( batch, - "Vrac > Species" + " > Alive not itemized", + "Vrac > Species > Alive not itemized", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED ); @@ -170,7 +166,7 @@ public SortingBatch getBenthosVracAliveNotItemizedRootBatch(SortingBatch batch) { return getSortingBatch( batch, - "Vrac > Benthos" + " > Alive not itemized", + "Vrac > Benthos > Alive not itemized", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED ); @@ -179,7 +175,7 @@ public SortingBatch getSpeciesVracInertRootBatch(SortingBatch batch) { return getSortingBatch( batch, - "Vrac > Species" + " > Inert (not alive)", + "Vrac > Species > Inert (not alive)", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT ); @@ -188,7 +184,7 @@ public SortingBatch getBenthosVracInertRootBatch(SortingBatch batch) { return getSortingBatch( batch, - "Vrac > Benthos" + " > Inert (not alive)", + "Vrac > Benthos > Inert (not alive)", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT ); @@ -197,7 +193,7 @@ public SortingBatch getSpeciesVracAliveItemizedRootBatch(SortingBatch batch) { return getSortingBatch( batch, - "Vrac > Species" + " > Alive itemized", + "Vrac > Species > Alive itemized", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED ); @@ -206,7 +202,7 @@ public SortingBatch getBenthosVracAliveItemizedRootBatch(SortingBatch batch) { return getSortingBatch( batch, - "Vrac > Benthos" + " > Alive itemized", + "Vrac > Benthos > Alive itemized", enumeration.PMFM_ID_SORTING_TYPE_2, enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED ); @@ -603,29 +599,22 @@ } } - final Comparator<Batch> batchComparator = new Comparator<Batch>() { - @Override - public int compare(Batch b1, Batch b2) { - return (b1.getRankOrder() == null) ? 0 : b1.getRankOrder().compareTo(b2.getRankOrder()); - } - }; + protected void displayBatch(Batch batch, int level, StringBuilder sb) { - private void displayBatch(Batch batch, int level, StringBuilder sb) { + ToStringStyle style = new BatchTreeToStringStyle(); - ToStringBuilder builder = new ToStringBuilder(batch, ToStringStyle.MULTI_LINE_STYLE); + ToStringBuilder builder = new ToStringBuilder(batch, style); builder.append("id", batch.getId()); - if (batch.getParentBatch() != null) { - builder.append("parentId", batch.getParentBatch().getId()); - } builder.append("rankOrder", batch.getRankOrder()); - builder.append("level", level); - if (batch.getWeight() != null) { - builder.append("weight", batch.getWeight()); +// builder.append("level", level); +// if (batch.getParentBatch() != null) { +// builder.append("parentId", batch.getParentBatch().getId()); +// } + + if (batch instanceof CatchBatch) { + CatchBatch catchBatch = (CatchBatch) batch; + builder.append("synchronizationStatus", catchBatch.getSynchronizationStatus()); } - if (batch.getWeightBeforeSampling() != null) { - builder.append("weightBeforeSampling", batch.getWeightBeforeSampling()); - } -// builder.append("qualityFlag", batch.getQualityFlag().getName()); if (batch instanceof SortingBatch) { SortingBatch sortingBatch = (SortingBatch) batch; if (sortingBatch.getSamplingRatio() != null) { @@ -634,45 +623,39 @@ if (sortingBatch.getSamplingRatioText() != null) { builder.append("samplingRatioText", sortingBatch.getSamplingRatioText()); } + if (sortingBatch.getIndividualCount() != null) { + builder.append("individualCount", sortingBatch.getIndividualCount()); + } if (sortingBatch.getReferenceTaxon() != null) { ReferenceTaxon referenceTaxon = sortingBatch.getReferenceTaxon(); - Species speciesByReferenceTaxonId = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId()); - builder.append("referenceTaxon", speciesByReferenceTaxonId.getName()); + builder.append("referenceTaxon", load(ReferenceTaxonImpl.class, referenceTaxon.getId()).getName()); } - if (sortingBatch.getSortingMeasurements() != null) { - for (SortingMeasurement sortingMeasurement : sortingBatch.getSortingMeasurements()) { - Caracteristic sortingMeasurementPmfm = getPmfm(sortingMeasurement.getPmfm()); - builder.append("sortingMeasurement.pmfm", sortingMeasurementPmfm.getParameterName() + " (" + sortingMeasurementPmfm.getId() + ")"); - if (sortingMeasurement.getQualitativeValue() != null) { - CaracteristicQualitativeValue caracteristicQualitativeValue = CaracteristicQualitativeValues.getCaracteristicQualitativeValue(sortingMeasurementPmfm, sortingMeasurement.getQualitativeValue().getId()); - if (caracteristicQualitativeValue == null && sortingMeasurement.getQualitativeValue().getId() == 2146) { - builder.append("sortingMeasurement.qualitativeValue", "Unsorted"); - } else { - builder.append("sortingMeasurement.qualitativeValue", caracteristicQualitativeValue.getName() + " (" + caracteristicQualitativeValue.getId() + ")"); - } - } - if (sortingMeasurement.getNumericalValue() != null) { - builder.append("sortingMeasurement.numericalValue", sortingMeasurement.getNumericalValue()); - } - } + + SortingMeasurement sm = null; + if (sortingBatch.getSortingMeasurements() != null && sortingBatch.getSortingMeasurements().size() == 1) { + sm = sortingBatch.getSortingMeasurements().iterator().next(); + } else if (sortingBatch.getReferenceTaxon() != null && sortingBatch.getReferenceTaxon().getId() != null) { + sm = measurementPersistenceHelper.getInheritedSortingMeasurement(sortingBatch); } + if (sm != null) { + String sortingMeasurementStr = measurementPersistenceHelper.toString(sm); + builder.append("sortingMeasurement", sortingMeasurementStr); + } } QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.getWeightMeasurementQuantificationMeasurement(batch); if (quantificationMeasurement != null) { - - builder.append("quantificationMeasurement.isReferenceQuantification", quantificationMeasurement.getIsReferenceQuantification()); - - Caracteristic quantificationMeasurementPmfm = getPmfm(quantificationMeasurement.getPmfm()); - builder.append("quantificationMeasurement.pmfm", quantificationMeasurementPmfm.getParameterName() + " (" + quantificationMeasurementPmfm.getId() + ")"); - - if (quantificationMeasurement.getQualitativeValue() != null) { - CaracteristicQualitativeValue caracteristicQualitativeValue = CaracteristicQualitativeValues.getCaracteristicQualitativeValue(quantificationMeasurementPmfm, quantificationMeasurement.getQualitativeValue().getId()); - builder.append("quantificationMeasurement.qualitativeValue", caracteristicQualitativeValue.getName() + " (" + caracteristicQualitativeValue.getId() + ")"); - } - if (quantificationMeasurement.getNumericalValue() != null) { - builder.append("quantificationMeasurement.numericalValue", quantificationMeasurement.getNumericalValue()); - } + String quantificationMeasurementStr = measurementPersistenceHelper.toString(quantificationMeasurement); + builder.append("weightQuantificationMeasurement", quantificationMeasurementStr); + builder.append("weightQuantificationMeasurement.isReferenceQuantification", quantificationMeasurement.getIsReferenceQuantification()); } + if (batch.getWeight() != null) { + builder.append("weight", batch.getWeight()); + } + if (batch.getWeightBeforeSampling() != null) { + builder.append("weightBeforeSampling", batch.getWeightBeforeSampling()); + } + builder.append("qualityFlag", load(QualityFlagImpl.class, batch.getQualityFlag().getCode()).getName()); + String prefix = "\n" + StringUtils.leftPad("", 2 * level); String batchStr = Joiner.on(prefix).join(builder.build().split("\n")); sb.append(prefix).append(batchStr); @@ -686,8 +669,19 @@ } } - protected Caracteristic getPmfm(Pmfm pmfm) { - Caracteristic caracteristic = referentialService.getCaracteristic(pmfm.getId()); - return caracteristic; + + static final class BatchTreeToStringStyle extends ToStringStyle { + + private static final long serialVersionUID = 1L; + + BatchTreeToStringStyle() { + super(); + this.setUseClassName(true); + this.setUseShortClassName(true); + this.setContentStart(""); + this.setFieldSeparator(SystemUtils.LINE_SEPARATOR + " | "); + this.setFieldSeparatorAtStart(true); + this.setContentEnd(""); + } } } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -150,7 +150,7 @@ protected void validateCatchBatch(CatchBatch batch, List<CatchBatchValidationError> errors) { - // Vrac + // -- Vrac SortingBatch vracBatch = batchTreeHelper.getVracBatch(batch); if (log.isDebugEnabled()) { @@ -160,10 +160,10 @@ if (vracBatch == null) { addError(errors, n("tutti.persistence.batch.validation.vracNotFound")); } else { - // Vrac > Species + // -- Vrac > Species SortingBatch speciesBatch = batchTreeHelper.getSpeciesVracRootBatch(vracBatch); - // Vrac > Benthos + // -- Vrac > Benthos SortingBatch benthosBatch = batchTreeHelper.getBenthosVracRootBatch(vracBatch); if (speciesBatch == null) { @@ -174,19 +174,19 @@ addWarning(errors, n("tutti.persistence.batch.validation.vracSpeciesNotFound")); } } else { - // Vrac > Species > Alive not itemized + // -- Vrac > Species > Alive not itemized SortingBatch livingNotItemizedBatch = batchTreeHelper.getSpeciesVracAliveNotItemizedRootBatch(speciesBatch); if (livingNotItemizedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracSpeciesLifeNotFound")); } - // Vrac > Species > Inert + // -- Vrac > Species > Inert SortingBatch inertBatch = batchTreeHelper.getSpeciesVracInertRootBatch(speciesBatch); if (inertBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracSpeciesInertNotFound")); } - // Vrac > Species > Alive itemized + // -- Vrac > Species > Alive itemized SortingBatch aliveItemizedBatch = batchTreeHelper.getSpeciesVracAliveItemizedRootBatch(speciesBatch); if (aliveItemizedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracSpeciesAliveItemizedNotFound")); @@ -203,19 +203,19 @@ } } else { - // Vrac > Benthos > Alive not itemized + // -- Vrac > Benthos > Alive not itemized SortingBatch livingNotItemizedBatch = batchTreeHelper.getBenthosVracAliveNotItemizedRootBatch(benthosBatch); if (livingNotItemizedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracBenthosLifeNotFound")); } - // Vrac > Benthos > Inert + // -- Vrac > Benthos > Inert SortingBatch inertBatch = batchTreeHelper.getBenthosVracInertRootBatch(benthosBatch); if (inertBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracBenthosInertNotFound")); } - // Vrac > Benthos > Alive itemized + // -- Vrac > Benthos > Alive itemized SortingBatch aliveItemizedBatch = batchTreeHelper.getBenthosVracAliveItemizedRootBatch(benthosBatch); if (aliveItemizedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound")); @@ -223,23 +223,23 @@ } } - // Hors Vrac + // -- Hors Vrac SortingBatch horsVracBatch = batchTreeHelper.getHorsVracBatch(batch); if (horsVracBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.horsVracNotFound")); } else { - // Hors Vrac > Species + // -- Hors Vrac > Species SortingBatch speciesBatch = batchTreeHelper.getSpeciesHorsVracRootBatch(horsVracBatch); if (speciesBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.horsVracSpeciesNotFound")); } - // Hors Vrac > Benthos + // -- Hors Vrac > Benthos SortingBatch benthosBatch = batchTreeHelper.getBenthosHorsVracRootBatch(horsVracBatch); if (benthosBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.horsVracBenthosNotFound")); } - // Hors Vrac > Marine Litter + // -- Hors Vrac > Marine Litter SortingBatch marineLitterBatch = batchTreeHelper.getMarineLitterRootBatch(horsVracBatch); if (marineLitterBatch == null) { @@ -247,7 +247,7 @@ } } - // Unsorted + // -- Unsorted SortingBatch unsortedBatch = batchTreeHelper.getRejectedBatch(batch); if (unsortedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.unsortedNotFound")); Modified: trunk/tutti-persistence/src/main/resources/queries-failsafe.hbm.xml =================================================================== --- trunk/tutti-persistence/src/main/resources/queries-failsafe.hbm.xml 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/main/resources/queries-failsafe.hbm.xml 2014-04-22 22:43:02 UTC (rev 1722) @@ -64,7 +64,8 @@ SELECT c.id, c.name, - c.departureDateTime + c.departureDateTime, + c.synchronizationStatus AS synchronizationStatus FROM ScientificCruiseImpl c WHERE @@ -116,6 +117,7 @@ sc.vessel.code AS vesselCode, mp.id AS managerId, sc.comments AS scientificCruiseComments, + sc.synchronizationStatus AS synchronizationStatus, (SELECT sm.alphanumericalValue FROM SurveyMeasurementImpl sm WHERE sm.fishingTrip.id=ft.id AND sm.pmfm.id= :pmfmIdSurveyPart @@ -247,6 +249,7 @@ SELECT o.id AS id, o.name AS name, + o.fishingTrip.synchronizationStatus AS synchronizationStatus, o.startDateTime AS startDateTime, (select vum.alphanumericalValue from VesselUseMeasurementImpl vum where vum.vesselUseFeatures.id = vuf.id and vum.pmfm.id=:pmfmIdStationNumber) AS stationNumber, (select gum.alphanumericalValue from GearUseMeasurementImpl gum where gum.gearUseFeatures.id = guf.id and gum.pmfm.id=:pmfmIdMultirigAggregation) AS multirigAggregation @@ -309,6 +312,7 @@ <![CDATA[ SELECT o.name AS name, + max(o.fishingTrip.synchronizationStatus) AS synchronizationStatus, guf.rankOrder AS rankOrder, max(o.startDateTime) AS startDateTime, max(o.endDateTime) AS endDateTime, @@ -433,7 +437,8 @@ SELECT s.id AS id, s.referenceTaxon.id AS referenceTaxon, - s.comments AS comment + s.comments AS comment, + s.synchronizationStatus AS synchronizationStatus FROM SampleImpl s WHERE @@ -450,7 +455,8 @@ SELECT s.id AS id, s.referenceTaxon.id AS referenceTaxon, - s.comments AS comment + s.comments AS comment, + s.synchronizationStatus AS synchronizationStatus FROM SampleImpl s WHERE @@ -574,6 +580,53 @@ </query> <!-- ===================================================================== --> + <!-- === Requete pour mettre a jour la valeur de SynchronizationStatus === --> + <!-- ===================================================================== --> + + <query cacheable="true" name="updateScientificCruiseSynchronizationStatus"> + <![CDATA[ + UPDATE ScientificCruiseImpl SET synchronizationStatus=:newStatus + WHERE synchronizationStatus=:oldStatus AND id=:cruiseId + ]]> + <query-param name="cruiseId" type="java.lang.Integer"/> + <query-param name="oldStatus" type="java.lang.String"/> + <query-param name="newStatus" type="java.lang.String"/> + </query> + + <query cacheable="true" name="updateFishingTripSynchronizationStatus"> + <![CDATA[ + UPDATE FishingTripImpl SET synchronizationStatus=:newStatus + WHERE synchronizationStatus=:oldStatus AND + id IN (SELECT id FROM FishingTripImpl WHERE scientificCruise.id=:cruiseId) + ]]> + <query-param name="cruiseId" type="java.lang.Integer"/> + <query-param name="oldStatus" type="java.lang.String"/> + <query-param name="newStatus" type="java.lang.String"/> + </query> + + <query cacheable="true" name="updateCatchBatchSynchronizationStatus"> + <![CDATA[ + UPDATE CatchBatchImpl SET synchronizationStatus=:newStatus + WHERE synchronizationStatus=:oldStatus AND + id IN (SELECT id FROM CatchBatchImpl WHERE fishingOperation.fishingTrip.scientificCruise.id=:cruiseId) + ]]> + <query-param name="cruiseId" type="java.lang.Integer"/> + <query-param name="oldStatus" type="java.lang.String"/> + <query-param name="newStatus" type="java.lang.String"/> + </query> + + <query cacheable="true" name="updateSampleSynchronizationStatus"> + <![CDATA[ + UPDATE SampleImpl SET synchronizationStatus=:newStatus + WHERE synchronizationStatus=:oldStatus AND + id IN (SELECT id FROM SampleImpl WHERE fishingOperation.fishingTrip.scientificCruise.id=:cruiseId) + ]]> + <query-param name="cruiseId" type="java.lang.Integer"/> + <query-param name="oldStatus" type="java.lang.String"/> + <query-param name="newStatus" type="java.lang.String"/> + </query> + + <!-- ===================================================================== --> <!-- === Requete techniques sur référentiels [REF-TXXX] === --> <!-- ===================================================================== --> Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo =================================================================== (Binary files differ) Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -83,7 +83,7 @@ @Test public void getRootBenthosBatch(/*String fishingOperationId*/) { //TODO Do me! - service.getRootBenthosBatch(fishingOperation.getId(), null); + service.getRootBenthosBatch(fishingOperation.getId(), false); } @Ignore @@ -164,7 +164,7 @@ public BenthosBatch getBenthosBatch(String fishingOperationId, String speciesBatchId) { - BatchContainer<BenthosBatch> rootSpeciesBatch = service.getRootBenthosBatch(fishingOperationId, null); + BatchContainer<BenthosBatch> rootSpeciesBatch = service.getRootBenthosBatch(fishingOperationId, false); return getBenthosBatch(speciesBatchId, rootSpeciesBatch.getChildren()); } Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -326,7 +326,7 @@ // ----------------------------------------------------------------------------- // 7. Test get all root species // ----------------------------------------------------------------------------- - List<BenthosBatch> rootBenthosBatch = service.getRootBenthosBatch(fishingOperationWithEmptyBatch.getId(), null).getChildren(); + List<BenthosBatch> rootBenthosBatch = service.getRootBenthosBatch(fishingOperationWithEmptyBatch.getId(), false).getChildren(); assertNotNull(rootBenthosBatch); assertEquals(2, rootBenthosBatch.size()); assertNotNull(rootBenthosBatch.get(0).getChildBatchs()); @@ -515,7 +515,7 @@ } protected BenthosBatch getBenthosBatch(String fishingOperationId, String speciesBatchId) { - return getBenthosBatch(speciesBatchId, service.getRootBenthosBatch(fishingOperationId, null).getChildren()); + return getBenthosBatch(speciesBatchId, service.getRootBenthosBatch(fishingOperationId, false).getChildren()); } protected BenthosBatch getBenthosBatch(String speciesBatchId, List<BenthosBatch> speciesBatchs) { Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -82,7 +82,7 @@ @Test public void getRootSpeciesBatch(/*String fishingOperationId*/) { //TODO Do me! - service.getRootSpeciesBatch(fishingOperation.getId(), null); + service.getRootSpeciesBatch(fishingOperation.getId(), false); } @Ignore @@ -168,7 +168,7 @@ public SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) { - BatchContainer<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(fishingOperationId, null); + BatchContainer<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(fishingOperationId, false); return getSpeciesBatch(speciesBatchId, rootSpeciesBatch.getChildren()); } Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -318,7 +318,7 @@ // ----------------------------------------------------------------------------- // 7. Test get all root species // ----------------------------------------------------------------------------- - BatchContainer<SpeciesBatch> rootSpeciesBatc = service.getRootSpeciesBatch(fishingOperationWithEmptyBatch.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatc = service.getRootSpeciesBatch(fishingOperationWithEmptyBatch.getId(),false ); List<SpeciesBatch> rootSpeciesBatch = rootSpeciesBatc.getChildren(); assertNotNull(rootSpeciesBatch); assertEquals(2, rootSpeciesBatch.size()); @@ -507,7 +507,7 @@ } protected SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) { - return getSpeciesBatch(speciesBatchId, service.getRootSpeciesBatch(fishingOperationId, null).getChildren()); + return getSpeciesBatch(speciesBatchId, service.getRootSpeciesBatch(fishingOperationId, false).getChildren()); } protected SpeciesBatch getSpeciesBatch(String speciesBatchId, List<SpeciesBatch> speciesBatchs) { Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -48,7 +48,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; @@ -1198,9 +1197,8 @@ //------------------------------------------------------------------------// @Override - public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, - SampleCategoryModel sampleCategoryModel) { - return driver.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel); + public BatchContainer<SpeciesBatch> getRootSpeciesBatch(String fishingOperationId, boolean validateTree) { + return driver.getRootSpeciesBatch(fishingOperationId, validateTree); } @Override @@ -1250,8 +1248,8 @@ //------------------------------------------------------------------------// @Override - public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException { - return driver.getRootBenthosBatch(fishingOperationId, sampleCategoryModel); + public BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, boolean validateTree) throws InvalidBatchModelException { + return driver.getRootBenthosBatch(fishingOperationId, validateTree); } @Override Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/ValidateCruiseOperationsService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -26,8 +26,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import org.nuiton.jaxx.application.ApplicationBusinessException; -import org.nuiton.jaxx.application.ApplicationTechnicalException; import fr.ifremer.tutti.persistence.InvalidBatchModelException; import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; @@ -36,7 +34,6 @@ 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.SampleCategoryModel; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency; import fr.ifremer.tutti.persistence.entities.protocol.SpeciesProtocol; @@ -54,6 +51,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.decorator.Decorator; +import org.nuiton.jaxx.application.ApplicationBusinessException; +import org.nuiton.jaxx.application.ApplicationTechnicalException; import org.nuiton.validator.NuitonValidatorResult; import org.nuiton.validator.NuitonValidatorScope; @@ -82,8 +81,6 @@ protected DecoratorService decoratorService; - protected SampleCategoryModel sampleCategoryModel; - @Override public void setServiceContext(TuttiServiceContext context) { super.setServiceContext(context); @@ -91,7 +88,6 @@ validationService = getService(ValidationService.class); weightComputingService = getService(WeightComputingService.class); decoratorService = getService(DecoratorService.class); - sampleCategoryModel = context.getSampleCategoryModel(); } /** @@ -246,7 +242,7 @@ boolean error = !isCatchBatch; if (isCatchBatch) { - rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel); + rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, true); if (rootSpeciesBatch != null) { List<SpeciesBatch> roots = rootSpeciesBatch.getChildren(); @@ -263,13 +259,13 @@ } } if (error) { - rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, sampleCategoryModel); + rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, true); } BatchContainer<BenthosBatch> rootBenthosBatch = null; error = false; if (isCatchBatch) { - rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, sampleCategoryModel); + rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, true); if (rootBenthosBatch != null) { List<BenthosBatch> roots = rootBenthosBatch.getChildren(); @@ -286,7 +282,7 @@ } } if (error) { - rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, sampleCategoryModel); + rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, true); } BatchContainer<MarineLitterBatch> rootMarineLitterBatch; @@ -328,7 +324,8 @@ .toString(batch.getSampleCategoryValue()); warningMap.put("species", Lists.newArrayList(t("tutti.validator.warning.species.protocolNotRespected", - species, categoryValue))); + species, categoryValue)) + ); break; } } @@ -342,7 +339,8 @@ .toString(batch.getSampleCategoryValue()); warningMap.put("benthos", Lists.newArrayList(t("tutti.validator.warning.benthos.protocolNotRespected", - species, categoryValue))); + species, categoryValue)) + ); break; } } Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightCleaningService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightCleaningService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightCleaningService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -222,7 +222,7 @@ BatchContainer<SpeciesBatch> speciesBatch = persistenceService.getRootSpeciesBatch( - fishingOperationId, sampleCategoryModel); + fishingOperationId, true); for (SpeciesBatch batch : speciesBatch.getChildren()) { @@ -238,7 +238,7 @@ BatchContainer<BenthosBatch> benthosBatch = persistenceService.getRootBenthosBatch( - fishingOperationId, sampleCategoryModel); + fishingOperationId, true); for (BenthosBatch batch : benthosBatch.getChildren()) { @@ -284,7 +284,7 @@ Set<SpeciesBatch> speciesToSave = Sets.newHashSet(); BatchContainer<SpeciesBatch> speciesBatch = persistenceService.getRootSpeciesBatch( - fishingOperationId, sampleCategoryModel); + fishingOperationId, true); for (SpeciesBatch batch : speciesBatch.getChildren()) { @@ -300,7 +300,7 @@ Set<BenthosBatch> benthosToSave = Sets.newHashSet(); BatchContainer<BenthosBatch> benthosBatch = persistenceService.getRootBenthosBatch( - fishingOperationId, sampleCategoryModel); + fishingOperationId, true); for (BenthosBatch batch : benthosBatch.getChildren()) { Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/WeightComputingService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -132,7 +132,7 @@ } catch (ApplicationBusinessException e) { result.put(fishingOperationId, e.getMessage()); - rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, null); + rootSpeciesBatch = persistenceService.getRootSpeciesBatch(fishingOperationId, false); } BatchContainer<BenthosBatch> rootBenthosBatch; @@ -141,7 +141,7 @@ } catch (ApplicationBusinessException e) { result.put(fishingOperationId, e.getMessage()); - rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, null); + rootBenthosBatch = persistenceService.getRootBenthosBatch(fishingOperationId, false); } BatchContainer<MarineLitterBatch> rootMarineLitterBatch; @@ -370,7 +370,7 @@ BatchContainer<SpeciesBatch> rootSpeciesBatch = null; if (persistenceService.isFishingOperationWithCatchBatch(operationId)) { - rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operationId, null); + rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operationId, false); currentSpeciesRowIndex = 0; if (rootSpeciesBatch != null) { @@ -563,7 +563,7 @@ BatchContainer<BenthosBatch> rootBenthosBatch = null; if (persistenceService.isFishingOperationWithCatchBatch(operationId)) { - rootBenthosBatch = persistenceService.getRootBenthosBatch(operationId, null); + rootBenthosBatch = persistenceService.getRootBenthosBatch(operationId, false); currentBenthosRowIndex = 0; if (rootBenthosBatch != null) { Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostExportService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -27,8 +27,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.io.Files; -import org.nuiton.jaxx.application.ApplicationIOUtil; -import org.nuiton.jaxx.application.ApplicationTechnicalException; import fr.ifremer.tutti.persistence.entities.CaracteristicMap; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; @@ -53,14 +51,16 @@ import org.apache.commons.io.IOUtils; import org.nuiton.csv.Export; import org.nuiton.csv.ExportModel; +import org.nuiton.jaxx.application.ApplicationIOUtil; +import org.nuiton.jaxx.application.ApplicationTechnicalException; import java.io.File; import java.io.Writer; import java.util.List; import java.util.Map; -import static org.nuiton.i18n.I18n.t; import static org.nuiton.i18n.I18n.n; +import static org.nuiton.i18n.I18n.t; /** * Service to export batches from a satellite post into a master post. @@ -102,8 +102,6 @@ protected char csvSeparator; - protected SampleCategoryModel sampleCategoryModel; - protected Map<String, CaracteristicQualitativeValue> sampleCategoryValueMap; @Override @@ -114,7 +112,7 @@ csvSeparator = context.getConfig().getCsvSeparator(); - sampleCategoryModel = context.getSampleCategoryModel(); + SampleCategoryModel sampleCategoryModel = context.getSampleCategoryModel(); sampleCategoryValueMap = Maps.newTreeMap(); @@ -143,7 +141,7 @@ // create rows BatchContainer<SpeciesBatch> speciesBatchContainer = - persistenceService.getRootSpeciesBatch(operationId, null); + persistenceService.getRootSpeciesBatch(operationId, false); List<CatchRow> rows = Lists.newArrayList(); List<CatchFrequencyRow> frequencyRows = Lists.newArrayList(); @@ -183,7 +181,7 @@ if (persistenceService.isFishingOperationWithCatchBatch(operationId)) { BatchContainer<BenthosBatch> benthosBatchContainer = - persistenceService.getRootBenthosBatch(operationId, null); + persistenceService.getRootBenthosBatch(operationId, false); // create rows Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostImportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostImportService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/catches/multipost/MultiPostImportService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -93,9 +93,6 @@ */ public class MultiPostImportService extends AbstractTuttiService { -// private static final Log log = -// LogFactory.getLog(TuttiMultiPostImportExportService.class); - public static final String BATCHES_KEY = "batchesKey"; protected static final String ATTACHMENTS_DIRECTORY = "attachments"; @@ -184,7 +181,7 @@ final Map<String, SpeciesBatch> notImportedBatches = Maps.newLinkedHashMap(); BatchContainer<SpeciesBatch> speciesBatches = - persistenceService.getRootSpeciesBatch(operation.getId(), null); + persistenceService.getRootSpeciesBatch(operation.getId(), false); TuttiDataContext dataContext = context.getDataContext(); List<Species> speciesList = dataContext.getReferentSpecies(); @@ -453,7 +450,7 @@ final Map<String, BenthosBatch> notImportedBatches = Maps.newLinkedHashMap(); BatchContainer<BenthosBatch> benthosBatches = - persistenceService.getRootBenthosBatch(operation.getId(), null); + persistenceService.getRootBenthosBatch(operation.getId(), false); TuttiDataContext dataContext = context.getDataContext(); List<Species> speciesList = dataContext.getReferentSpecies(); Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/TuttiExportService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -931,7 +931,7 @@ } catch (Exception e) { withError = true; rootSpeciesBatch = - persistenceService.getRootSpeciesBatch(operationId, null); + persistenceService.getRootSpeciesBatch(operationId, false); } try { @@ -940,7 +940,7 @@ } catch (Exception e) { withError = true; rootBenthosBatch = - persistenceService.getRootBenthosBatch(operationId, null); + persistenceService.getRootBenthosBatch(operationId, false); } try { Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/psionimport/PsionImportService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -207,7 +207,7 @@ } BatchContainer<SpeciesBatch> rootSpeciesBatch = - persistenceService.getRootSpeciesBatch(operation.getId(), null); + persistenceService.getRootSpeciesBatch(operation.getId(), false); Set<Species> alreadyUsedSpecies = Sets.newHashSet(); for (SpeciesBatch speciesBatch : rootSpeciesBatch.getChildren()) { Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportService.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -32,8 +32,6 @@ import com.google.common.collect.Maps; import com.google.common.collect.Multimaps; import com.google.common.collect.Sets; -import org.nuiton.jaxx.application.ApplicationIOUtil; -import org.nuiton.jaxx.application.ApplicationTechnicalException; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.Attachment; @@ -63,6 +61,8 @@ import org.nuiton.csv.Export; import org.nuiton.csv.Import; import org.nuiton.decorator.Decorator; +import org.nuiton.jaxx.application.ApplicationIOUtil; +import org.nuiton.jaxx.application.ApplicationTechnicalException; import java.io.File; import java.io.IOException; @@ -74,8 +74,8 @@ import java.util.Map; import java.util.Set; +import static org.nuiton.i18n.I18n.n; import static org.nuiton.i18n.I18n.t; -import static org.nuiton.i18n.I18n.n; /** * @author kmorin <kmorin@codelutin.com> @@ -287,7 +287,8 @@ int end = Math.min(surveyCode.length(), 7); return surveyCode.substring(0, end); } - }) + } + ) ); speciesBySurveyCode.putAll(TuttiEntities.splitByRefTaxCode(dataContext.getReferentSpecies())); @@ -383,7 +384,7 @@ // delete all species batches - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); for (SpeciesBatch batch : rootSpeciesBatch.getChildren()) { persistenceService.deleteSpeciesBatch(batch.getId()); } Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/WeightComputingServiceTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/WeightComputingServiceTest.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/catches/WeightComputingServiceTest.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -99,7 +99,7 @@ public void computeCatchWeights() { CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_2_ID); try { - BatchContainer<SpeciesBatch> batches = persistenceService.getRootSpeciesBatch(OPERATION_2_ID, null); + BatchContainer<SpeciesBatch> batches = persistenceService.getRootSpeciesBatch(OPERATION_2_ID, false); weightComputingService.computeCatchBatchWeights(catchBatch, batches, null, null); Assert.fail(); @@ -112,7 +112,7 @@ catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_3_ID); try { - BatchContainer<BenthosBatch> batches = persistenceService.getRootBenthosBatch(OPERATION_3_ID, null); + BatchContainer<BenthosBatch> batches = persistenceService.getRootBenthosBatch(OPERATION_3_ID, false); weightComputingService.computeCatchBatchWeights(catchBatch, null, batches, null); Assert.fail(); @@ -138,8 +138,8 @@ catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_5_ID); try { - BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_5_ID, null); - BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_5_ID, null); + BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_5_ID, false); + BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_5_ID, false); weightComputingService.computeCatchBatchWeights(catchBatch, speciesBatches, benthosBatches, null); Assert.fail(); @@ -164,8 +164,8 @@ catchBatch = persistenceService.getCatchBatchFromFishingOperation(OPERATION_7_ID); try { - BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_7_ID, null); - BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_7_ID, null); + BatchContainer<SpeciesBatch> speciesBatches = persistenceService.getRootSpeciesBatch(OPERATION_7_ID, false); + BatchContainer<BenthosBatch> benthosBatches = persistenceService.getRootBenthosBatch(OPERATION_7_ID, false); weightComputingService.computeCatchBatchWeights(catchBatch, speciesBatches, benthosBatches, null); if (log.isInfoEnabled()) { log.info("Weight computing worked on operation #7"); @@ -178,7 +178,7 @@ @Test public void computeSpeciesBatch() { - BatchContainer<SpeciesBatch> speciesBatchContainer = persistenceService.getRootSpeciesBatch(OPERATION_1_ID, null); + BatchContainer<SpeciesBatch> speciesBatchContainer = persistenceService.getRootSpeciesBatch(OPERATION_1_ID, false); List<SpeciesBatch> speciesBatches = speciesBatchContainer.getChildren(); for (int i = 0; i < speciesBatches.size() - 1; i++) { try { @@ -203,7 +203,7 @@ Assert.fail(); } - BatchContainer<BenthosBatch> benthosBatchContainer = persistenceService.getRootBenthosBatch(OPERATION_1_ID, null); + BatchContainer<BenthosBatch> benthosBatchContainer = persistenceService.getRootBenthosBatch(OPERATION_1_ID, false); List<BenthosBatch> benthosBatches = benthosBatchContainer.getChildren(); for (int i = 0; i < benthosBatches.size() - 1; i++) { try { Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/psionimport/PsionImportServiceTest.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -110,7 +110,7 @@ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); catchBatch.setFishingOperation(operation); - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); int oldNbBatchs = rootSpeciesBatch.sizeChildren(); PsionImportResult importResult = service.importFile(importFile, operation, catchBatch); @@ -127,7 +127,7 @@ Assert.assertEquals(0, errors.size()); // no batch imported - BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); Assert.assertEquals(oldNbBatchs + 17, rootSpeciesBatchAfter.sizeChildren()); } @@ -140,7 +140,7 @@ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); catchBatch.setFishingOperation(operation); - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); int oldNbBatchs = rootSpeciesBatch.sizeChildren(); PsionImportResult importResult = service.importFile(importFile, operation, catchBatch); @@ -156,7 +156,7 @@ Assert.assertEquals(10, nbAdded); Assert.assertEquals(0, errors.size()); - BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); Assert.assertEquals(oldNbBatchs + 10, rootSpeciesBatchAfter.sizeChildren()); } @@ -169,7 +169,7 @@ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); catchBatch.setFishingOperation(operation); - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); int oldNbBatchs = rootSpeciesBatch.sizeChildren(); PsionImportResult importResult = service.importFile(importFile, operation, catchBatch); @@ -185,7 +185,7 @@ Assert.assertEquals(1, errors.size()); // no batch imported - BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); Assert.assertEquals(oldNbBatchs, rootSpeciesBatchAfter.sizeChildren()); } } Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportExportServiceTest.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -100,7 +100,7 @@ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); catchBatch.setFishingOperation(operation); - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); Assert.assertEquals(3, rootSpeciesBatch.sizeChildren()); PupitriImportResult importResult = service.importPupitri(trunk, carroussel, operation, catchBatch); @@ -113,12 +113,12 @@ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); catchBatch.setFishingOperation(operation); - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); Assert.assertEquals(3, rootSpeciesBatch.sizeChildren()); PupitriImportResult importResult = service.importPupitri(trunk, carroussel, operation, catchBatch); Assert.assertTrue(importResult.isFishingOperationFound()); Assert.assertEquals(6, importResult.getNbCarrousselNotImported()); - BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); Assert.assertEquals(18, rootSpeciesBatchAfter.sizeChildren()); Decorator<Species> speciesDecorator = decoratorService.getDecoratorByType(Species.class); Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceTest.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/pupitri/PupitriImportServiceTest.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -105,11 +105,11 @@ CatchBatch catchBatch = persistenceService.getCatchBatchFromFishingOperation(operation.getId()); catchBatch.setFishingOperation(operation); - BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(operation.getId(), false); Assert.assertEquals(3, rootSpeciesBatch.sizeChildren()); int nbNotAdded = service.importPupitri(trunk, carroussel, operation, catchBatch).getNbCarrousselNotImported(); Assert.assertEquals(0, nbNotAdded); - BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), null); + BatchContainer<SpeciesBatch> rootSpeciesBatchAfter = persistenceService.getRootSpeciesBatch(operation.getId(), false); Assert.assertEquals(31, rootSpeciesBatchAfter.sizeChildren()); Decorator<Species> speciesDecorator = decoratorService.getDecoratorByType(Species.class); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/action/SaveCruiseAction.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -36,8 +36,11 @@ import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIHandler; import fr.ifremer.tutti.ui.swing.content.cruise.EditCruiseUIModel; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiUIHandler; +import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import org.apache.commons.lang3.ObjectUtils; +import javax.swing.ImageIcon; +import javax.swing.JLabel; import javax.swing.JOptionPane; import java.util.Set; @@ -168,6 +171,8 @@ for (GearWithOriginalRankOrder gear : model.getGear()) { gear.setOriginalRankOrder(gear.getRankOrder()); } + // update SynchronizationStatus + model.setSynchronizationStatus(saved.getSynchronizationStatus()); model.setModify(false); } @@ -177,5 +182,7 @@ getContext().getMainUI().getHandler().setBodyTitle( EditCruiseUIHandler.getTitle(true)); + ImageIcon icon = TuttiUIUtil.getCruiseIcon(getModel()); + getContext().getMainUI().getBody().setLeftDecoration(new JLabel(icon)); } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/MainUIHandler.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -25,8 +25,6 @@ */ import com.google.common.base.Preconditions; -import org.nuiton.jaxx.application.swing.action.ApplicationActionUI; -import org.nuiton.jaxx.application.swing.util.CloseableUI; import fr.ifremer.tutti.TuttiConfiguration; import fr.ifremer.tutti.ichtyometer.feed.FeedReader; import fr.ifremer.tutti.persistence.entities.data.Cruise; @@ -61,6 +59,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.i18n.I18n; +import org.nuiton.jaxx.application.swing.action.ApplicationActionUI; +import org.nuiton.jaxx.application.swing.util.CloseableUI; import javax.swing.Icon; import javax.swing.JButton; @@ -101,9 +101,9 @@ String result; if (connected) { FeedReader ichtyometerReader = getModel().getIchtyometerReader(); - result =t("tutti.ichtyometer.status.connected.tip", ichtyometerReader.getClientName()); + result = t("tutti.ichtyometer.status.connected.tip", ichtyometerReader.getClientName()); } else { - result=t("tutti.ichtyometer.status.not.connected.tip"); + result = t("tutti.ichtyometer.status.not.connected.tip"); } return result; } @@ -421,7 +421,8 @@ screenUI = new EditCruiseUI(ui); rightDecoration = ((EditCruiseUI) screenUI).getTopToolBar(); - icon = ui.getMenuActionEditCruise().getIcon(); + Cruise cruise = context.getDataContext().getCruise(); + icon = TuttiUIUtil.getCruiseIcon(cruise == null ? ((EditCruiseUI) screenUI).getModel() : cruise); break; case EDIT_PROTOCOL: Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -26,8 +26,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Lists; -import jaxx.runtime.SwingUtil; -import org.nuiton.jaxx.application.swing.util.CloseableUI; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.Cruise; @@ -46,6 +44,7 @@ import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.application.swing.util.CloseableUI; import javax.swing.JComponent; import javax.swing.JList; @@ -106,6 +105,7 @@ getDataContext().resetValidationDataContext(); EditCruiseUIModel model = new EditCruiseUIModel(); + model.setSynchronizationStatus("DIRTY"); if (getContext().isCruiseFilled()) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -365,6 +365,18 @@ } @Override + public String getSynchronizationStatus() { + return editObject.getSynchronizationStatus(); + } + + @Override + public void setSynchronizationStatus(String synchronizationStatus) { + String oldValue = getSynchronizationStatus(); + editObject.setSynchronizationStatus(synchronizationStatus); + firePropertyChange(PROPERTY_SYNCHRONIZATION_STATUS, oldValue, synchronizationStatus); + } + + @Override public List<GearWithOriginalRankOrder> getGear() { return editObject.getGear(); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUI.css 2014-04-22 22:43:02 UTC (rev 1722) @@ -91,7 +91,7 @@ #cruiseLabel { text: "tutti.selectCruise.field.cruise"; labelFor: {cruiseCombobox}; - actionIcon: cruise; + icon: {TuttiUIUtil.getCruiseIcon(model.getCruise())}; toolTipText: "tutti.selectCruise.field.cruise.tip"; _help: {"tutti.selectCruise.field.cruise.help"}; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/home/SelectCruiseUIHandler.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -129,10 +129,6 @@ } } else { -// TuttiProtocol selectedProtocol = null; -// if (context.isProgramFilled()) { -// selectedProtocol = getDataContext().getProtocol(); -// } model.setProtocol(getDataContext().getProtocol()); } ui.setContextValue(model); @@ -145,26 +141,14 @@ SelectCruiseUIModel model = getModel(); -// List<Program> programs = Lists.newArrayList(); -// if (model.getPrograms() != null) { -// programs.addAll(model.getPrograms()); -// } initBeanFilterableComboBox(ui.getProgramCombobox(), model.getPrograms(), model.getProgram()); -// List<Cruise> cruises = Lists.newArrayList(); -// if (model.getCruises() != null) { -// cruises.addAll(model.getCruises()); -// } initBeanFilterableComboBox(ui.getCruiseCombobox(), model.getCruises(), model.getCruise()); -// List<TuttiProtocol> protocols = Lists.newArrayList(); -// if (model.getProtocols() != null) { -// protocols.addAll(model.getProtocols()); -// } initBeanFilterableComboBox(ui.getProtocolCombobox(), model.getProtocols(), model.getProtocol()); @@ -246,7 +230,6 @@ getValidator().setBean(model); -// ui.applyDataBinding(SelectCruiseUI.BINDING_EDIT_PROGRAM_BUTTON_ENABLED); ui.applyDataBinding(SelectCruiseUI.BINDING_NEW_CRUISE_BUTTON_ENABLED); ui.applyDataBinding(SelectCruiseUI.BINDING_EDIT_CATCHES_BUTTON_ENABLED); ui.applyDataBinding(SelectCruiseUI.BINDING_VALIDATE_CATCHES_BUTTON_ENABLED); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -1212,6 +1212,18 @@ } @Override + public String getSynchronizationStatus() { + return editObject.getSynchronizationStatus(); + } + + @Override + public void setSynchronizationStatus(String synchronizationStatus) { + String oldValue = getSynchronizationStatus(); + editObject.setSynchronizationStatus(synchronizationStatus); + firePropertyChange(PROPERTY_SYNCHRONIZATION_STATUS, oldValue, synchronizationStatus); + } + + @Override public List<Person> getRecorderPerson() { return editObject.getRecorderPerson(); } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -28,8 +28,6 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; -import fr.ifremer.tutti.ui.swing.util.computable.ComputableData; -import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.CatchBatch; @@ -37,10 +35,12 @@ import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; +import fr.ifremer.tutti.type.WeightUnit; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; -import org.nuiton.jaxx.application.swing.tab.TabContentModel; import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware; +import fr.ifremer.tutti.ui.swing.util.computable.ComputableData; import org.apache.commons.collections.CollectionUtils; +import org.nuiton.jaxx.application.swing.tab.TabContentModel; import org.nuiton.util.beans.Binder; import org.nuiton.util.beans.BinderFactory; @@ -349,18 +349,6 @@ return null; } -// public CatchBatch getCatchBatch() { -// return editObject; -// } -// -// public void setCatchBatch(CatchBatch catchBatch) { -// Object oldValue = this.editObject; -// Object oldObjectId = getObjectId(); -// this.editObject = catchBatch; -// firePropertyChange(PROPERTY_CATCH_BATCH, oldValue, catchBatch); -// firePropertyChange(PROPERTY_OBJECT_ID, oldObjectId, getObjectId()); -// } - @Override public FishingOperation getFishingOperation() { return fishingOperation; @@ -738,34 +726,6 @@ } //------------------------------------------------------------------------// - //-- Plankton --// - //------------------------------------------------------------------------// - - @Override - public Float getPlanktonTotalWeight() { - return planktonTotalWeight; - } - - @Override - public void setPlanktonTotalWeight(Float planktonTotalWeight) { - Object oldValue = getPlanktonTotalWeight(); - this.planktonTotalWeight = planktonTotalWeight; - firePropertyChange(PROPERTY_PLANKTON_TOTAL_WEIGHT, oldValue, planktonTotalWeight); - } - - @Override - public Float getPlanktonTotalSampleWeight() { - return planktonTotalSampleWeight; - } - - @Override - public void setPlanktonTotalSampleWeight(Float planktonTotalSampleWeight) { - Object oldValue = getPlanktonTotalSampleWeight(); - this.planktonTotalSampleWeight = planktonTotalSampleWeight; - firePropertyChange(PROPERTY_PLANKTON_TOTAL_SAMPLE_WEIGHT, oldValue, planktonTotalSampleWeight); - } - - //------------------------------------------------------------------------// //-- Marine Litter --// //------------------------------------------------------------------------// @@ -840,6 +800,18 @@ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment()); } + @Override + public String getSynchronizationStatus() { + return editObject.getSynchronizationStatus(); + } + + @Override + public void setSynchronizationStatus(String synchronizationStatus) { + String oldValue = getSynchronizationStatus(); + editObject.setSynchronizationStatus(synchronizationStatus); + firePropertyChange(PROPERTY_SYNCHRONIZATION_STATUS, oldValue, synchronizationStatus); + } + public void reset() { setSpeciesTotalInertComputedWeight(null); setSpeciesTotalLivingNotItemizedComputedWeight(null); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -242,6 +242,18 @@ return editObject.getRankOrder(); } + @Override + public String getSynchronizationStatus() { + return editObject.getSynchronizationStatus(); + } + + @Override + public void setSynchronizationStatus(String synchronizationStatus) { + String oldValue = getSynchronizationStatus(); + editObject.setSynchronizationStatus(synchronizationStatus); + firePropertyChange(PROPERTY_SYNCHRONIZATION_STATUS, oldValue, synchronizationStatus); + } + //------------------------------------------------------------------------// //-- AttachmentModelAware --// //------------------------------------------------------------------------// Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -240,7 +240,7 @@ // get all batch species root (says the one with only a species sample category) BatchContainer<BenthosBatch> rootBenthosBatch = getPersistenceService().getRootBenthosBatch( - bean.getId(), sampleCategoryModel); + bean.getId(), true); List<BenthosBatch> catches = rootBenthosBatch.getChildren(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -254,6 +254,18 @@ editObject.setRankOrder(rankOrder); } + @Override + public String getSynchronizationStatus() { + return editObject.getSynchronizationStatus(); + } + + @Override + public void setSynchronizationStatus(String synchronizationStatus) { + String oldValue = getSynchronizationStatus(); + editObject.setSynchronizationStatus(synchronizationStatus); + firePropertyChange(PROPERTY_SYNCHRONIZATION_STATUS, oldValue, synchronizationStatus); + } + //------------------------------------------------------------------------// //-- AttachmentModelAware --// //------------------------------------------------------------------------// Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -192,7 +192,7 @@ // get all batch species root (says the one with only a species sample category) BatchContainer<SpeciesBatch> rootSpeciesBatch = getPersistenceService().getRootSpeciesBatch( - bean.getId(), sampleCategoryModel); + bean.getId(), true); List<SpeciesBatch> catches = rootSpeciesBatch.getChildren(); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2014-04-22 21:58:53 UTC (rev 1721) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiUIUtil.java 2014-04-22 22:43:02 UTC (rev 1722) @@ -24,6 +24,9 @@ * #L% */ +import fr.ifremer.tutti.persistence.entities.data.Cruise; +import fr.ifremer.tutti.persistence.entities.data.Cruises; +import jaxx.runtime.SwingUtil; import org.nuiton.jaxx.application.ApplicationBusinessException; import org.nuiton.jaxx.application.swing.util.ApplicationUIUtil; import fr.ifremer.tutti.ui.swing.TuttiUIContext; @@ -33,6 +36,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import javax.swing.ImageIcon; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; @@ -109,4 +113,18 @@ } } + public static ImageIcon getCruiseIcon(Cruise cruise) { + String iconName = "cruise"; + if (cruise != null) { + + if (Cruises.isDirty(cruise)) { + iconName = "cruise-dirty"; + } else if (Cruises.isReadyToSynch(cruise)) { + iconName = "cruise-ready-to-sync"; + } else if (Cruises.isSynch(cruise)) { + iconName = "cruise-waiting"; + } + } + return SwingUtil.createActionIcon(iconName); + } }