r966 - in trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service: . batch
Author: tchemit Date: 2013-05-21 12:01:49 +0200 (Tue, 21 May 2013) New Revision: 966 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/966 Log: fixes #2469: [CAPTURE] Impossible de supprimer le poids total non tri?\195?\169 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/batch/BatchPersistenceHelper.java 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 2013-05-21 09:42:32 UTC (rev 965) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2013-05-21 10:01:49 UTC (rev 966) @@ -321,44 +321,99 @@ quantificationMeasurements.removeAll(notChangedQuantificationMeasurements); } - boolean needVracSpeciesAliveNotItemized = - source.getSpeciesTotalLivingNotItemizedWeight() != null; - boolean needVracSpeciesInert = - source.getSpeciesTotalInertWeight() != null; - boolean needVracSpeciesAliveItemized = false; + SortingBatch vracBatch = batchHelper.getVracBatch(target); - boolean needVracSpecies = source.getSpeciesTotalSortedWeight() != null || + SortingBatch horsVracBatch = batchHelper.getHorsVracBatch(target); + + SortingBatch horsVracSpeciesRootBatch = null; + SortingBatch horsVracBenthosRootBatch = null; + SortingBatch horsVracMarineLitterRootBatch = null; + + if (horsVracBatch != null) { + + horsVracSpeciesRootBatch = batchHelper.getSpeciesHorsVracRootBatch( + horsVracBatch); + horsVracBenthosRootBatch = batchHelper.getBenthosHorsVracRootBatch( + horsVracBatch); + horsVracMarineLitterRootBatch = batchHelper.getMarineLitterRootBatch( + horsVracBatch); + } + + SortingBatch speciesVracBatch = null; + SortingBatch benthosVracBatch = null; + + SortingBatch speciesVracAliveNotItemizeRootBatch = null; + SortingBatch speciesVracInertRootBatch = null; + SortingBatch speciesVracAliveItemizeRootBatch = null; + SortingBatch benthosVracAliveNotItemizeRootBatch = null; + SortingBatch benthosVracInertRootBatch = null; + SortingBatch benthosVracAliveItemizeRootBatch = null; + + if (vracBatch != null) { + speciesVracBatch = batchHelper.getSpeciesVracRootBatch( + vracBatch); + + if (speciesVracBatch != null) { + speciesVracAliveNotItemizeRootBatch = batchHelper.getSpeciesVracAliveNotItemizeRootBatch( + speciesVracBatch); + speciesVracInertRootBatch = batchHelper.getSpeciesVracInertRootBatch( + speciesVracBatch); + speciesVracAliveItemizeRootBatch = batchHelper.getSpeciesVracAliveItemizeRootBatch( + speciesVracBatch); + } + + benthosVracBatch = batchHelper.getBenthosVracRootBatch(vracBatch); + if (benthosVracBatch != null) { + benthosVracAliveNotItemizeRootBatch = batchHelper.getBenthosVracAliveNotItemizeRootBatch( + benthosVracBatch); + benthosVracInertRootBatch = batchHelper.getBenthosVracInertRootBatch( + benthosVracBatch); + benthosVracAliveItemizeRootBatch = batchHelper.getBenthosVracAliveItemizeRootBatch( + benthosVracBatch); + } + } + + boolean needVracSpeciesAliveNotItemized = speciesVracAliveNotItemizeRootBatch != null || + source.getSpeciesTotalLivingNotItemizedWeight() != null; + boolean needVracSpeciesInert = speciesVracInertRootBatch != null || + source.getSpeciesTotalInertWeight() != null; + boolean needVracSpeciesAliveItemized = speciesVracAliveItemizeRootBatch != null; + + boolean needVracSpecies = speciesVracBatch != null || + source.getSpeciesTotalSortedWeight() != null || needVracSpeciesAliveNotItemized || needVracSpeciesInert || needVracSpeciesAliveItemized; - boolean needVracBenthosAliveNotItemized = - source.getBenthosTotalLivingNotItemizedWeight() != null; - boolean needVracBenthosInert = - source.getBenthosTotalInertWeight() != null; - boolean needVracBenthosAliveItemized = false; + boolean needVracBenthosAliveNotItemized = benthosVracAliveNotItemizeRootBatch != null || + source.getBenthosTotalLivingNotItemizedWeight() != null; + boolean needVracBenthosInert = benthosVracInertRootBatch != null || + source.getBenthosTotalInertWeight() != null; + boolean needVracBenthosAliveItemized = benthosVracAliveItemizeRootBatch != null; - boolean needVracBenthos = source.getBenthosTotalSortedWeight() != null || + boolean needVracBenthos = benthosVracBatch != null || + source.getBenthosTotalSortedWeight() != null || needVracBenthosAliveNotItemized || needVracBenthosInert || needVracBenthosAliveItemized; - boolean needVrac = - source.getCatchTotalSortedCarousselWeight() != null || - source.getCatchTotalSortedTremisWeight() != null || - needVracSpecies || - needVracBenthos; + boolean needVrac = vracBatch != null || + source.getCatchTotalSortedCarousselWeight() != null || + source.getCatchTotalSortedTremisWeight() != null || + needVracSpecies || + needVracBenthos; - boolean needHorsVracSpecies = false; - boolean needHorsVracBenthos = false; - boolean needHorsVracMarineLitter = - source.getMarineLitterTotalWeight() != null; + boolean needHorsVracSpecies = horsVracSpeciesRootBatch != null; + boolean needHorsVracBenthos = horsVracBenthosRootBatch != null; + boolean needHorsVracMarineLitter = horsVracMarineLitterRootBatch != null || + source.getMarineLitterTotalWeight() != null; boolean needHorsVrac = needHorsVracSpecies || needHorsVracBenthos || needHorsVracMarineLitter; - boolean needUnsorted = source.getCatchTotalRejectedWeight() != null; + boolean needUnsorted = batchHelper.getRejectedBatch(target) != null || + source.getCatchTotalRejectedWeight() != null; // --------------------------------------------------------------------- // Vrac @@ -366,7 +421,7 @@ if (needVrac) { - SortingBatch vracBatch = batchHelper.getOrCreateVracBatch( + vracBatch = batchHelper.getOrCreateVracBatch( target, source.getCatchTotalSortedCarousselWeight(), source.getCatchTotalSortedTremisWeight()); @@ -376,7 +431,7 @@ // --------------------------------------------------------------------- // Vrac / Species // --------------------------------------------------------------------- - SortingBatch speciesBatch = batchHelper.getOrCreateSpeciesVracRootBatch( + speciesVracBatch = batchHelper.getOrCreateSpeciesVracRootBatch( target, vracBatch, source.getSpeciesTotalSortedWeight()); @@ -387,7 +442,7 @@ // --------------------------------------------------------------------- batchHelper.getOrCreateSpeciesVracAliveNotItemizeRootBatch( target, - speciesBatch, + speciesVracBatch, source.getSpeciesTotalLivingNotItemizedWeight()); } @@ -397,7 +452,7 @@ // --------------------------------------------------------------------- batchHelper.getOrCreateSpeciesVracInertRootBatch( target, - speciesBatch, + speciesVracBatch, source.getSpeciesTotalInertWeight()); } @@ -407,7 +462,7 @@ // --------------------------------------------------------------------- batchHelper.getOrCreateSpeciesVracAliveItemizeRootBatch( target, - speciesBatch); + speciesVracBatch); } } @@ -416,7 +471,7 @@ // --------------------------------------------------------------------- // Vrac > Benthos // --------------------------------------------------------------------- - SortingBatch benthosBatch = batchHelper.getOrCreateBenthosVracRootBatch( + benthosVracBatch = batchHelper.getOrCreateBenthosVracRootBatch( target, vracBatch, source.getBenthosTotalSortedWeight()); @@ -427,7 +482,7 @@ // --------------------------------------------------------------------- batchHelper.getOrCreateBenthosVracAliveNotItemizeRootBatch( target, - benthosBatch, + benthosVracBatch, source.getBenthosTotalLivingNotItemizedWeight()); } @@ -437,7 +492,7 @@ // --------------------------------------------------------------------- batchHelper.getOrCreateBenthosVracInertRootBatch( target, - benthosBatch, + benthosVracBatch, source.getBenthosTotalInertWeight()); } @@ -447,7 +502,7 @@ // --------------------------------------------------------------------- batchHelper.getOrCreateBenthosVracAliveItemizeRootBatch( target, - benthosBatch); + benthosVracBatch); } } @@ -458,8 +513,7 @@ // --------------------------------------------------------------------- // Hors Vrac // --------------------------------------------------------------------- - SortingBatch horsVracBatch = - batchHelper.getOrCreateHorsVracBatch(target); + horsVracBatch = batchHelper.getOrCreateHorsVracBatch(target); if (needHorsVracSpecies) { // --------------------------------------------------------------------- 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 2013-05-21 09:42:32 UTC (rev 965) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2013-05-21 10:01:49 UTC (rev 966) @@ -511,6 +511,14 @@ return result; } + public SortingBatch getVracBatch(CatchBatch batch) { + return get( + batch, + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_VRAC_ID + ); + } + public SortingBatch getOrCreateVracBatch(CatchBatch batch, Float weight, Float weightBeforeSampling) { @@ -525,6 +533,14 @@ ); } + public SortingBatch getSpeciesVracRootBatch(SortingBatch batch) { + return get( + batch, + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES + ); + } + public SortingBatch getOrCreateSpeciesVracRootBatch(CatchBatch target, SortingBatch batch, Float totalWeight) { @@ -538,6 +554,14 @@ ); } + public SortingBatch getSpeciesVracAliveNotItemizeRootBatch(SortingBatch batch) { + return get( + batch, + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED + ); + } + public SortingBatch getOrCreateSpeciesVracAliveNotItemizeRootBatch(CatchBatch target, SortingBatch batch, Float totalWeight) { @@ -551,6 +575,14 @@ ); } + 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) { @@ -564,6 +596,15 @@ ); } + public SortingBatch getSpeciesVracAliveItemizeRootBatch( + SortingBatch batch) { + return get( + batch, + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED + ); + } + public SortingBatch getOrCreateSpeciesVracAliveItemizeRootBatch(CatchBatch target, SortingBatch batch) { return getOrCreate( @@ -576,6 +617,15 @@ ); } + public SortingBatch getBenthosVracRootBatch( + SortingBatch batch) { + return get( + batch, + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS + ); + } + public SortingBatch getOrCreateBenthosVracRootBatch(CatchBatch target, SortingBatch batch, Float totalWeight) { @@ -589,6 +639,15 @@ ); } + public SortingBatch getBenthosVracAliveNotItemizeRootBatch( + SortingBatch batch) { + return get( + batch, + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED + ); + } + public SortingBatch getOrCreateBenthosVracAliveNotItemizeRootBatch(CatchBatch target, SortingBatch batch, Float totalWeight) { @@ -602,6 +661,14 @@ ); } + public SortingBatch getBenthosVracInertRootBatch(SortingBatch batch) { + return get( + batch, + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT + ); + } + public SortingBatch getOrCreateBenthosVracInertRootBatch(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target, SortingBatch batch, Float totalWeight) { @@ -615,6 +682,14 @@ ); } + public SortingBatch getBenthosVracAliveItemizeRootBatch(SortingBatch batch) { + return get( + batch, + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED + ); + } + public SortingBatch getOrCreateBenthosVracAliveItemizeRootBatch(CatchBatch target, SortingBatch batch) { return getOrCreate( @@ -627,6 +702,14 @@ ); } + 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, @@ -638,6 +721,14 @@ ); } + 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( @@ -650,6 +741,14 @@ ); } + 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( @@ -662,6 +761,14 @@ ); } + 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) { @@ -675,6 +782,15 @@ ); } + public SortingBatch getRejectedBatch(CatchBatch batch) { + + return get( + batch, + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_UNSORTED_ID + ); + } + public SortingBatch getOrCreateRejectedBatch(CatchBatch batch, Float weight) { @@ -807,11 +923,11 @@ Float weight, Float weightBeforeSampling, short rankOrder) { - SortingBatch result = getSortingBatch( + SortingBatch result = get( parentBatch, - null, sortingPmfmId, sortingQualitativeValueId); + if (result == null) { result = SortingBatch.Factory.newInstance(); @@ -892,4 +1008,15 @@ return result; } + + protected SortingBatch get(Batch parentBatch, + Integer sortingPmfmId, + Integer sortingQualitativeValueId) { + SortingBatch result = getSortingBatch( + parentBatch, + null, + sortingPmfmId, + sortingQualitativeValueId); + return result; + } }
participants (1)
-
tchemit@users.forge.codelutin.com