Author: tchemit Date: 2014-04-21 07:40:03 +0200 (Mon, 21 Apr 2014) New Revision: 1717 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/1717 Log: refs #4959 : refactor batch model + improve tuttipersistence design Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/CaracteristicQualitativeValues.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceService.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchTreeHelper.java Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/adagio/core/service/technical/sanity/DatabaseSanityServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/adagio/core/service/technical/synchro/ReferentialSynchroServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 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/entities/TuttiEntities.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/AttachmentPersistenceServiceImpl.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/MarineLitterBatchPersistenceServiceImpl.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/ProgramPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SamplePersistenceHelper.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/TuttiPersistenceServiceLocator.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/ScientificCruiseCatchBatchValidator.java 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/export/generic/CatchExportRow.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/UpdateSchemaTest.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/adagio/core/service/technical/sanity/DatabaseSanityServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/adagio/core/service/technical/sanity/DatabaseSanityServiceImpl.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/adagio/core/service/technical/sanity/DatabaseSanityServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -29,7 +29,6 @@ import fr.ifremer.adagio.core.service.technical.sanity.task.DatabaseSanityTask; import org.hibernate.SessionFactory; import org.hibernate.classic.Session; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -50,7 +49,7 @@ /** * Session factory. */ - @Autowired + @Resource protected SessionFactory sessionFactory; /** Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/adagio/core/service/technical/synchro/ReferentialSynchroServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/adagio/core/service/technical/synchro/ReferentialSynchroServiceImpl.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/adagio/core/service/technical/synchro/ReferentialSynchroServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -38,12 +38,12 @@ import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.tool.hbm2ddl.ColumnMetadata; import org.nuiton.util.TimeLog; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.jdbc.support.JdbcUtils; import org.springframework.stereotype.Service; +import javax.annotation.Resource; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; @@ -76,10 +76,10 @@ private static final TimeLog TIME = new TimeLog(ReferentialSynchroServiceImpl.class); - @Autowired + @Resource protected DriverManagerDataSource dataSource; - @Autowired + @Resource protected SessionFactory sessionFactory; protected Dialect localDialect; Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -24,43 +24,21 @@ * #L% */ -import com.google.common.base.Predicate; -import com.google.common.collect.Multimap; -import fr.ifremer.tutti.persistence.entities.CaracteristicMap; -import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; -import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; -import fr.ifremer.tutti.persistence.entities.data.Attachment; -import fr.ifremer.tutti.persistence.entities.data.BatchContainer; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; -import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; -import fr.ifremer.tutti.persistence.entities.data.CatchBatch; -import fr.ifremer.tutti.persistence.entities.data.Cruise; -import fr.ifremer.tutti.persistence.entities.data.FishingOperation; -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; -import fr.ifremer.tutti.persistence.entities.protocol.TuttiProtocol; -import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; -import fr.ifremer.tutti.persistence.entities.referential.Gear; -import fr.ifremer.tutti.persistence.entities.referential.ObjectType; -import fr.ifremer.tutti.persistence.entities.referential.Person; -import fr.ifremer.tutti.persistence.entities.referential.Species; -import fr.ifremer.tutti.persistence.entities.referential.TuttiLocation; -import fr.ifremer.tutti.persistence.entities.referential.TuttiReferentialEntity; -import fr.ifremer.tutti.persistence.entities.referential.Vessel; -import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile; -import org.nuiton.util.Version; +import fr.ifremer.tutti.persistence.service.AccidentalBatchPersistenceService; +import fr.ifremer.tutti.persistence.service.AttachmentPersistenceService; +import fr.ifremer.tutti.persistence.service.BenthosBatchPersistenceService; +import fr.ifremer.tutti.persistence.service.CatchBatchPersistenceService; +import fr.ifremer.tutti.persistence.service.CruisePersistenceService; +import fr.ifremer.tutti.persistence.service.FishingOperationPersistenceService; +import fr.ifremer.tutti.persistence.service.IndividualObservationBatchPersistenceService; +import fr.ifremer.tutti.persistence.service.MarineLitterBatchPersistenceService; +import fr.ifremer.tutti.persistence.service.ProgramPersistenceService; +import fr.ifremer.tutti.persistence.service.ProtocolPersistenceService; +import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService; +import fr.ifremer.tutti.persistence.service.SpeciesBatchPersistenceService; +import fr.ifremer.tutti.persistence.service.TechnicalPersistenceService; import org.springframework.transaction.annotation.Transactional; -import java.io.File; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.Callable; - /** * Contract for a persistence driver used by Tutti. * @@ -68,7 +46,20 @@ * @since 0.1 */ @Transactional(readOnly = true) -public interface TuttiPersistence extends TuttiPersistenceServiceImplementor { +public interface TuttiPersistence extends TuttiPersistenceServiceImplementor, + TechnicalPersistenceService, + BenthosBatchPersistenceService, + SpeciesBatchPersistenceService, + ReferentialPersistenceService, + CatchBatchPersistenceService, + AttachmentPersistenceService, + ProgramPersistenceService, + CruisePersistenceService, + ProtocolPersistenceService, + FishingOperationPersistenceService, + MarineLitterBatchPersistenceService, + AccidentalBatchPersistenceService, + IndividualObservationBatchPersistenceService { //------------------------------------------------------------------------// //-- Technical methods --// @@ -76,658 +67,658 @@ String getImplementationName(); - /** - * To clear all caches. - * - * @since 1.0.1 - */ - void clearAllCaches(); +// /** +// * To clear all caches. +// * +// * @since 1.0.1 +// */ +// void clearAllCaches(); +// +//// /** +//// * @return the enumeration file (where all constant mapping are defined). +//// * @since 2.4 +//// */ +//// TuttiEnumerationFile getEnumerationFile(); +// +// /** +// * To invoke the given call code. +// * <p/> +// * <strong>Note:</strong> this is mainly to execute a code in a single +// * transaction. +// * +// * @param call call to invoke +// * @param <V> return type +// * @return the return of the call +// * @since 2.4 +// */ +// @Transactional(readOnly = false) +// <V> V invoke(Callable<V> call); +// +// Version getDbVersion(); +// +// Version getApplicationVersion(); +// +// void updateSchema(); +// +// void sanityDb(); - /** - * @return the enumeration file (where all constant mapping are defined). - * @since 2.4 - */ - TuttiEnumerationFile getEnumerationFile(); +// //------------------------------------------------------------------------// +// //-- Referential methods --// +// //------------------------------------------------------------------------// +// +// /** +// * @return all available zones (used by a {@link Program}. +// * @see Program#getZone() +// * @see Program#setZone(TuttiLocation) +// * @since 0.3 +// */ +// List<TuttiLocation> getAllProgramZone(); +// +// /** +// * @return all countries. +// * @since 0.1 +// */ +// List<TuttiLocation> getAllCountry(); +// +// /** +// * @return all harbours (used by a {@link Cruise}). +// * @see {@link Cruise#getDepartureLocation()} +// * @see {@link Cruise#setDepartureLocation(TuttiLocation)} +// * @see {@link Cruise#getReturnLocation()} +// * @see {@link Cruise#setReturnLocation(TuttiLocation)} +// * @since 1.2 +// */ +// +// List<TuttiLocation> getAllHarbour(); +// +// /** +// * Get the list of location of type strata that match the given zone id. +// * +// * @param zoneId id of the parent zone (can not be null) +// * @return the stratas with given zone id as location parent +// * @since 1.0 +// */ +// List<TuttiLocation> getAllFishingOperationStrata(String zoneId); +// +// /** +// * Get the list of location of type substra that match the given zone id or +// * if not null the given strata id. +// * +// * @param zoneId id of the parent zone (can not be null) +// * @param strataId id of the optional parent strata +// * @return the list of localite with given zone id as location parent / or strata +// * @since 1.0 +// */ +// List<TuttiLocation> getAllFishingOperationSubStrata(String zoneId, String strataId); +// +// /** +// * Get the list of location of type substra that match the given zone id or +// * if not null the given strata id or if not null the given substrata id if +// * not null. +// * +// * @param zoneId id of the parent zone (can not be null) +// * @param strataId id of the optional parent strata +// * @param subStrataId id of the optional parent subStrata +// * @return the list of localite with given zone id as location parent / or strata or substrata +// * @since 1.0 +// */ +// List<TuttiLocation> getAllFishingOperationLocation(String zoneId, String strataId, String subStrataId); +// +// /** +// * @return all scientific vessels (used by a {@link Cruise}). +// * @see Cruise#getVessel() +// * @see Cruise#setVessel(Vessel) +// * @since 0.3 +// */ +// List<Vessel> getAllScientificVessel(); +// +// /** +// * @return all commercial vessels (used by a {@link Cruise}). +// * @see Cruise#getVessel() +// * @see Cruise#setVessel(Vessel) +// * @since 0.3 +// */ +// List<Vessel> getAllFishingVessel(); +// +// /** +// * Get all species (referent or synonym) with with {@link Species#getSurveyCode()} +// * filled by optional protocol. +// * +// * @return all species with {@code surveyCode} filled if possible. +// * @since 0.1 +// */ +// List<Species> getAllSpecies(); +// +// /** +// * Get all {@code referent} species with {@link Species#getSurveyCode()} +// * filled by optional protocol. +// * +// * @return all species with {@code surveyCode} filled if possible. +// * @since 1.0 +// */ +// List<Species> getAllReferentSpecies(); +// +// /** +// * Obtain a species with external code as vernacular code given his referenceTaxonId. +// * <p/> +// * <strong>Note:</strong> {@link Species#getRefTaxCode()} will not be +// * filled by with method. +// * +// * @param referenceTaxonId id of the reference taxon of the species to load +// * @return the species or {@code null} if not found. +// * @see Species#getReferenceTaxonId() +// * @see Species#getVernacularCode() +// * @since 2.0 +// */ +// Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer referenceTaxonId); +// +// /** +// * @return all caracteristics of the system. +// * @since 1.0 +// */ +// List<Caracteristic> getAllCaracteristic(); +// +// /** +// * @return all caracteristics of the system with the ones which are protected. +// * @since 2.3 +// */ +// List<Caracteristic> getAllCaracteristicWithProtected(); +// +// /** +// * @return all caracteristics of the system useable for {@link SampleCategoryModel}. +// * @since 2.4 +// */ +// List<Caracteristic> getAllCaracteristicForSampleCategory(); +// +// /** +// * @return all numeric caracteristics of the system. +// * @since 1.0.2 +// */ +// List<Caracteristic> getAllNumericCaracteristic(); +// +// Caracteristic getSizeCategoryCaracteristic(); +// +// Caracteristic getSexCaracteristic(); +// +// Caracteristic getSortedUnsortedCaracteristic(); +// +// Caracteristic getMaturityCaracteristic(); +// +// Caracteristic getAgeCaracteristic(); +// +// Caracteristic getMarineLitterCategoryCaracteristic(); +// +// Caracteristic getMarineLitterSizeCategoryCaracteristic(); +// +// Caracteristic getVerticalOpeningCaracteristic(); +// +// Caracteristic getHorizontalOpeningWingCaracteristic(); +// +// Caracteristic getHorizontalOpeningDoorCaracteristic(); +// +// Caracteristic getDeadOrAliveCaracteristic(); +// +// Caracteristic getPmfmIdCaracteristic(); +// +// Caracteristic getWeightMeasuredCaracteristic(); +// +// Caracteristic getCaracteristic(Integer pmfmId); +// +// Predicate<SpeciesAbleBatch> getVracBatchPredicate(); +// +// boolean isVracBatch(SpeciesAbleBatch speciesBatch); +// +// boolean isTemporary(TuttiReferentialEntity entity); +// +// List<Gear> getAllScientificGear(); +// +// List<Gear> getAllFishingGear(); +// +// List<Person> getAllPerson(); +// +// /** +// * @return all object type +// * @since 1.0.2 +// */ +// List<ObjectType> getAllObjectType(); +// +// Person getPerson(Integer personId); +// +// Gear getGear(Integer gearCode); +// +// Vessel getVessel(String vesselCode); +// +// ObjectType getObjectType(String objectTypeCode); +// +// /** +// * Import given temporary species. +// * +// * @param species species to import +// * @since 1.0 +// */ +// @Transactional(readOnly = false) +// List<Species> importTemporarySpecies(List<Species> species); +// +// /** +// * Import given temporary vessels. +// * +// * @param vessels vessels to import +// * @since 1.0 +// */ +// @Transactional(readOnly = false) +// List<Vessel> importTemporaryVessel(List<Vessel> vessels); +// +// /** +// * Import given temporary persons. +// * +// * @param persons persons to import +// * @since 1.0 +// */ +// @Transactional(readOnly = false) +// List<Person> importTemporaryPerson(List<Person> persons); +// +// /** +// * Import given temporary gears. +// * +// * @param gears gears to import +// * @since 1.0 +// */ +// @Transactional(readOnly = false) +// List<Gear> importTemporaryGear(List<Gear> gears); - /** - * To invoke the given call code. - * <p/> - * <strong>Note:</strong> this is mainly to execute a code in a single - * transaction. - * - * @param call call to invoke - * @param <V> return type - * @return the return of the call - * @since 2.4 - */ - @Transactional(readOnly = false) - <V> V invoke(Callable<V> call); - - Version getDbVersion(); - - Version getApplicationVersion(); - - void updateSchema(); - - void sanityDb(); - //------------------------------------------------------------------------// - //-- Referential methods --// - //------------------------------------------------------------------------// - - /** - * @return all available zones (used by a {@link Program}. - * @see Program#getZone() - * @see Program#setZone(TuttiLocation) - * @since 0.3 - */ - List<TuttiLocation> getAllProgramZone(); - - /** - * @return all countries. - * @since 0.1 - */ - List<TuttiLocation> getAllCountry(); - - /** - * @return all harbours (used by a {@link Cruise}). - * @see {@link Cruise#getDepartureLocation()} - * @see {@link Cruise#setDepartureLocation(TuttiLocation)} - * @see {@link Cruise#getReturnLocation()} - * @see {@link Cruise#setReturnLocation(TuttiLocation)} - * @since 1.2 - */ - - List<TuttiLocation> getAllHarbour(); - - /** - * Get the list of location of type strata that match the given zone id. - * - * @param zoneId id of the parent zone (can not be null) - * @return the stratas with given zone id as location parent - * @since 1.0 - */ - List<TuttiLocation> getAllFishingOperationStrata(String zoneId); - - /** - * Get the list of location of type substra that match the given zone id or - * if not null the given strata id. - * - * @param zoneId id of the parent zone (can not be null) - * @param strataId id of the optional parent strata - * @return the list of localite with given zone id as location parent / or strata - * @since 1.0 - */ - List<TuttiLocation> getAllFishingOperationSubStrata(String zoneId, String strataId); - - /** - * Get the list of location of type substra that match the given zone id or - * if not null the given strata id or if not null the given substrata id if - * not null. - * - * @param zoneId id of the parent zone (can not be null) - * @param strataId id of the optional parent strata - * @param subStrataId id of the optional parent subStrata - * @return the list of localite with given zone id as location parent / or strata or substrata - * @since 1.0 - */ - List<TuttiLocation> getAllFishingOperationLocation(String zoneId, String strataId, String subStrataId); - - /** - * @return all scientific vessels (used by a {@link Cruise}). - * @see Cruise#getVessel() - * @see Cruise#setVessel(Vessel) - * @since 0.3 - */ - List<Vessel> getAllScientificVessel(); - - /** - * @return all commercial vessels (used by a {@link Cruise}). - * @see Cruise#getVessel() - * @see Cruise#setVessel(Vessel) - * @since 0.3 - */ - List<Vessel> getAllFishingVessel(); - - /** - * Get all species (referent or synonym) with with {@link Species#getSurveyCode()} - * filled by optional protocol. - * - * @return all species with {@code surveyCode} filled if possible. - * @since 0.1 - */ - List<Species> getAllSpecies(); - - /** - * Get all {@code referent} species with {@link Species#getSurveyCode()} - * filled by optional protocol. - * - * @return all species with {@code surveyCode} filled if possible. - * @since 1.0 - */ - List<Species> getAllReferentSpecies(); - - /** - * Obtain a species with external code as vernacular code given his referenceTaxonId. - * <p/> - * <strong>Note:</strong> {@link Species#getRefTaxCode()} will not be - * filled by with method. - * - * @param referenceTaxonId id of the reference taxon of the species to load - * @return the species or {@code null} if not found. - * @see Species#getReferenceTaxonId() - * @see Species#getVernacularCode() - * @since 2.0 - */ - Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer referenceTaxonId); - - /** - * @return all caracteristics of the system. - * @since 1.0 - */ - List<Caracteristic> getAllCaracteristic(); - - /** - * @return all caracteristics of the system with the ones which are protected. - * @since 2.3 - */ - List<Caracteristic> getAllCaracteristicWithProtected(); - - /** - * @return all caracteristics of the system useable for {@link SampleCategoryModel}. - * @since 2.4 - */ - List<Caracteristic> getAllCaracteristicForSampleCategory(); - - /** - * @return all numeric caracteristics of the system. - * @since 1.0.2 - */ - List<Caracteristic> getAllNumericCaracteristic(); - - Caracteristic getSizeCategoryCaracteristic(); - - Caracteristic getSexCaracteristic(); - - Caracteristic getSortedUnsortedCaracteristic(); - - Caracteristic getMaturityCaracteristic(); - - Caracteristic getAgeCaracteristic(); - - Caracteristic getMarineLitterCategoryCaracteristic(); - - Caracteristic getMarineLitterSizeCategoryCaracteristic(); - - Caracteristic getVerticalOpeningCaracteristic(); - - Caracteristic getHorizontalOpeningWingCaracteristic(); - - Caracteristic getHorizontalOpeningDoorCaracteristic(); - - Caracteristic getDeadOrAliveCaracteristic(); - - Caracteristic getPmfmIdCaracteristic(); - - Caracteristic getWeightMeasuredCaracteristic(); - - Caracteristic getCaracteristic(Integer pmfmId); - - Predicate<SpeciesAbleBatch> getVracBatchPredicate(); - - boolean isVracBatch(SpeciesAbleBatch speciesBatch); - - boolean isTemporary(TuttiReferentialEntity entity); - - List<Gear> getAllScientificGear(); - - List<Gear> getAllFishingGear(); - - List<Person> getAllPerson(); - - /** - * @return all object type - * @since 1.0.2 - */ - List<ObjectType> getAllObjectType(); - - Person getPerson(Integer personId); - - Gear getGear(Integer gearCode); - - Vessel getVessel(String vesselCode); - - ObjectType getObjectType(String objectTypeCode); - - /** - * Import given temporary species. - * - * @param species species to import - * @since 1.0 - */ - @Transactional(readOnly = false) - List<Species> importTemporarySpecies(List<Species> species); - - /** - * Import given temporary vessels. - * - * @param vessels vessels to import - * @since 1.0 - */ - @Transactional(readOnly = false) - List<Vessel> importTemporaryVessel(List<Vessel> vessels); - - /** - * Import given temporary persons. - * - * @param persons persons to import - * @since 1.0 - */ - @Transactional(readOnly = false) - List<Person> importTemporaryPerson(List<Person> persons); - - /** - * Import given temporary gears. - * - * @param gears gears to import - * @since 1.0 - */ - @Transactional(readOnly = false) - List<Gear> importTemporaryGear(List<Gear> gears); - - //------------------------------------------------------------------------// //-- Attachments methods --// //------------------------------------------------------------------------// - /** - * Get all attachments for the given object {@code objectId} of type. - * - * @param objectType type of attachment (see {@link AttachementObjectTypeEnum}) - * @param objectId id of the object - * @return list of all attachments for the given {@code objectId}. - * @see AttachementObjectTypeEnum - */ - List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType, - Integer objectId); +// /** +// * Get all attachments for the given object {@code objectId} of type. +// * +// * @param objectType type of attachment (see {@link AttachementObjectTypeEnum}) +// * @param objectId id of the object +// * @return list of all attachments for the given {@code objectId}. +// * @see AttachementObjectTypeEnum +// */ +// List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType, +// Integer objectId); +// +// /** +// * Get the file of the given {@code attachmentId}. +// * +// * @param attachmentId id of the attachment +// * @return the file for the given attachment +// */ +// File getAttachmentFile(String attachmentId); +// +// /** +// * Creates the given attachment. +// * +// * @param attachment attachment to create +// * @param file file to store in this attachment +// * @return the attachment with his id. +// */ +// @Transactional(readOnly = false) +// Attachment createAttachment(Attachment attachment, File file); +// +// /** +// * Saves the given attachment. +// * +// * @param attachment attachment to create +// * @return the attachment with his id. +// */ +// @Transactional(readOnly = false) +// Attachment saveAttachment(Attachment attachment); +// +// /** +// * Deletes the given attachment given his id. +// * +// * @param attachmentId id of the attachment to delete +// */ +// @Transactional(readOnly = false) +// void deleteAttachment(String attachmentId); - /** - * Get the file of the given {@code attachmentId}. - * - * @param attachmentId id of the attachment - * @return the file for the given attachment - */ - File getAttachmentFile(String attachmentId); - - /** - * Creates the given attachment. - * - * @param attachment attachment to create - * @param file file to store in this attachment - * @return the attachment with his id. - */ - @Transactional(readOnly = false) - Attachment createAttachment(Attachment attachment, File file); - - /** - * Saves the given attachment. - * - * @param attachment attachment to create - * @return the attachment with his id. - */ - @Transactional(readOnly = false) - Attachment saveAttachment(Attachment attachment); - - /** - * Deletes the given attachment given his id. - * - * @param attachmentId id of the attachment to delete - */ - @Transactional(readOnly = false) - void deleteAttachment(String attachmentId); - //------------------------------------------------------------------------// //-- Program methods --// //------------------------------------------------------------------------// - /** - * Get all programs. - * <p/> - * <strong>Note:</strong> For each program, his zone is loaded. - * - * @return the list of programs found in db. - */ - List<Program> getAllProgram(); +// /** +// * Get all programs. +// * <p/> +// * <strong>Note:</strong> For each program, his zone is loaded. +// * +// * @return the list of programs found in db. +// */ +// List<Program> getAllProgram(); +// +// /** +// * Get the program for the given {@code id}. +// * <p/> +// * <strong>Note:</strong> his zone is loaded. +// * +// * @param id id of the program to load +// * @return the loaded program +// */ +// Program getProgram(String id); +// +// @Transactional(readOnly = false) +// Program createProgram(Program bean); +// +// @Transactional(readOnly = false) +// Program saveProgram(Program bean); - /** - * Get the program for the given {@code id}. - * <p/> - * <strong>Note:</strong> his zone is loaded. - * - * @param id id of the program to load - * @return the loaded program - */ - Program getProgram(String id); - - @Transactional(readOnly = false) - Program createProgram(Program bean); - - @Transactional(readOnly = false) - Program saveProgram(Program bean); - //------------------------------------------------------------------------// //-- Cruise methods --// //------------------------------------------------------------------------// - List<Cruise> getAllCruise(String programId); +// List<Cruise> getAllCruise(String programId); +// +// Cruise getCruise(String id); +// +// @Transactional(readOnly = false) +// Cruise createCruise(Cruise bean); +// +// @Transactional(readOnly = false) +// Cruise saveCruise(Cruise bean, boolean updateVessel, boolean updateGear); +// +// CaracteristicMap getGearCaracteristics(String cruiseId, +// String gearId, +// short rankOrder); +// +// boolean isOperationUseGears(Integer cruiseId, Collection<Gear> gears); +// +// @Transactional(readOnly = false) +// void saveGearCaracteristics(Gear gear, Cruise cruise); - Cruise getCruise(String id); - - @Transactional(readOnly = false) - Cruise createCruise(Cruise bean); - - @Transactional(readOnly = false) - Cruise saveCruise(Cruise bean, boolean updateVessel, boolean updateGear); - - CaracteristicMap getGearCaracteristics(String cruiseId, - String gearId, - short rankOrder); - - boolean isOperationUseGears(Integer cruiseId, Collection<Gear> gears); - - @Transactional(readOnly = false) - void saveGearCaracteristics(Gear gear, Cruise cruise); - //------------------------------------------------------------------------// //-- Protocol methods --// //------------------------------------------------------------------------// - /** - * The protocol used by the persistence lay (used to consolidate entites). - * - * @return The protocol used by the persistence layer - * @see #setProtocol(TuttiProtocol) - * @since 2.6 - */ - TuttiProtocol getProtocol(); +// /** +// * The protocol used by the persistence lay (used to consolidate entites). +// * +// * @return The protocol used by the persistence layer +// * @see #setProtocol(TuttiProtocol) +// * @since 2.6 +// */ +// TuttiProtocol getProtocol(); +// +// /** +// * Set the protocol to use by the persistence layer. +// * +// * @param protocol the new protocol to use (can be null) +// * @see #getProtocol() +// * @since 2.6 +// */ +// void setProtocol(TuttiProtocol protocol); +// +// List<String> getAllProtocolNames(); +// +// List<TuttiProtocol> getAllProtocol(); +// +// boolean isProtocolExist(String id); +// +// TuttiProtocol getProtocol(String id); +// +// @Transactional(readOnly = false) +// TuttiProtocol createProtocol(TuttiProtocol bean); +// +// @Transactional(readOnly = false) +// TuttiProtocol saveProtocol(TuttiProtocol bean); +// +// @Transactional(readOnly = false) +// void deleteProtocol(String id); - /** - * Set the protocol to use by the persistence layer. - * - * @param protocol the new protocol to use (can be null) - * @see #getProtocol() - * @since 2.6 - */ - void setProtocol(TuttiProtocol protocol); - - List<String> getAllProtocolNames(); - - List<TuttiProtocol> getAllProtocol(); - - boolean isProtocolExist(String id); - - TuttiProtocol getProtocol(String id); - - @Transactional(readOnly = false) - TuttiProtocol createProtocol(TuttiProtocol bean); - - @Transactional(readOnly = false) - TuttiProtocol saveProtocol(TuttiProtocol bean); - - @Transactional(readOnly = false) - void deleteProtocol(String id); - //------------------------------------------------------------------------// //-- FishingOperation methods --// //------------------------------------------------------------------------// - int getFishingOperationCount(String cruiseId); +// int getFishingOperationCount(String cruiseId); +// +// List<String> getAllFishingOperationIds(String cruiseId); +// +// List<FishingOperation> getAllFishingOperation(String cruiseId); +// +// FishingOperation getFishingOperation(String id); +// +// List<Vessel> getFishingOperationSecondaryVessel(String fishingOperationId); +// +// @Transactional(readOnly = false) +// FishingOperation createFishingOperation(FishingOperation bean); +// +// @Transactional(readOnly = false) +// FishingOperation saveFishingOperation(FishingOperation bean); +// +// @Transactional(readOnly = false) +// void deleteFishingOperation(String id); - List<String> getAllFishingOperationIds(String cruiseId); - - List<FishingOperation> getAllFishingOperation(String cruiseId); - - FishingOperation getFishingOperation(String id); - - List<Vessel> getFishingOperationSecondaryVessel(String fishingOperationId); - - @Transactional(readOnly = false) - FishingOperation createFishingOperation(FishingOperation bean); - - @Transactional(readOnly = false) - FishingOperation saveFishingOperation(FishingOperation bean); - - @Transactional(readOnly = false) - void deleteFishingOperation(String id); - //------------------------------------------------------------------------// //-- CatchBatch methods --// //------------------------------------------------------------------------// - /** - * @param operationId id of the fishing operation - * @return {@code true} if there is a catchBatch for the given fishing - * operation, {@code false} otherwise. - * @since 2.2 - */ - boolean isFishingOperationWithCatchBatch(String operationId); +// /** +// * @param operationId id of the fishing operation +// * @return {@code true} if there is a catchBatch for the given fishing +// * operation, {@code false} otherwise. +// * @since 2.2 +// */ +// boolean isFishingOperationWithCatchBatch(String operationId); +// +// /** +// * Get the catchBatch from the fishing Operation id. +// * <p/> +// * If batch model is not compatible with Tutti then a +// * {@link InvalidBatchModelException} will be thrown. +// * +// * @param id id of the fihsing operation +// * @return found catchbatch +// * @throws InvalidBatchModelException if batch model is not compatible +// * with Tutti. +// */ +// CatchBatch getCatchBatchFromFishingOperation(String id) throws InvalidBatchModelException; +// +// /** +// * Create the given CatchBatch and return it. +// * +// * @param bean catchBatch to create +// * @return created catchBatch +// */ +// @Transactional(readOnly = false) +// CatchBatch createCatchBatch(CatchBatch bean); +// +// /** +// * Save the given catchBatch and return it. +// * +// * @param bean batch to save +// * @return the saved catchBatch +// */ +// @Transactional(readOnly = false) +// CatchBatch saveCatchBatch(CatchBatch bean); - /** - * Get the catchBatch from the fishing Operation id. - * <p/> - * If batch model is not compatible with Tutti then a - * {@link InvalidBatchModelException} will be thrown. - * - * @param id id of the fihsing operation - * @return found catchbatch - * @throws InvalidBatchModelException if batch model is not compatible - * with Tutti. - */ - CatchBatch getCatchBatchFromFishingOperation(String id) throws InvalidBatchModelException; - - /** - * Create the given CatchBatch and return it. - * - * @param bean catchBatch to create - * @return created catchBatch - */ - @Transactional(readOnly = false) - CatchBatch createCatchBatch(CatchBatch bean); - - /** - * Save the given catchBatch and return it. - * - * @param bean batch to save - * @return the saved catchBatch - */ - @Transactional(readOnly = false) - CatchBatch saveCatchBatch(CatchBatch bean); - //------------------------------------------------------------------------// //-- Species Batch methods --// //------------------------------------------------------------------------// - /** - * Get the batch parent of all root {@link SpeciesBatch} for the given - * fishing operation. - * <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 - * @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; +// /** +// * Get the batch parent of all root {@link SpeciesBatch} for the given +// * fishing operation. +// * <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 +// * @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; +// +// @Transactional(readOnly = false) +// SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId); +// +// @Transactional(readOnly = false) +// SpeciesBatch saveSpeciesBatch(SpeciesBatch bean); +// +// @Transactional(readOnly = false) +// void deleteSpeciesBatch(String id); +// +// @Transactional(readOnly = false) +// void deleteSpeciesSubBatch(String id); +// +// @Transactional(readOnly = false) +// void changeSpeciesBatchSpecies(String batchId, Species species); +// +// /** +// * Get all frequencies for the given species batch. +// * +// * @param speciesBatchId the id of the species batch to seek. +// * @return the list of frequencies for the given specues batch id +// * @since 1.0 +// */ +// List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId); +// +// /** +// * Get all frequencies for the given root species batch container. +// * +// * @param batchContainer the root batch containter +// * @return the list of species frequencies indexed by their species +// * @since 3.3 +// */ +// Multimap<Species, SpeciesBatchFrequency> getAllSpeciesBatchFrequencyForBatch(BatchContainer<SpeciesBatch> batchContainer); +// +// /** +// * Save all given {@link SpeciesBatchFrequency} into the given +// * {@code speciesBatchId}. If some are not existing then creates them. +// * <p/> +// * <strong>Note:</strong> This will as a side effect remove all previous frequency for this species batch. +// * +// * @param speciesBatchId id of the {@link SpeciesBatch} to use +// * @param frequencies list of frequencies to create or update +// * @return the persisted list of frequencies +// * @since 1.0 +// */ +// @Transactional(readOnly = false) +// List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId, +// List<SpeciesBatchFrequency> frequencies); - @Transactional(readOnly = false) - SpeciesBatch createSpeciesBatch(SpeciesBatch bean, String parentBatchId); - - @Transactional(readOnly = false) - SpeciesBatch saveSpeciesBatch(SpeciesBatch bean); - - @Transactional(readOnly = false) - void deleteSpeciesBatch(String id); - - @Transactional(readOnly = false) - void deleteSpeciesSubBatch(String id); - - @Transactional(readOnly = false) - void changeSpeciesBatchSpecies(String batchId, Species species); - - /** - * Get all frequencies for the given species batch. - * - * @param speciesBatchId the id of the species batch to seek. - * @return the list of frequencies for the given specues batch id - * @since 1.0 - */ - List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId); - - /** - * Get all frequencies for the given root species batch container. - * - * @param batchContainer the root batch containter - * @return the list of species frequencies indexed by their species - * @since 3.3 - */ - Multimap<Species, SpeciesBatchFrequency> getAllSpeciesBatchFrequencyForBatch(BatchContainer<SpeciesBatch> batchContainer); - - /** - * Save all given {@link SpeciesBatchFrequency} into the given - * {@code speciesBatchId}. If some are not existing then creates them. - * <p/> - * <strong>Note:</strong> This will as a side effect remove all previous frequency for this species batch. - * - * @param speciesBatchId id of the {@link SpeciesBatch} to use - * @param frequencies list of frequencies to create or update - * @return the persisted list of frequencies - * @since 1.0 - */ - @Transactional(readOnly = false) - List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId, - List<SpeciesBatchFrequency> frequencies); - //------------------------------------------------------------------------// //-- Benthos Batch methods --// //------------------------------------------------------------------------// - /** - * Get the batch parent of all root {@link BenthosBatch} for the given - * fishing operation. - * <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 - * @return the list of root {@link BenthosBatch} - * @throws InvalidBatchModelException if batch does not respect the sample category model - * @since 2.4 - */ - BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, - SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException; +// /** +// * Get the batch parent of all root {@link BenthosBatch} for the given +// * fishing operation. +// * <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 +// * @return the list of root {@link BenthosBatch} +// * @throws InvalidBatchModelException if batch does not respect the sample category model +// * @since 2.4 +// */ +// BatchContainer<BenthosBatch> getRootBenthosBatch(String fishingOperationId, +// SampleCategoryModel sampleCategoryModel) throws InvalidBatchModelException; +// +// @Transactional(readOnly = false) +// BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId); +// +// @Transactional(readOnly = false) +// BenthosBatch saveBenthosBatch(BenthosBatch bean); +// +// @Transactional(readOnly = false) +// void deleteBenthosBatch(String id); +// +// @Transactional(readOnly = false) +// void deleteBenthosSubBatch(String id); +// +// @Transactional(readOnly = false) +// void changeBenthosBatchSpecies(String batchId, Species species); +// +// /** +// * Get all frequencies for the given species batch. +// * +// * @param benthosBatchId the id of the species batch to seek. +// * @return the list of frequencies for the given specues batch id +// * @since 1.0 +// */ +// List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId); +// +// /** +// * Get all frequencies for the given root benthos batch container. +// * +// * @param batchContainer the root batch containter +// * @return the list of benthos frequencies indexed by their species +// * @since 3.3 +// */ +// Multimap<Species, BenthosBatchFrequency> getAllBenthosBatchFrequencyForBatch(BatchContainer<BenthosBatch> batchContainer); +// +// /** +// * Save all given {@link BenthosBatchFrequency} into the given +// * {@code benthosBatchId}. If some are not existing then creates them. +// * <p/> +// * <strong>Note:</strong> This will as a side effect remove all previous frequency for this species batch. +// * +// * @param benthosBatchId id of the {@link BenthosBatch} to use +// * @param frequencies list of frequencies to create or update +// * @return the persisted list of frequencies +// * @since 1.0 +// */ +// @Transactional(readOnly = false) +// List<BenthosBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId, +// List<BenthosBatchFrequency> frequencies); - @Transactional(readOnly = false) - BenthosBatch createBenthosBatch(BenthosBatch bean, String parentBatchId); - - @Transactional(readOnly = false) - BenthosBatch saveBenthosBatch(BenthosBatch bean); - - @Transactional(readOnly = false) - void deleteBenthosBatch(String id); - - @Transactional(readOnly = false) - void deleteBenthosSubBatch(String id); - - @Transactional(readOnly = false) - void changeBenthosBatchSpecies(String batchId, Species species); - - /** - * Get all frequencies for the given species batch. - * - * @param benthosBatchId the id of the species batch to seek. - * @return the list of frequencies for the given specues batch id - * @since 1.0 - */ - List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId); - - /** - * Get all frequencies for the given root benthos batch container. - * - * @param batchContainer the root batch containter - * @return the list of benthos frequencies indexed by their species - * @since 3.3 - */ - Multimap<Species, BenthosBatchFrequency> getAllBenthosBatchFrequencyForBatch(BatchContainer<BenthosBatch> batchContainer); - - /** - * Save all given {@link BenthosBatchFrequency} into the given - * {@code benthosBatchId}. If some are not existing then creates them. - * <p/> - * <strong>Note:</strong> This will as a side effect remove all previous frequency for this species batch. - * - * @param benthosBatchId id of the {@link BenthosBatch} to use - * @param frequencies list of frequencies to create or update - * @return the persisted list of frequencies - * @since 1.0 - */ - @Transactional(readOnly = false) - List<BenthosBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId, - List<BenthosBatchFrequency> frequencies); - //------------------------------------------------------------------------// //-- MarineLitter Batch methods --// //------------------------------------------------------------------------// - /** - * Get the batch parent of all root {@link MarineLitterBatch} for the given - * fishing operation. - * <p/> - * <strong>Note:</strong> All childs of the batch should be loaded here. - * - * @param fishingOperationId if of the fishing operation to seek - * @return the list of root {@link MarineLitterBatch} - * @since 1.3 - */ - BatchContainer<MarineLitterBatch> getRootMarineLitterBatch(String fishingOperationId); +// /** +// * Get the batch parent of all root {@link MarineLitterBatch} for the given +// * fishing operation. +// * <p/> +// * <strong>Note:</strong> All childs of the batch should be loaded here. +// * +// * @param fishingOperationId if of the fishing operation to seek +// * @return the list of root {@link MarineLitterBatch} +// * @since 1.3 +// */ +// BatchContainer<MarineLitterBatch> getRootMarineLitterBatch(String fishingOperationId); +// +// @Transactional(readOnly = false) +// MarineLitterBatch createMarineLitterBatch(MarineLitterBatch bean); +// +// @Transactional(readOnly = false) +// MarineLitterBatch saveMarineLitterBatch(MarineLitterBatch bean); +// +// @Transactional(readOnly = false) +// void deleteMarineLitterBatch(String id); - @Transactional(readOnly = false) - MarineLitterBatch createMarineLitterBatch(MarineLitterBatch bean); - - @Transactional(readOnly = false) - MarineLitterBatch saveMarineLitterBatch(MarineLitterBatch bean); - - @Transactional(readOnly = false) - void deleteMarineLitterBatch(String id); - //------------------------------------------------------------------------// //-- Accidental Batch methods --// //------------------------------------------------------------------------// - List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId); +// List<AccidentalBatch> getAllAccidentalBatch(String fishingOperationId); +// +// @Transactional(readOnly = false) +// AccidentalBatch createAccidentalBatch(AccidentalBatch bean); +// +// @Transactional(readOnly = false) +// AccidentalBatch saveAccidentalBatch(AccidentalBatch bean); +// +// @Transactional(readOnly = false) +// void deleteAccidentalBatch(String id); - @Transactional(readOnly = false) - AccidentalBatch createAccidentalBatch(AccidentalBatch bean); - - @Transactional(readOnly = false) - AccidentalBatch saveAccidentalBatch(AccidentalBatch bean); - - @Transactional(readOnly = false) - void deleteAccidentalBatch(String id); - //------------------------------------------------------------------------// //-- IndividualObservation Batch methods --// //------------------------------------------------------------------------// - List<IndividualObservationBatch> getAllIndividualObservationBatch(String fishingOperationId); - - @Transactional(readOnly = false) - IndividualObservationBatch createIndividualObservationBatch(IndividualObservationBatch bean); - - @Transactional(readOnly = false) - IndividualObservationBatch saveIndividualObservationBatch(IndividualObservationBatch bean); - - @Transactional(readOnly = false) - void deleteIndividualObservationBatch(String id); +// List<IndividualObservationBatch> getAllIndividualObservationBatch(String fishingOperationId); +// +// @Transactional(readOnly = false) +// IndividualObservationBatch createIndividualObservationBatch(IndividualObservationBatch bean); +// +// @Transactional(readOnly = false) +// IndividualObservationBatch saveIndividualObservationBatch(IndividualObservationBatch bean); +// +// @Transactional(readOnly = false) +// void deleteIndividualObservationBatch(String id); } 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -25,14 +25,8 @@ */ import com.google.common.base.Predicate; -import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; -import fr.ifremer.adagio.core.dao.technical.DatabaseSchemaDao; -import fr.ifremer.adagio.core.dao.technical.DatabaseSchemaUpdateException; -import fr.ifremer.adagio.core.dao.technical.VersionNotFoundException; -import fr.ifremer.adagio.core.service.technical.CacheService; -import fr.ifremer.adagio.core.service.technical.sanity.DatabaseSanityService; import fr.ifremer.tutti.persistence.entities.CaracteristicMap; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; @@ -73,16 +67,15 @@ import fr.ifremer.tutti.persistence.service.ProtocolPersistenceService; import fr.ifremer.tutti.persistence.service.ReferentialPersistenceService; import fr.ifremer.tutti.persistence.service.SpeciesBatchPersistenceService; +import fr.ifremer.tutti.persistence.service.TechnicalPersistenceService; import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile; import fr.ifremer.tutti.persistence.service.TuttiPersistenceServiceLocator; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.jaxx.application.ApplicationTechnicalException; import org.nuiton.util.Version; -import org.nuiton.util.VersionUtil; -import org.springframework.beans.factory.annotation.Autowired; +import javax.annotation.Resource; import java.io.File; import java.io.IOException; import java.util.Collection; @@ -101,53 +94,48 @@ private static final Log log = LogFactory.getLog(TuttiPersistenceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; - @Autowired + @Resource(name = "programPersistenceService") protected ProgramPersistenceService programService; - @Autowired + @Resource(name = "cruisePersistenceService") protected CruisePersistenceService cruiseService; - @Autowired + @Resource(name = "fishingOperationPersistenceService") protected FishingOperationPersistenceService fishingOperationService; - @Autowired + @Resource(name = "batchPersistenceService") protected CatchBatchPersistenceService catchBatchService; - @Autowired + @Resource(name = "speciesBatchPersistenceService") protected SpeciesBatchPersistenceService speciesBatchService; - @Autowired + @Resource(name = "benthosBatchPersistenceService") protected BenthosBatchPersistenceService benthosBatchService; - @Autowired +// @Resource(name = "commonBatchPersistenceService") +// protected CommonBatchPersistenceService commonBatchService; + + @Resource(name = "marineLitterBatchPersistenceService") protected MarineLitterBatchPersistenceService marineLitterBatchService; - @Autowired + @Resource(name = "accidentalBatchPersistenceService") protected AccidentalBatchPersistenceService accidentalBatchService; - @Autowired + @Resource(name = "individualObservationBatchPersistenceService") protected IndividualObservationBatchPersistenceService individualObservationBatchService; - @Autowired + @Resource(name = "protocolPersistenceService") protected ProtocolPersistenceService protocolService; - @Autowired + @Resource(name = "attachmentPersistenceService") protected AttachmentPersistenceService attachmentService; - @Autowired - protected DatabaseSanityService databaseSanityService; + @Resource(name = "technicalPersistenceService") + protected TechnicalPersistenceService technicalPersistenceService; - @Autowired - protected CacheService cacheService; - - @Autowired - protected DatabaseSchemaDao databaseSchemaDao; - - protected Predicate<SpeciesAbleBatch> batchVracPredicate; - @Override public String getImplementationName() { return "Persistence Adagio implementation"; @@ -155,64 +143,37 @@ @Override public void clearAllCaches() { - cacheService.clearAllCaches(); + technicalPersistenceService.clearAllCaches(); } @Override public TuttiEnumerationFile getEnumerationFile() { - return referentialService.getEnumerationFile(); + return technicalPersistenceService.getEnumerationFile(); } @Override public <V> V invoke(Callable<V> call) { - - try { - V result = call.call(); - return result; - } catch (RuntimeException e) { - throw e; - } catch (Exception e) { - throw new ApplicationTechnicalException(e); - } + return technicalPersistenceService.invoke(call); } @Override public Version getDbVersion() { - Version version = getDbVersion0(); - return version; + return technicalPersistenceService.getDbVersion(); } - private Version getDbVersion0() { - fr.ifremer.adagio.core.dao.technical.Version version; - try { - version = databaseSchemaDao.getSchemaVersion(); - } catch (VersionNotFoundException e) { - if (log.isErrorEnabled()) { - log.error("Could not find db version", e); - } - version = null; - } - return version == null ? null : VersionUtil.valueOf(version.toString()); - } - @Override public Version getApplicationVersion() { - fr.ifremer.adagio.core.dao.technical.Version version = databaseSchemaDao.getSchemaVersionIfUpdate(); - return VersionUtil.valueOf(version.toString()); + return technicalPersistenceService.getApplicationVersion(); } @Override public void updateSchema() { - try { - databaseSchemaDao.updateSchema(); - } catch (DatabaseSchemaUpdateException e) { - throw new ApplicationTechnicalException(e.getCause()); - } + technicalPersistenceService.updateSchema(); } @Override public void sanityDb() { - databaseSanityService.sanity(); + technicalPersistenceService.sanityDb(); } @Override @@ -227,15 +188,12 @@ catchBatchService.init(); speciesBatchService.init(); benthosBatchService.init(); +// commonBatchService.init(); marineLitterBatchService.init(); accidentalBatchService.init(); individualObservationBatchService.init(); protocolService.init(); attachmentService.init(); - - TuttiEnumerationFile enumerationFile = getEnumerationFile(); - - batchVracPredicate = TuttiEntities.newSpeciesAbleBatchCategoryPredicate(enumerationFile.PMFM_ID_SORTED_UNSORTED, enumerationFile.QUALITATIVE_VRAC_ID); } protected boolean close; @@ -257,6 +215,7 @@ catchBatchService.close(); speciesBatchService.close(); benthosBatchService.close(); +// commonBatchService.close(); marineLitterBatchService.close(); accidentalBatchService.close(); individualObservationBatchService.close(); @@ -337,6 +296,11 @@ } @Override + public Species getSpeciesByReferenceTaxonId(Integer referenceTaxonId) { + return referentialService.getSpeciesByReferenceTaxonId(referenceTaxonId); + } + + @Override public List<Caracteristic> getAllCaracteristic() { return referentialService.getAllCaracteristic(); } @@ -433,12 +397,12 @@ @Override public boolean isVracBatch(SpeciesAbleBatch speciesBatch) { - return batchVracPredicate.apply(speciesBatch); + return referentialService.isVracBatch(speciesBatch); } @Override public Predicate<SpeciesAbleBatch> getVracBatchPredicate() { - return batchVracPredicate; + return referentialService.getVracBatchPredicate(); } @Override @@ -482,6 +446,11 @@ } @Override + public TuttiLocation getLocation(String id) { + return referentialService.getLocation(id); + } + + @Override public List<Species> importTemporarySpecies(List<Species> species) { return referentialService.importTemporarySpecies(species); } @@ -531,6 +500,11 @@ attachmentService.deleteAttachment(attachmentId); } + @Override + public void deleteAllAttachment(AttachementObjectTypeEnum objectType, Integer... objectIds) { + attachmentService.deleteAllAttachment(objectType, objectIds); + } + //------------------------------------------------------------------------// //-- Program methods --// //------------------------------------------------------------------------// @@ -626,6 +600,11 @@ } @Override + public List<String> getAllProtocolId() { + return protocolService.getAllProtocolId(); + } + + @Override public TuttiProtocol saveProtocol(TuttiProtocol bean) { return protocolService.saveProtocol(bean); } @@ -717,6 +696,11 @@ } @Override + public Collection<FishingOperation> saveFishingOperations(Collection<FishingOperation> beans) { + return fishingOperationService.saveFishingOperations(beans); + } + + @Override public void deleteFishingOperation(String id) { fishingOperationService.deleteFishingOperation(id); } @@ -745,6 +729,11 @@ return catchBatchService.saveCatchBatch(bean); } + @Override + public void deleteCatchBatch(String fishingOperationId) { + catchBatchService.deleteCatchBatch(fishingOperationId); + } + //------------------------------------------------------------------------// //-- Species Batch methods --// //------------------------------------------------------------------------// @@ -786,27 +775,9 @@ @Override public Multimap<Species, SpeciesBatchFrequency> getAllSpeciesBatchFrequencyForBatch(BatchContainer<SpeciesBatch> batchContainer) { - - Multimap<Species, SpeciesBatchFrequency> result = ArrayListMultimap.create(); - for (SpeciesBatch speciesBatch : batchContainer.getChildren()) { - getAllSpeciesBatchFrequencyForBatch(speciesBatch, result); - } - return result; + return speciesBatchService.getAllSpeciesBatchFrequencyForBatch(batchContainer); } - protected void getAllSpeciesBatchFrequencyForBatch(SpeciesBatch batch, - Multimap<Species, SpeciesBatchFrequency> result) { - - List<SpeciesBatchFrequency> speciesBatchFrequency = getAllSpeciesBatchFrequency(batch.getId()); - result.putAll(batch.getSpecies(), speciesBatchFrequency); - - if (!batch.isChildBatchsEmpty()) { - for (SpeciesBatch child : batch.getChildBatchs()) { - getAllSpeciesBatchFrequencyForBatch(child, result); - } - } - } - @Override public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency(String speciesBatchId, List<SpeciesBatchFrequency> frequencies) { return speciesBatchService.saveSpeciesBatchFrequency(speciesBatchId, frequencies); @@ -853,28 +824,9 @@ @Override public Multimap<Species, BenthosBatchFrequency> getAllBenthosBatchFrequencyForBatch(BatchContainer<BenthosBatch> batchContainer) { - - Multimap<Species, BenthosBatchFrequency> result = ArrayListMultimap.create(); - - for (BenthosBatch speciesBatch : batchContainer.getChildren()) { - getAllBenthosBatchFrequencyForBatch(speciesBatch, result); - } - return result; + return benthosBatchService.getAllBenthosBatchFrequencyForBatch(batchContainer); } - protected void getAllBenthosBatchFrequencyForBatch(BenthosBatch batch, - Multimap<Species, BenthosBatchFrequency> result) { - - List<BenthosBatchFrequency> speciesBatchFrequency = getAllBenthosBatchFrequency(batch.getId()); - result.putAll(batch.getSpecies(), speciesBatchFrequency); - - if (!batch.isChildBatchsEmpty()) { - for (BenthosBatch child : batch.getChildBatchs()) { - getAllBenthosBatchFrequencyForBatch(child, result); - } - } - } - @Override public List<BenthosBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId, List<BenthosBatchFrequency> frequencies) { @@ -929,6 +881,11 @@ accidentalBatchService.deleteAccidentalBatch(id); } + @Override + public void deleteAccidentalBatchForFishingOperation(String fishingOperationId) { + accidentalBatchService.deleteAccidentalBatchForFishingOperation(fishingOperationId); + } + //------------------------------------------------------------------------// //-- IndividualObservation Batch methods --// //------------------------------------------------------------------------// @@ -953,6 +910,11 @@ individualObservationBatchService.deleteIndividualObservationBatch(id); } + @Override + public void deleteIndividualObservationBatchForFishingOperation(String fishingOperationId) { + individualObservationBatchService.deleteIndividualObservationBatchForFishingOperation(fishingOperationId); + } + //------------------------------------------------------------------------// //-- Internal methods --// //------------------------------------------------------------------------// 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -679,6 +679,46 @@ public void close() throws IOException { } + @Override + public void deleteAccidentalBatchForFishingOperation(String fishingOperationId) { + throw notImplemented(); + } + + @Override + public void deleteAllAttachment(AttachementObjectTypeEnum objectType, Integer... objectIds) { + throw notImplemented(); + } + + @Override + public void deleteCatchBatch(String fishingOperationId) { + throw notImplemented(); + } + + @Override + public Collection<FishingOperation> saveFishingOperations(Collection<FishingOperation> beans) { + throw notImplemented(); + } + + @Override + public void deleteIndividualObservationBatchForFishingOperation(String fishingOperationId) { + throw notImplemented(); + } + + @Override + public List<String> getAllProtocolId() { + throw notImplemented(); + } + + @Override + public TuttiLocation getLocation(String id) { + throw notImplemented(); + } + + @Override + public Species getSpeciesByReferenceTaxonId(Integer referenceTaxonId) { + throw notImplemented(); + } + protected RuntimeException notImplemented() { return new RuntimeException("method not implemented"); } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/TuttiEntities.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -418,7 +418,7 @@ * Take a {@code 5} digit context beacuse of rounding stuff to * get exactly 4 correct digits. */ - private static final MathContext MATH_CONTEXT_4_DIGIT = new MathContext(5); + private static final MathContext MATH_CONTEXT_4_DIGIT = new MathContext(4); private static DecimalFormatSymbols symbols; Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/CaracteristicQualitativeValues.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/CaracteristicQualitativeValues.java (rev 0) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/CaracteristicQualitativeValues.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -0,0 +1,17 @@ +package fr.ifremer.tutti.persistence.entities.referential; + +public class CaracteristicQualitativeValues extends AbstractCaracteristicQualitativeValues { + + public static CaracteristicQualitativeValue getCaracteristicQualitativeValue(Caracteristic caracteristic, Integer id) { + CaracteristicQualitativeValue result = null; + if (id != null && !caracteristic.isQualitativeValueEmpty()) { + for (CaracteristicQualitativeValue caracteristicQualitativeValue : caracteristic.getQualitativeValue()) { + if (id.equals(caracteristicQualitativeValue.getIdAsInt())) { + result = caracteristicQualitativeValue; + break; + } + } + } + return result; + } +} \ No newline at end of file Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/referential/CaracteristicQualitativeValues.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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AbstractPersistenceService.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -33,8 +33,8 @@ import org.hibernate.SessionFactory; import org.hibernate.classic.Session; import org.hibernate.type.Type; -import org.springframework.beans.factory.annotation.Autowired; +import javax.annotation.Resource; import java.io.Serializable; import java.sql.Timestamp; import java.util.Calendar; @@ -61,10 +61,10 @@ * * @since 0.3 */ - @Autowired + @Resource protected SessionFactory sessionFactory; - @Autowired + @Resource(name = "tuttiEnumerationFile") protected TuttiEnumerationFile enumeration; protected TuttiConfiguration config; @@ -77,7 +77,8 @@ Preconditions.checkNotNull( config, "No config found in " + - TuttiConfiguration.class.getName()); + TuttiConfiguration.class.getName() + ); } } 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -47,7 +47,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.type.IntegerType; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Service; @@ -68,7 +67,7 @@ private static final Log log = LogFactory.getLog(AccidentalBatchPersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; @Resource(name = "samplePersistenceHelper") Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -30,7 +30,6 @@ import fr.ifremer.adagio.core.dao.data.measure.file.MeasurementFileDao; import fr.ifremer.adagio.core.dao.referential.ObjectTypeImpl; import fr.ifremer.adagio.core.dao.referential.QualityFlagImpl; -import org.nuiton.jaxx.application.ApplicationIOUtil; import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.Attachments; @@ -39,7 +38,7 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.type.IntegerType; import org.hibernate.type.StringType; -import org.springframework.beans.factory.annotation.Autowired; +import org.nuiton.jaxx.application.ApplicationIOUtil; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.dao.InvalidDataAccessResourceUsageException; import org.springframework.stereotype.Service; @@ -68,7 +67,7 @@ protected static final String ATTACHMENT_PATH_FORMAT = "%1$s/OBJ%2$s/%1$s-OBJ%2$s-%3$s.%4$s"; - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; @Resource(name = "measurementFileDao") 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceService.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -24,6 +24,7 @@ * #L% */ +import com.google.common.collect.Multimap; import fr.ifremer.tutti.persistence.InvalidBatchModelException; import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; @@ -97,6 +98,15 @@ List<BenthosBatchFrequency> getAllBenthosBatchFrequency(String benthosBatchId); /** + * Get all frequencies for the given root benthos batch container. + * + * @param batchContainer the root batch containter + * @return the list of benthos frequencies indexed by their species + * @since 3.3 + */ + Multimap<Species, BenthosBatchFrequency> getAllBenthosBatchFrequencyForBatch(BatchContainer<BenthosBatch> batchContainer); + + /** * Save all given {@link BenthosBatchFrequency} into the given * {@code benthosBatchId}. If some are not existing then creates them. * <p/> 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -25,7 +25,9 @@ */ import com.google.common.base.Preconditions; +import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import fr.ifremer.adagio.core.dao.data.batch.Batch; import fr.ifremer.adagio.core.dao.data.batch.CatchBatch; @@ -46,10 +48,10 @@ 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.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; @@ -76,12 +78,18 @@ private static final Log log = LogFactory.getLog(BenthosBatchPersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; @Resource(name = "batchPersistenceHelper") protected BatchPersistenceHelper batchHelper; + @Resource(name = "batchTreeHelper") + protected BatchTreeHelper batchTreeHelper; + + @Resource(name = "measurementPersistenceHelper") + protected MeasurementPersistenceHelper measurementPersistenceHelper; + protected SampleCategoryModel sampleCategoryModel; //------------------------------------------------------------------------// @@ -103,13 +111,14 @@ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false); // Vrac / Benthos - 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 - ); + 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>(); if (vracBenthosBatch != null) { @@ -134,12 +143,13 @@ } // Hors-Vrac / Benthos - 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 - ); + 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; @@ -274,6 +284,28 @@ } @Override + public Multimap<Species, BenthosBatchFrequency> getAllBenthosBatchFrequencyForBatch(BatchContainer<BenthosBatch> batchContainer) { + Multimap<Species, BenthosBatchFrequency> result = ArrayListMultimap.create(); + for (BenthosBatch speciesBatch : batchContainer.getChildren()) { + getAllSpeciesBatchFrequencyForBatch(speciesBatch, result); + } + return result; + } + + protected void getAllSpeciesBatchFrequencyForBatch(BenthosBatch batch, + Multimap<Species, BenthosBatchFrequency> result) { + + List<BenthosBatchFrequency> speciesBatchFrequency = getAllBenthosBatchFrequency(batch.getId()); + result.putAll(batch.getSpecies(), speciesBatchFrequency); + + if (!batch.isChildBatchsEmpty()) { + for (BenthosBatch child : batch.getChildBatchs()) { + getAllSpeciesBatchFrequencyForBatch(child, result); + } + } + } + + @Override public List<BenthosBatchFrequency> saveBenthosBatchFrequency(String benthosBatchId, List<BenthosBatchFrequency> frequencies) { Preconditions.checkNotNull(benthosBatchId); @@ -386,7 +418,7 @@ if (source.getSortingMeasurements().size() == 1) { sm = source.getSortingMeasurements().iterator().next(); } else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) { - sm = batchHelper.getInheritedSortingMeasurement(source); + sm = measurementPersistenceHelper.getInheritedSortingMeasurement(source); } if (sm != null) { boolean isSamplingCategory = sampleCategoryModel.containsCategoryId( @@ -521,12 +553,12 @@ // Weight or SampleCategoryWeight if (source.getWeight() == null && source.getSampleCategoryWeight() != null) { - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getSampleCategoryWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) { - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); @@ -541,7 +573,7 @@ samplingRatioText = samplingRatioText.replaceAll(",", "."); target.setSamplingRatioText(samplingRatioText); target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight()); - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); @@ -552,7 +584,7 @@ Integer pmfmId = source.getSampleCategoryId(); // Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch) if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) { - SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement( + SortingMeasurement sortingMeasurement = measurementPersistenceHelper.setSortingMeasurement( target, pmfmId, source.getSampleCategoryValue()); @@ -630,7 +662,7 @@ // Weight or SampleCategoryWeight if (source.getWeight() != null) { - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); @@ -639,7 +671,7 @@ // Sorting measurement if ((source.getLengthStepCaracteristic() != null && source.getLengthStep() != null)) { Integer pmfmId = source.getLengthStepCaracteristic().getIdAsInt(); - SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, pmfmId, + SortingMeasurement sortingMeasurement = measurementPersistenceHelper.setSortingMeasurement(target, pmfmId, source.getLengthStep()); notChangedSortingMeasurements.remove(sortingMeasurement); } 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CatchBatchPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -36,11 +36,11 @@ import fr.ifremer.tutti.persistence.entities.data.CatchBatch; import fr.ifremer.tutti.persistence.entities.data.CatchBatchBean; import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper; +import fr.ifremer.tutti.persistence.service.batch.BatchTreeHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.FlushMode; import org.hibernate.type.IntegerType; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Service; @@ -57,15 +57,21 @@ private static final Log log = LogFactory.getLog(CatchBatchPersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; - @Autowired + @Resource(name = "attachmentPersistenceService") protected AttachmentPersistenceService attachmentPersistenceService; @Resource(name = "batchPersistenceHelper") protected BatchPersistenceHelper batchHelper; + @Resource(name = "batchTreeHelper") + protected BatchTreeHelper batchTreeHelper; + + @Resource(name = "measurementPersistenceHelper") + protected MeasurementPersistenceHelper measurementPersistenceHelper; + //------------------------------------------------------------------------// //-- CatchBatch methods --// //------------------------------------------------------------------------// @@ -95,11 +101,12 @@ } // Vrac - SortingBatch vracBatch = batchHelper.getSortingBatch( - source, - "Vrac", - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_VRAC_ID); + SortingBatch vracBatch = batchTreeHelper.getVracBatch(source); +// SortingBatch vracBatch = batchHelper.getSortingBatch( +// source, +// "Vrac", +// enumeration.PMFM_ID_SORTED_UNSORTED, +// enumeration.QUALITATIVE_VRAC_ID); if (vracBatch != null) { @@ -107,33 +114,36 @@ result.setCatchTotalSortedTremisWeight(vracBatch.getWeightBeforeSampling()); // Vrac > Species - SortingBatch vracSpeciesBatch = batchHelper.getSortingBatch( - vracBatch, - "Vrac > Species", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_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 - SortingBatch inertBatch = batchHelper.getSortingBatch( - vracSpeciesBatch, - "Vrac > Species > Inert", - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_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 - 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); + 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()); @@ -141,32 +151,35 @@ } // Vrac > Benthos - SortingBatch vracBenthosBatch = batchHelper.getSortingBatch( - vracBatch, - "Vrac > Benthos", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_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 - SortingBatch inertBatch = batchHelper.getSortingBatch( - vracBenthosBatch, - "Vrac > Benthos > Inert", - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_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 - 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); + 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()); @@ -175,34 +188,38 @@ } // Hors Vrac - SortingBatch horsVracBatch = batchHelper.getSortingBatch( - source, - "Hors Vrac", - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_HORS_VRAC_ID); + 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 - batchHelper.getSortingBatch( - horsVracBatch, - "Hors Vrac > Species", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + batchTreeHelper.getSpeciesHorsVracRootBatch(horsVracBatch); +// batchHelper.getSortingBatch( +// horsVracBatch, +// "Hors Vrac > Species", +// enumeration.PMFM_ID_SORTING_TYPE, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); // Hors Vrac > Benthos - batchHelper.getSortingBatch( - horsVracBatch, - "Hors Vrac > Benthos", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + batchTreeHelper.getBenthosHorsVracRootBatch(horsVracBatch); +// batchHelper.getSortingBatch( +// horsVracBatch, +// "Hors Vrac > Benthos", +// enumeration.PMFM_ID_SORTING_TYPE, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); // Hors Vrac > MarineLitter - SortingBatch marineLitterBatch = batchHelper.getSortingBatch( - horsVracBatch, - "Hors Vrac > MarineLitter", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER); + 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()); @@ -210,11 +227,12 @@ } // Non trié - SortingBatch unsortedBatch = batchHelper.getSortingBatch( - source, - "Unsorted", - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_UNSORTED_ID); + 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()); @@ -310,7 +328,7 @@ // Total Weight if (source.getCatchTotalWeight() != null) { - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getCatchTotalWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); @@ -321,9 +339,11 @@ quantificationMeasurements.removeAll(notChangedQuantificationMeasurements); } - SortingBatch vracBatch = batchHelper.getVracBatch(target); + SortingBatch vracBatch = batchTreeHelper.getVracBatch(target); +// SortingBatch vracBatch = batchHelper.getVracBatch(target); - SortingBatch horsVracBatch = batchHelper.getHorsVracBatch(target); + SortingBatch horsVracBatch = batchTreeHelper.getHorsVracBatch(target); +// SortingBatch horsVracBatch = batchHelper.getHorsVracBatch(target); SortingBatch horsVracSpeciesRootBatch = null; SortingBatch horsVracBenthosRootBatch = null; @@ -331,12 +351,12 @@ if (horsVracBatch != null) { - horsVracSpeciesRootBatch = batchHelper.getSpeciesHorsVracRootBatch( - horsVracBatch); - horsVracBenthosRootBatch = batchHelper.getBenthosHorsVracRootBatch( - horsVracBatch); - horsVracMarineLitterRootBatch = batchHelper.getMarineLitterRootBatch( - horsVracBatch); + 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; @@ -350,26 +370,27 @@ SortingBatch benthosVracAliveItemizeRootBatch = null; if (vracBatch != null) { - speciesVracBatch = batchHelper.getSpeciesVracRootBatch( - vracBatch); + speciesVracBatch = batchTreeHelper.getSpeciesVracRootBatch(vracBatch); +// speciesVracBatch = batchHelper.getSpeciesVracRootBatch(vracBatch); if (speciesVracBatch != null) { - speciesVracAliveNotItemizeRootBatch = batchHelper.getSpeciesVracAliveNotItemizeRootBatch( - speciesVracBatch); - speciesVracInertRootBatch = batchHelper.getSpeciesVracInertRootBatch( - speciesVracBatch); - speciesVracAliveItemizeRootBatch = batchHelper.getSpeciesVracAliveItemizeRootBatch( - speciesVracBatch); + 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 = batchHelper.getBenthosVracRootBatch(vracBatch); + benthosVracBatch = batchTreeHelper.getBenthosVracRootBatch(vracBatch); +// benthosVracBatch = batchHelper.getBenthosVracRootBatch(vracBatch); if (benthosVracBatch != null) { - benthosVracAliveNotItemizeRootBatch = batchHelper.getBenthosVracAliveNotItemizeRootBatch( - benthosVracBatch); - benthosVracInertRootBatch = batchHelper.getBenthosVracInertRootBatch( - benthosVracBatch); - benthosVracAliveItemizeRootBatch = batchHelper.getBenthosVracAliveItemizeRootBatch( - benthosVracBatch); + benthosVracAliveNotItemizeRootBatch = batchTreeHelper.getBenthosVracAliveNotItemizedRootBatch(benthosVracBatch); +// benthosVracAliveNotItemizeRootBatch = batchHelper.getBenthosVracAliveNotItemizedRootBatch(benthosVracBatch); + benthosVracInertRootBatch = batchTreeHelper.getBenthosVracInertRootBatch(benthosVracBatch); +// benthosVracInertRootBatch = batchHelper.getBenthosVracInertRootBatch(benthosVracBatch); + benthosVracAliveItemizeRootBatch = batchTreeHelper.getBenthosVracAliveItemizedRootBatch(benthosVracBatch); +// benthosVracAliveItemizeRootBatch = batchHelper.getBenthosVracAliveItemizeRootBatch(benthosVracBatch); } } @@ -412,8 +433,9 @@ needHorsVracBenthos || needHorsVracMarineLitter; - boolean needUnsorted = batchHelper.getRejectedBatch(target) != null || + boolean needUnsorted = batchTreeHelper.getRejectedBatch(target) != null || source.getCatchTotalRejectedWeight() != null; +// boolean needUnsorted = batchHelper.getRejectedBatch(target) != null || // --------------------------------------------------------------------- // Vrac @@ -421,7 +443,7 @@ if (needVrac) { - vracBatch = batchHelper.getOrCreateVracBatch( + vracBatch = batchTreeHelper.getOrCreateVracBatch( target, source.getCatchTotalSortedCarousselWeight(), source.getCatchTotalSortedTremisWeight()); @@ -431,7 +453,7 @@ // --------------------------------------------------------------------- // Vrac / Species // --------------------------------------------------------------------- - speciesVracBatch = batchHelper.getOrCreateSpeciesVracRootBatch( + speciesVracBatch = batchTreeHelper.getOrCreateSpeciesVracRootBatch( target, vracBatch, source.getSpeciesTotalSortedWeight()); @@ -440,7 +462,7 @@ // --------------------------------------------------------------------- // Vrac / Species / Alive not itemized // --------------------------------------------------------------------- - batchHelper.getOrCreateSpeciesVracAliveNotItemizeRootBatch( + batchTreeHelper.getOrCreateSpeciesVracAliveNotItemizedRootBatch( target, speciesVracBatch, source.getSpeciesTotalLivingNotItemizedWeight()); @@ -450,7 +472,7 @@ // --------------------------------------------------------------------- // Vrac / Species / Inert (not alive) // --------------------------------------------------------------------- - batchHelper.getOrCreateSpeciesVracInertRootBatch( + batchTreeHelper.getOrCreateSpeciesVracInertRootBatch( target, speciesVracBatch, source.getSpeciesTotalInertWeight()); @@ -460,7 +482,7 @@ // --------------------------------------------------------------------- // Vrac / Species / Alive itemized // --------------------------------------------------------------------- - batchHelper.getOrCreateSpeciesVracAliveItemizeRootBatch( + batchTreeHelper.getOrCreateSpeciesVracAliveItemizedRootBatch( target, speciesVracBatch); } @@ -471,7 +493,7 @@ // --------------------------------------------------------------------- // Vrac > Benthos // --------------------------------------------------------------------- - benthosVracBatch = batchHelper.getOrCreateBenthosVracRootBatch( + benthosVracBatch = batchTreeHelper.getOrCreateBenthosVracRootBatch( target, vracBatch, source.getBenthosTotalSortedWeight()); @@ -480,7 +502,7 @@ // --------------------------------------------------------------------- // Vrac / Benthos / Alive not itemized // --------------------------------------------------------------------- - batchHelper.getOrCreateBenthosVracAliveNotItemizeRootBatch( + batchTreeHelper.getOrCreateBenthosVracAliveNotItemizedRootBatch( target, benthosVracBatch, source.getBenthosTotalLivingNotItemizedWeight()); @@ -490,7 +512,7 @@ // --------------------------------------------------------------------- // Vrac / Benthos / Inert (not alive) // --------------------------------------------------------------------- - batchHelper.getOrCreateBenthosVracInertRootBatch( + batchTreeHelper.getOrCreateBenthosVracInertRootBatch( target, benthosVracBatch, source.getBenthosTotalInertWeight()); @@ -500,7 +522,7 @@ // --------------------------------------------------------------------- // Vrac / Benthos / Alive itemized // --------------------------------------------------------------------- - batchHelper.getOrCreateBenthosVracAliveItemizeRootBatch( + batchTreeHelper.getOrCreateBenthosVracAliveItemizedRootBatch( target, benthosVracBatch); } @@ -513,13 +535,13 @@ // --------------------------------------------------------------------- // Hors Vrac // --------------------------------------------------------------------- - horsVracBatch = batchHelper.getOrCreateHorsVracBatch(target); + horsVracBatch = batchTreeHelper.getOrCreateHorsVracBatch(target); if (needHorsVracSpecies) { // --------------------------------------------------------------------- // Hors Vrac > Species // --------------------------------------------------------------------- - batchHelper.getOrCreateSpeciesHorsVracRootBatch( + batchTreeHelper.getOrCreateSpeciesHorsVracRootBatch( target, horsVracBatch); } @@ -528,7 +550,7 @@ // --------------------------------------------------------------------- // Hors Vrac > Benthos // --------------------------------------------------------------------- - batchHelper.getOrCreateBenthosHorsVracRootBatch( + batchTreeHelper.getOrCreateBenthosHorsVracRootBatch( target, horsVracBatch); } @@ -537,7 +559,7 @@ // --------------------------------------------------------------------- // Hors Vrac > MarineLitter // --------------------------------------------------------------------- - batchHelper.getOrCreateMarineLitterRootBatch( + batchTreeHelper.getOrCreateMarineLitterRootBatch( target, horsVracBatch, source.getMarineLitterTotalWeight()); @@ -548,7 +570,7 @@ // --------------------------------------------------------------------- // Unsorted (=rejected) // --------------------------------------------------------------------- - batchHelper.getOrCreateRejectedBatch( + 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/CruisePersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -82,7 +82,6 @@ import org.hibernate.type.ShortType; import org.hibernate.type.StringType; import org.nuiton.jaxx.application.ApplicationBusinessException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Service; @@ -110,16 +109,16 @@ private static final Log log = LogFactory.getLog(CruisePersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; - @Autowired + @Resource(name = "programPersistenceService") protected ProgramPersistenceService programService; - @Autowired + @Resource(name = "fishingOperationPersistenceService") protected FishingOperationPersistenceService fishingOperationService; - @Autowired + @Resource(name = "vesselPersonFeaturesPersistenceHelper") protected VesselPersonFeaturesPersistenceHelper vesselPersonFeaturesPersistenceHelper; @Resource(name = "scientificCruiseDao") @@ -695,7 +694,8 @@ } return result; } - }); + } + ); boolean gearRemoved = isOperationUseGears(target.getId(), gears); if (gearRemoved) { 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -81,7 +81,6 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.FlushMode; import org.hibernate.type.IntegerType; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Service; @@ -110,22 +109,22 @@ private static final Log log = LogFactory.getLog(FishingOperationPersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; - @Autowired + @Resource(name = "batchPersistenceService") protected CatchBatchPersistenceService catchBatchService; - @Autowired + @Resource(name = "accidentalBatchPersistenceService") protected AccidentalBatchPersistenceService accidentalBatchService; - @Autowired + @Resource(name = "attachmentPersistenceService") protected AttachmentPersistenceService attachmentPersistenceService; - @Autowired + @Resource(name = "vesselPersonFeaturesPersistenceHelper") protected VesselPersonFeaturesPersistenceHelper vesselPersonFeaturesPersistenceHelper; - @Autowired + @Resource(name = "measurementPersistenceHelper") protected MeasurementPersistenceHelper measurementPersistenceHelper; @Resource(name = "scientificCruiseDao") @@ -411,6 +410,7 @@ } return result; } + @Override public FishingOperation createFishingOperation(FishingOperation bean) { Preconditions.checkNotNull(bean); 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -50,7 +50,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.type.IntegerType; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Service; @@ -71,10 +70,10 @@ private static final Log log = LogFactory.getLog(IndividualObservationBatchPersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; - @Autowired + @Resource(name = "attachmentPersistenceService") protected AttachmentPersistenceService attachmentPersistenceService; @Resource(name = "samplePersistenceHelper") Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -40,9 +40,9 @@ import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.service.batch.BatchPersistenceHelper; +import fr.ifremer.tutti.persistence.service.batch.BatchTreeHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -61,12 +61,18 @@ private static final Log log = LogFactory.getLog(MarineLitterBatchPersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; @Resource(name = "batchPersistenceHelper") protected BatchPersistenceHelper batchHelper; + @Resource(name = "measurementPersistenceHelper") + protected MeasurementPersistenceHelper measurementPersistenceHelper; + + @Resource(name = "batchTreeHelper") + protected BatchTreeHelper batchTreeHelper; + protected Integer marineLitterCategory; protected Integer marineLitterSizeCategory; @@ -95,9 +101,9 @@ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false); // Get marine litter root batch - SortingBatch sortingBatch = getMarineLitterParentBatch(catchBatch); + SortingBatch sortingBatch = batchTreeHelper.getMarineLitterRootBatch(catchBatch); - BatchContainer<MarineLitterBatch> result = new BatchContainer<MarineLitterBatch>(); + BatchContainer<MarineLitterBatch> result = new BatchContainer<>(); if (sortingBatch != null) { result.setId(sortingBatch.getId()); @@ -219,7 +225,7 @@ // If parent and root need to be set if (target.getId() == null || target.getRootBatch() == null) { - setBatchParents(target, catchBatch); + batchHelper.setMarineLitterBatchParents(target, catchBatch); } // RankOrder (initialize once, at creation) @@ -245,7 +251,7 @@ // Weight if (source.getWeight() != null) { - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); @@ -254,7 +260,7 @@ // MarineLitterCategory if (source.getMarineLitterCategory() != null) { - SortingMeasurement measurement = batchHelper.setSortingMeasurement( + SortingMeasurement measurement = measurementPersistenceHelper.setSortingMeasurement( target, marineLitterCategory, source.getMarineLitterCategory().getIdAsInt() @@ -265,7 +271,7 @@ // MarineLitterSizeCategory if (source.getMarineLitterSizeCategory() != null) { - SortingMeasurement measurement = batchHelper.setSortingMeasurement( + SortingMeasurement measurement = measurementPersistenceHelper.setSortingMeasurement( target, marineLitterSizeCategory, source.getMarineLitterSizeCategory().getIdAsInt() @@ -299,37 +305,20 @@ } } - public void setBatchParents(SortingBatch target, CatchBatch catchBatch) { - - Preconditions.checkNotNull(target); - - SortingBatch parentBatch = getMarineLitterParentBatch(catchBatch); - - if (parentBatch == null) { - - SortingBatch horsVracBatch = batchHelper.getOrCreateHorsVracBatch( - catchBatch - ); - - parentBatch = batchHelper.getOrCreateMarineLitterRootBatch( - catchBatch, - horsVracBatch, - null - ); - } - - target.setParentBatch(parentBatch); - target.setRootBatch(catchBatch); - } - - protected SortingBatch getMarineLitterParentBatch(CatchBatch catchBatch) { - SortingBatch parentBatch = batchHelper.getSortingBatch( - catchBatch, - "Hors Vrac > Marine Litter", - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_HORS_VRAC_ID, - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER); - return parentBatch; - } +// public void setMarineLitterBatchParents(SortingBatch target, CatchBatch catchBatch) { +// +// Preconditions.checkNotNull(target); +// +// SortingBatch parentBatch = batchTreeHelper.getMarineLitterRootBatch(catchBatch); +// +// if (parentBatch == null) { +// +// SortingBatch horsVracBatch = batchHelper.getOrCreateHorsVracBatch(catchBatch); +// +// parentBatch = batchHelper.getOrCreateMarineLitterRootBatch(catchBatch, horsVracBatch, null); +// } +// +// target.setParentBatch(parentBatch); +// target.setRootBatch(catchBatch); +// } } 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MeasurementPersistenceHelper.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -24,13 +24,20 @@ * #L% */ +import com.google.common.base.Preconditions; +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.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.referential.pmfm.QualitativeValue; import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.io.Serializable; /** @@ -42,6 +49,12 @@ @Component("measurementPersistenceHelper") public class MeasurementPersistenceHelper extends AbstractPersistenceService { + @Resource(name = "referentialPersistenceService") + protected ReferentialPersistenceService referentialService; + + @Resource(name = "catchBatchDao") + protected CatchBatchExtendDao catchBatchDao; + public void setMeasurement(Measurement measurement, Caracteristic caracteristic, Serializable value) { @@ -68,4 +81,38 @@ break; } } + + 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); + setMeasurement(sortingMeasurement, + caracteristic, + value); + return sortingMeasurement; + } + + public QuantificationMeasurement setWeightMeasurementQuantificationMeasurement(Batch batch, Float weightValue) { + return catchBatchDao.setQuantificationMeasurement(batch, enumeration.PMFM_ID_WEIGHT_MEASURED, getRecorderDepartmentId(), weightValue, true); + } + + public QuantificationMeasurement getWeightMeasurementQuantificationMeasurement(Batch batch) { + QuantificationMeasurement quantificationMeasurement = catchBatchDao.getQuantificationMeasurement(batch, enumeration.PMFM_ID_WEIGHT_MEASURED, getRecorderDepartmentId(), false); + return quantificationMeasurement; + } + + public SortingMeasurement getInheritedSortingMeasurement(SortingBatch sortingBatch) { + return catchBatchDao.getInheritedSortingMeasurement(sortingBatch, enumeration.PMFM_ID_SORTED_UNSORTED); + } + + 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/ProgramPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceServiceImpl.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ProgramPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -39,7 +39,6 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.type.IntegerType; import org.hibernate.type.StringType; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Service; @@ -59,7 +58,7 @@ private static final Log log = LogFactory.getLog(ProgramPersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; @Resource(name = "programDao") Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceService.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -24,10 +24,12 @@ * #L% */ +import com.google.common.base.Predicate; import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; import fr.ifremer.tutti.persistence.entities.data.Cruise; 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.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.Gear; import fr.ifremer.tutti.persistence.entities.referential.ObjectType; @@ -266,6 +268,10 @@ @Cacheable(value = "pmfmById", key = "#pmfmId") Caracteristic getCaracteristic(Integer pmfmId); + Predicate<SpeciesAbleBatch> getVracBatchPredicate(); + + boolean isVracBatch(SpeciesAbleBatch speciesBatch); + @Cacheable(value = "objectTypeByCode", key = "#objectTypeCode") ObjectType getObjectType(String objectTypeCode); @@ -309,5 +315,5 @@ @CacheEvict(value = "gears", allEntries = true) List<Gear> importTemporaryGear(List<Gear> gears); - TuttiEnumerationFile getEnumerationFile(); +// TuttiEnumerationFile getEnumerationFile(); } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -25,6 +25,7 @@ */ import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import fr.ifremer.adagio.core.dao.administration.user.PersonExtendDao; @@ -37,6 +38,7 @@ import fr.ifremer.adagio.core.dao.referential.taxon.TaxonRefVO; import fr.ifremer.adagio.core.service.technical.CacheService; import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValues; @@ -114,6 +116,17 @@ @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService thisService; + protected Predicate<SpeciesAbleBatch> batchVracPredicate; + + @Override + public void init() { + super.init(); + + batchVracPredicate = TuttiEntities.newSpeciesAbleBatchCategoryPredicate( + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_VRAC_ID); + } + //------------------------------------------------------------------------// //-- ReferentialPersistenceService implentation --// //------------------------------------------------------------------------// @@ -353,7 +366,7 @@ "projectMemberProfilId", IntegerType.INSTANCE, enumeration.USER_PROFIL_ID_PROJECT_MEMBER, "userProfilId", IntegerType.INSTANCE, enumeration.USER_PROFIL_ID_USER, "departementPrefixCode", StringType.INSTANCE, enumeration.USER_PROFIL_ID_DEPARTEMENT_PREFIX - ); + ); List<Person> result = Lists.newArrayList(); while (list.hasNext()) { @@ -667,6 +680,16 @@ } @Override + public boolean isVracBatch(SpeciesAbleBatch speciesBatch) { + return batchVracPredicate.apply(speciesBatch); + } + + @Override + public Predicate<SpeciesAbleBatch> getVracBatchPredicate() { + return batchVracPredicate; + } + + @Override public List<Species> importTemporarySpecies(List<Species> species) { List<Species> result = Lists.newArrayList(); for (Species source : species) { @@ -723,10 +746,10 @@ return Collections.unmodifiableList(result); } - @Override - public TuttiEnumerationFile getEnumerationFile() { - return enumeration; - } +// @Override +// public TuttiEnumerationFile getEnumerationFile() { +// return enumeration; +// } //------------------------------------------------------------------------// //-- Internal methods --// Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SamplePersistenceHelper.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SamplePersistenceHelper.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SamplePersistenceHelper.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -35,7 +35,6 @@ import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import org.hibernate.type.IntegerType; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import javax.annotation.Resource; @@ -52,13 +51,13 @@ @Component("samplePersistenceHelper") public class SamplePersistenceHelper extends AbstractPersistenceService { - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; - @Autowired + @Resource(name = "measurementPersistenceHelper") protected MeasurementPersistenceHelper measurementPersistenceHelper; - @Autowired + @Resource(name = "attachmentPersistenceService") protected AttachmentPersistenceService attachmentPersistenceService; @Resource(name = "sampleDao") 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceService.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -24,6 +24,7 @@ * #L% */ +import com.google.common.collect.Multimap; import fr.ifremer.tutti.persistence.InvalidBatchModelException; import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; @@ -99,6 +100,15 @@ List<SpeciesBatchFrequency> getAllSpeciesBatchFrequency(String speciesBatchId); /** + * Get all frequencies for the given root species batch container. + * + * @param batchContainer the root batch containter + * @return the list of species frequencies indexed by their species + * @since 3.3 + */ + Multimap<Species, SpeciesBatchFrequency> getAllSpeciesBatchFrequencyForBatch(BatchContainer<SpeciesBatch> batchContainer); + + /** * Save all given {@link SpeciesBatchFrequency} into the given * {@code speciesBatchId}. If some are not existing then creates them. * <p/> 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -25,7 +25,9 @@ */ import com.google.common.base.Preconditions; +import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import fr.ifremer.adagio.core.dao.data.batch.Batch; import fr.ifremer.adagio.core.dao.data.batch.CatchBatch; @@ -46,10 +48,10 @@ 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.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; @@ -76,12 +78,18 @@ private static final Log log = LogFactory.getLog(SpeciesBatchPersistenceServiceImpl.class); - @Autowired + @Resource(name = "referentialPersistenceService") protected ReferentialPersistenceService referentialService; @Resource(name = "batchPersistenceHelper") protected BatchPersistenceHelper batchHelper; + @Resource(name = "batchTreeHelper") + protected BatchTreeHelper batchTreeHelper; + + @Resource(name = "measurementPersistenceHelper") + protected MeasurementPersistenceHelper measurementPersistenceHelper; + protected SampleCategoryModel sampleCategoryModel; @Override @@ -103,13 +111,14 @@ CatchBatch catchBatch = batchHelper.getRootCatchBatchByFishingOperationId(fishingOperationId, false); // Vrac / Species - 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 - ); + 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). @@ -142,11 +151,12 @@ } // Hors-Vrac / Species - 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); + 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; @@ -286,6 +296,28 @@ } @Override + public Multimap<Species, SpeciesBatchFrequency> getAllSpeciesBatchFrequencyForBatch(BatchContainer<SpeciesBatch> batchContainer) { + Multimap<Species, SpeciesBatchFrequency> result = ArrayListMultimap.create(); + for (SpeciesBatch speciesBatch : batchContainer.getChildren()) { + getAllSpeciesBatchFrequencyForBatch(speciesBatch, result); + } + return result; + } + + protected void getAllSpeciesBatchFrequencyForBatch(SpeciesBatch batch, + Multimap<Species, SpeciesBatchFrequency> result) { + + List<SpeciesBatchFrequency> speciesBatchFrequency = getAllSpeciesBatchFrequency(batch.getId()); + result.putAll(batch.getSpecies(), speciesBatchFrequency); + + if (!batch.isChildBatchsEmpty()) { + for (SpeciesBatch child : batch.getChildBatchs()) { + getAllSpeciesBatchFrequencyForBatch(child, result); + } + } + } + + @Override public List<SpeciesBatchFrequency> saveSpeciesBatchFrequency( String speciesBatchId, List<SpeciesBatchFrequency> frequencies) { @@ -423,7 +455,7 @@ if (source.getSortingMeasurements().size() == 1) { sm = source.getSortingMeasurements().iterator().next(); } else if (source.getReferenceTaxon() != null && source.getReferenceTaxon().getId() != null) { - sm = batchHelper.getInheritedSortingMeasurement(source); + sm = measurementPersistenceHelper.getInheritedSortingMeasurement(source); } if (sm != null) { @@ -562,12 +594,12 @@ // Weight or SampleCategoryWeight if (source.getSampleCategoryWeight() != null && source.getWeight() == null) { - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getSampleCategoryWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); } else if (source.getWeight() != null && source.getSampleCategoryWeight() == null) { - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); @@ -582,7 +614,7 @@ samplingRatioText = samplingRatioText.replaceAll(",", "."); target.setSamplingRatioText(samplingRatioText); target.setSamplingRatio(source.getWeight() / source.getSampleCategoryWeight()); - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); @@ -593,7 +625,7 @@ Integer pmfmId = source.getSampleCategoryId(); // Do not store sorting measurement if pmfm = SORTED (already store in an ancestor batch) if (!pmfmId.equals(enumeration.PMFM_ID_SORTED_UNSORTED)) { - SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement( + SortingMeasurement sortingMeasurement = measurementPersistenceHelper.setSortingMeasurement( target, pmfmId, source.getSampleCategoryValue()); @@ -671,7 +703,7 @@ // Weight or SampleCategoryWeight if (source.getWeight() != null) { - QuantificationMeasurement quantificationMeasurement = batchHelper.setWeightMeasurementQuantificationMeasurement( + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( target, source.getWeight()); notChangedQuantificationMeasurements.remove(quantificationMeasurement); @@ -680,8 +712,8 @@ // Sorting measurement if ((source.getLengthStepCaracteristic() != null && source.getLengthStep() != null)) { Integer pmfmId = source.getLengthStepCaracteristic().getIdAsInt(); - SortingMeasurement sortingMeasurement = batchHelper.setSortingMeasurement(target, pmfmId, - source.getLengthStep()); + SortingMeasurement sortingMeasurement = measurementPersistenceHelper.setSortingMeasurement(target, pmfmId, + source.getLengthStep()); notChangedSortingMeasurements.remove(sortingMeasurement); } Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceService.java (rev 0) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceService.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -0,0 +1,54 @@ +package fr.ifremer.tutti.persistence.service; + +import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; +import org.nuiton.util.Version; +import org.springframework.transaction.annotation.Transactional; + +import java.util.concurrent.Callable; + +/** + * Contains some technical services. + * <p/> + * Created on 4/20/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 3.5 + */ +@Transactional(readOnly = true) +public interface TechnicalPersistenceService extends TuttiPersistenceServiceImplementor { + + /** + * @return the enumeration file (where all constant mapping are defined). + * @since 2.4 + */ + TuttiEnumerationFile getEnumerationFile(); + + /** + * To clear all caches. + * + * @since 1.0.1 + */ + void clearAllCaches(); + + /** + * To invoke the given call code. + * <p/> + * <strong>Note:</strong> this is mainly to execute a code in a single + * transaction. + * + * @param call call to invoke + * @param <V> return type + * @return the return of the call + * @since 2.4 + */ + @Transactional(readOnly = false) + <V> V invoke(Callable<V> call); + + Version getDbVersion(); + + Version getApplicationVersion(); + + void updateSchema(); + + void sanityDb(); +} Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceService.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceServiceImpl.java (rev 0) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceServiceImpl.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -0,0 +1,100 @@ +package fr.ifremer.tutti.persistence.service; + +import fr.ifremer.adagio.core.dao.technical.DatabaseSchemaDao; +import fr.ifremer.adagio.core.dao.technical.DatabaseSchemaUpdateException; +import fr.ifremer.adagio.core.dao.technical.VersionNotFoundException; +import fr.ifremer.adagio.core.service.technical.CacheService; +import fr.ifremer.adagio.core.service.technical.sanity.DatabaseSanityService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.jaxx.application.ApplicationTechnicalException; +import org.nuiton.util.Version; +import org.nuiton.util.VersionUtil; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.concurrent.Callable; + +/** + * Created on 4/20/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 3.5 + */ +@Service("technicalPersistenceService") +public class TechnicalPersistenceServiceImpl extends AbstractPersistenceService implements TechnicalPersistenceService { + + /** Logger. */ + private static final Log log = LogFactory.getLog(TechnicalPersistenceServiceImpl.class); + + @Resource(name = "databaseSanityService") + protected DatabaseSanityService databaseSanityService; + + @Resource(name = "cacheService") + protected CacheService cacheService; + + @Resource(name = "databaseSchemaDao") + protected DatabaseSchemaDao databaseSchemaDao; + + @Override + public TuttiEnumerationFile getEnumerationFile() { + return enumeration; + } + + @Override + public <V> V invoke(Callable<V> call) { + + try { + V result = call.call(); + return result; + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new ApplicationTechnicalException(e); + } + } + + @Override + public Version getDbVersion() { + Version version = getDbVersion0(); + return version; + } + + private Version getDbVersion0() { + fr.ifremer.adagio.core.dao.technical.Version version; + try { + version = databaseSchemaDao.getSchemaVersion(); + } catch (VersionNotFoundException e) { + if (log.isErrorEnabled()) { + log.error("Could not find db version", e); + } + version = null; + } + return version == null ? null : VersionUtil.valueOf(version.toString()); + } + + @Override + public Version getApplicationVersion() { + fr.ifremer.adagio.core.dao.technical.Version version = databaseSchemaDao.getSchemaVersionIfUpdate(); + return VersionUtil.valueOf(version.toString()); + } + + @Override + public void updateSchema() { + try { + databaseSchemaDao.updateSchema(); + } catch (DatabaseSchemaUpdateException e) { + throw new ApplicationTechnicalException(e.getCause()); + } + } + + @Override + public void sanityDb() { + databaseSanityService.sanity(); + } + + @Override + public void clearAllCaches() { + cacheService.clearAllCaches(); + } +} Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TechnicalPersistenceServiceImpl.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/TuttiPersistenceServiceLocator.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiPersistenceServiceLocator.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -61,6 +61,11 @@ TuttiPersistence.class); } + public static TechnicalPersistenceService getTechnicalPersistenceService() { + return instance().getService("technicalPersistenceService", + TechnicalPersistenceService.class); + } + public static ReferentialPersistenceService getReferentialPersistenceService() { return instance().getService("referentialPersistenceService", ReferentialPersistenceService.class); 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchPersistenceHelper.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -27,7 +27,6 @@ import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; 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.batch.CatchBatchExtendDao; @@ -35,9 +34,7 @@ import fr.ifremer.adagio.core.dao.data.batch.SortingBatchDao; import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationError; import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException; -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.tutti.persistence.InvalidBatchModelException; import fr.ifremer.tutti.persistence.entities.TuttiEntity; @@ -52,12 +49,8 @@ import fr.ifremer.tutti.persistence.service.AbstractPersistenceService; import fr.ifremer.tutti.persistence.service.AttachmentPersistenceService; import fr.ifremer.tutti.persistence.service.IndividualObservationBatchPersistenceService; -import fr.ifremer.tutti.persistence.service.MeasurementPersistenceHelper; 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.beans.factory.annotation.Autowired; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.stereotype.Component; @@ -65,9 +58,7 @@ import javax.annotation.Resource; import java.io.Serializable; import java.text.MessageFormat; -import java.util.Collection; import java.util.List; -import java.util.Set; import static org.nuiton.i18n.I18n.t; @@ -80,9 +71,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; @@ -102,9 +93,12 @@ @Resource(name = "scientificCruiseCatchBatchValidator") protected TuttiCatchBatchValidator catchBatchValidator; - @Autowired - protected MeasurementPersistenceHelper measurementPersistenceHelper; +// @Resource(name = "measurementPersistenceHelper") +// protected MeasurementPersistenceHelper measurementPersistenceHelper; + @Resource(name = "batchTreeHelper") + protected BatchTreeHelper batchTreeHelper; + @Override public void init() { super.init(); @@ -225,13 +219,13 @@ catchBatchDao.updateSortingBatch(sortingBatch, parentCatchBatch); } - public SortingMeasurement getInheritedSortingMeasurement(SortingBatch sortingBatch) { - return catchBatchDao.getInheritedSortingMeasurement(sortingBatch, enumeration.PMFM_ID_SORTED_UNSORTED); - } +// 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 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) { @@ -338,62 +332,66 @@ if (enumeration.QUALITATIVE_VRAC_ID.equals(qualitativeValueId)) { // get vrac / Species / Alive itemized batch - 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); + 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 - SortingBatch vracBatch = getSortingBatch( - catchBatch, - "Vrac", - enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID); + 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 = getOrCreateVracBatch(catchBatch, null, null); + vracBatch = batchTreeHelper.getOrCreateVracBatch(catchBatch, null, null); } // get vrac > species batch - SortingBatch vracSpeciesBatch = getSortingBatch( - vracBatch, - "Vrac > Species", - enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_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 = getOrCreateSpeciesVracRootBatch(catchBatch, vracBatch, null); + vracSpeciesBatch = batchTreeHelper.getOrCreateSpeciesVracRootBatch(catchBatch, vracBatch, null); } // create vrac > species > Alive itemized batch - parentBatch = getOrCreateSpeciesVracAliveItemizeRootBatch(catchBatch, vracSpeciesBatch); + parentBatch = batchTreeHelper.getOrCreateSpeciesVracAliveItemizedRootBatch(catchBatch, vracSpeciesBatch); } } else if (enumeration.QUALITATIVE_HORS_VRAC_ID.equals(qualitativeValueId)) { // get hors vrac > Species batch - 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); + 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 - SortingBatch horsVracBatch = getOrCreateHorsVracBatch(catchBatch); + SortingBatch horsVracBatch = batchTreeHelper.getOrCreateHorsVracBatch(catchBatch); // create hors vrac > species batch - parentBatch = getOrCreateSpeciesHorsVracRootBatch( + parentBatch = batchTreeHelper.getOrCreateSpeciesHorsVracRootBatch( catchBatch, horsVracBatch); } @@ -441,63 +439,67 @@ if (enumeration.QUALITATIVE_VRAC_ID.equals(qualitativeValueId)) { // Vrac > Benthos > Alive Itemized - 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); + 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 - SortingBatch vracBatch = getSortingBatch( - catchBatch, - "Vrac", - enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_VRAC_ID); + 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 = getOrCreateVracBatch(catchBatch, null, null); + vracBatch = batchTreeHelper.getOrCreateVracBatch(catchBatch, null, null); } // get vrac > Benthos batch - SortingBatch vracBenthosBatch = getSortingBatch( - vracBatch, - "Vrac > Benthos", - enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_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 = getOrCreateBenthosVracRootBatch(catchBatch, vracBatch, null); + vracBenthosBatch = batchTreeHelper.getOrCreateBenthosVracRootBatch(catchBatch, vracBatch, null); } // create vrac > Benthos > Alive itemized batch - parentBatch = getOrCreateBenthosVracAliveItemizeRootBatch(catchBatch, vracBenthosBatch); + parentBatch = batchTreeHelper.getOrCreateBenthosVracAliveItemizedRootBatch(catchBatch, vracBenthosBatch); } } else if (enumeration.QUALITATIVE_HORS_VRAC_ID.equals(qualitativeValueId)) { // get hors-vrac > Benthos batch - 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); + 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 - SortingBatch horsVracBatch = getOrCreateHorsVracBatch(catchBatch); + SortingBatch horsVracBatch = batchTreeHelper.getOrCreateHorsVracBatch(catchBatch); // create hors vrac > Benthos batch - parentBatch = getOrCreateBenthosHorsVracRootBatch( + parentBatch = batchTreeHelper.getOrCreateBenthosHorsVracRootBatch( catchBatch, horsVracBatch); } @@ -512,6 +514,23 @@ target.setParentBatch(parentBatch); } + public void setMarineLitterBatchParents(SortingBatch target, CatchBatch catchBatch) { + + Preconditions.checkNotNull(target); + + SortingBatch parentBatch = batchTreeHelper.getMarineLitterRootBatch(catchBatch); + + if (parentBatch == null) { + + SortingBatch horsVracBatch = batchTreeHelper.getOrCreateHorsVracBatch(catchBatch); + + parentBatch = batchTreeHelper.getOrCreateMarineLitterRootBatch(catchBatch, horsVracBatch, null); + } + + target.setParentBatch(parentBatch); + target.setRootBatch(catchBatch); + } + public Integer convertSampleCategoryValueIntoQualitativeId(Serializable value) { if (value == null) { return null; @@ -526,343 +545,342 @@ return qualitativeValueId; } - public SortingBatch getSortingBatch(Batch source, - String debugMessage, - Integer... ids) { +// public SortingBatch getSortingBatch(Batch source, +// String debugMessage, +// Integer... ids) { +// +// return getSortingBatch(source.getChildBatchs(), debugMessage, ids); +// } - return getSortingBatch(source.getChildBatchs(), debugMessage, ids); - } +// 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; +// } - public SortingBatch getSortingBatch(Collection<Batch> childs, - String debugMessage, - Integer... ids) { +// public SortingBatch getVracBatch(CatchBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTED_UNSORTED, +// enumeration.QUALITATIVE_VRAC_ID +// ); +// } - int nbParams = ids.length / 2; +// 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 +// ); +// } - 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; - } +// public SortingBatch getSpeciesVracRootBatch(SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES +// ); +// } - public SortingBatch getVracBatch(CatchBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_VRAC_ID - ); - } +// 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 +// ); +// } - 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 - ); - } +// public SortingBatch getSpeciesVracAliveNotItemizedRootBatch(SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE_2, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED +// ); +// } - public SortingBatch getSpeciesVracRootBatch(SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES - ); - } +// 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 +// ); +// } - 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 - ); - } +// public SortingBatch getSpeciesVracInertRootBatch(SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE_2, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT +// ); +// } - 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 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 SortingBatch getOrCreateSpeciesVracAliveNotItemizeRootBatch(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 - ); - } +// public SortingBatch getSpeciesVracAliveItemizeRootBatch( +// SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE_2, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED +// ); +// } - public SortingBatch getSpeciesVracInertRootBatch(SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT - ); - } +// 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 +// ); +// } - 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 SortingBatch getBenthosVracRootBatch( +// SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS +// ); +// } - public SortingBatch getSpeciesVracAliveItemizeRootBatch( - SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED - ); - } +// 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 +// ); +// } - public SortingBatch getOrCreateSpeciesVracAliveItemizeRootBatch(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 getBenthosVracAliveNotItemizedRootBatch( +// SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE_2, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED +// ); +// } - public SortingBatch getBenthosVracRootBatch( - SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS - ); - } +// 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 +// ); +// } - 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 - ); - } +// public SortingBatch getBenthosVracInertRootBatch(SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE_2, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT +// ); +// } - 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 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 +// ); +// } - public SortingBatch getOrCreateBenthosVracAliveNotItemizeRootBatch(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 - ); - } +// public SortingBatch getBenthosVracAliveItemizeRootBatch(SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE_2, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED +// ); +// } - public SortingBatch getBenthosVracInertRootBatch(SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT - ); - } +// 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 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 - ); - } +// public SortingBatch getHorsVracBatch(CatchBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTED_UNSORTED, +// enumeration.QUALITATIVE_HORS_VRAC_ID +// ); +// } - public SortingBatch getBenthosVracAliveItemizeRootBatch(SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED - ); - } +// public SortingBatch getOrCreateHorsVracBatch(CatchBatch batch) { +// return getOrCreate( +// batch, +// batch, +// enumeration.PMFM_ID_SORTED_UNSORTED, +// enumeration.QUALITATIVE_HORS_VRAC_ID, +// null, +// (short) 2 +// ); +// } - public SortingBatch getOrCreateBenthosVracAliveItemizeRootBatch(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 getSpeciesHorsVracRootBatch(SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES +// ); +// } - public SortingBatch getHorsVracBatch(CatchBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_HORS_VRAC_ID - ); - } +// 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 getOrCreateHorsVracBatch(CatchBatch batch) { - return getOrCreate( - batch, - batch, - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_HORS_VRAC_ID, - null, - (short) 2 - ); - } +// public SortingBatch getBenthosHorsVracRootBatch(SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS +// ); +// } - public SortingBatch getSpeciesHorsVracRootBatch(SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES - ); - } +// 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 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 getMarineLitterRootBatch(SortingBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTING_TYPE, +// enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER +// ); +// } - public SortingBatch getBenthosHorsVracRootBatch(SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS - ); - } +// 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 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 getRejectedBatch(CatchBatch batch) { +// return get( +// batch, +// enumeration.PMFM_ID_SORTED_UNSORTED, +// enumeration.QUALITATIVE_UNSORTED_ID +// ); +// } - public SortingBatch getMarineLitterRootBatch(SortingBatch batch) { - return get( - batch, - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER - ); - } +// public SortingBatch getOrCreateRejectedBatch(CatchBatch batch, +// Float weight) { +// +// return getOrCreate( +// batch, +// batch, +// enumeration.PMFM_ID_SORTED_UNSORTED, +// enumeration.QUALITATIVE_UNSORTED_ID, +// weight, +// (short) 3 +// ); +// } - 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 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 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, @@ -927,124 +945,124 @@ return result; } - protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target, - Batch batch, - Integer pmfmId, - Integer pmfmValue, - Float totalWeight, - short rankOrder) { - return getOrCreate( - target, - batch, - pmfmId, - pmfmValue, - totalWeight, - null, - rankOrder - ); - } +// protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target, +// Batch batch, +// Integer pmfmId, +// Integer pmfmValue, +// Float totalWeight, +// short rankOrder) { +// return getOrCreate( +// target, +// batch, +// pmfmId, +// pmfmValue, +// totalWeight, +// null, +// rankOrder +// ); +// } - protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch, - Batch parentBatch, - Integer sortingPmfmId, - Integer sortingQualitativeValueId, - Float weight, - Float weightBeforeSampling, - short rankOrder) { - SortingBatch result = get( - parentBatch, - sortingPmfmId, - sortingQualitativeValueId); +// protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch, +// Batch parentBatch, +// Integer sortingPmfmId, +// Integer sortingQualitativeValueId, +// Float weight, +// Float weightBeforeSampling, +// short rankOrder) { +// SortingBatch result = batchTreeHelper.get( +// parentBatch, +// sortingPmfmId, +// sortingQualitativeValueId); +// +// if (result == null) { +// +// result = SortingBatch.Factory.newInstance(); +// if (parentBatch.getChildBatchs() == null) { +// parentBatch.setChildBatchs(Sets.<Batch>newHashSet()); +// } +// parentBatch.getChildBatchs().add(result); +// +// Collection<SortingMeasurement> sortingMeasurements = result.getSortingMeasurements(); +// +// // Create lists to store all updates, then remove not updated items +// Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet(); +// if (sortingMeasurements != null) { +// notChangedSortingMeasurements.addAll(sortingMeasurements); +// } +// +// // Some mandatory properties : +// QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED); +// result.setQualityFlag(qualityFlag); +// result.setRootBatch(rootBatch); +// result.setParentBatch(parentBatch); +// result.setExhaustiveInventory(true); +// +// // No taxon or taxon group +// result.setReferenceTaxon(null); +// result.setTaxonGroup(null); +// +// result.setRankOrder(rankOrder); +// +// // Sorting measurement +// if (sortingPmfmId != null && sortingQualitativeValueId != null) { +// SortingMeasurement sm = setSortingMeasurement( +// result, +// sortingPmfmId, +// sortingQualitativeValueId); +// notChangedSortingMeasurements.remove(sm); +// } +// // Removed not changed sorting measurements +// if (sortingMeasurements != null) { +// sortingMeasurements.removeAll(notChangedSortingMeasurements); +// } +// +// catchBatchDao.createSortingBatch(result, rootBatch); +// } +// +// Collection<QuantificationMeasurement> quantificationMeasurements = result.getQuantificationMeasurements(); +// Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet(); +// if (quantificationMeasurements != null) { +// notChangedQuantificationMeasurements.addAll(quantificationMeasurements); +// } +// +// // Sampling Ratio +// if (weightBeforeSampling == null || weight == null) { +// result.setSamplingRatio(null); +// result.setSamplingRatioText(null); +// } else { +// String samplingRatioText = weight + "/" + weightBeforeSampling; +// samplingRatioText = samplingRatioText.replaceAll(",", "."); +// result.setSamplingRatioText(samplingRatioText); +// result.setSamplingRatio(weight / weightBeforeSampling); +// } +// +// // Weight +// if (weightBeforeSampling != null || weight != null) { +// Float batchReferenceWeight = weight; +// if (batchReferenceWeight == null) { +// batchReferenceWeight = weightBeforeSampling; +// } +// QuantificationMeasurement quantificationMeasurement = setWeightMeasurementQuantificationMeasurement( +// result, +// batchReferenceWeight); +// notChangedQuantificationMeasurements.remove(quantificationMeasurement); +// } +// // Removed not changed quantification measurements +// if (quantificationMeasurements != null) { +// quantificationMeasurements.removeAll(notChangedQuantificationMeasurements); +// } +// +// return result; +// } - if (result == null) { - - result = SortingBatch.Factory.newInstance(); - if (parentBatch.getChildBatchs() == null) { - parentBatch.setChildBatchs(Sets.<Batch>newHashSet()); - } - parentBatch.getChildBatchs().add(result); - - Collection<SortingMeasurement> sortingMeasurements = result.getSortingMeasurements(); - - // Create lists to store all updates, then remove not updated items - Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet(); - if (sortingMeasurements != null) { - notChangedSortingMeasurements.addAll(sortingMeasurements); - } - - // Some mandatory properties : - QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED); - result.setQualityFlag(qualityFlag); - result.setRootBatch(rootBatch); - result.setParentBatch(parentBatch); - result.setExhaustiveInventory(true); - - // No taxon or taxon group - result.setReferenceTaxon(null); - result.setTaxonGroup(null); - - result.setRankOrder(rankOrder); - - // Sorting measurement - if (sortingPmfmId != null && sortingQualitativeValueId != null) { - SortingMeasurement sm = setSortingMeasurement( - result, - sortingPmfmId, - sortingQualitativeValueId); - notChangedSortingMeasurements.remove(sm); - } - // Removed not changed sorting measurements - if (sortingMeasurements != null) { - sortingMeasurements.removeAll(notChangedSortingMeasurements); - } - - catchBatchDao.createSortingBatch(result, rootBatch); - } - - Collection<QuantificationMeasurement> quantificationMeasurements = result.getQuantificationMeasurements(); - Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet(); - if (quantificationMeasurements != null) { - notChangedQuantificationMeasurements.addAll(quantificationMeasurements); - } - - // Sampling Ratio - if (weightBeforeSampling == null || weight == null) { - result.setSamplingRatio(null); - result.setSamplingRatioText(null); - } else { - String samplingRatioText = weight + "/" + weightBeforeSampling; - samplingRatioText = samplingRatioText.replaceAll(",", "."); - result.setSamplingRatioText(samplingRatioText); - result.setSamplingRatio(weight / weightBeforeSampling); - } - - // Weight - if (weightBeforeSampling != null || weight != null) { - Float batchReferenceWeight = weight; - if (batchReferenceWeight == null) { - batchReferenceWeight = weightBeforeSampling; - } - QuantificationMeasurement quantificationMeasurement = setWeightMeasurementQuantificationMeasurement( - result, - batchReferenceWeight); - notChangedQuantificationMeasurements.remove(quantificationMeasurement); - } - // Removed not changed quantification measurements - if (quantificationMeasurements != null) { - quantificationMeasurements.removeAll(notChangedQuantificationMeasurements); - } - - return result; - } - - protected SortingBatch get(Batch parentBatch, - Integer sortingPmfmId, - Integer sortingQualitativeValueId) { - SortingBatch result = getSortingBatch( - parentBatch, - null, - sortingPmfmId, - sortingQualitativeValueId); - return result; - } +// protected SortingBatch get(Batch parentBatch, +// Integer sortingPmfmId, +// Integer sortingQualitativeValueId) { +// SortingBatch result = getSortingBatch( +// parentBatch, +// null, +// sortingPmfmId, +// sortingQualitativeValueId); +// return result; +// } } Added: 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 (rev 0) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchTreeHelper.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -0,0 +1,693 @@ +package fr.ifremer.tutti.persistence.service.batch; + +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.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.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.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Set; + +/** + * Helper to build or navigauet into the batch tree. + * <p/> + * Created on 4/20/14. + * + * @author Tony Chemit <chemit@codelutin.com> + * @since 3.5 + */ +@Component("batchTreeHelper") +public class BatchTreeHelper extends AbstractPersistenceService { + + /** 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; + + //------------------------------------------------------------------------// + //-- Get CatchBatch navigation methods --// + //------------------------------------------------------------------------// + + public SortingBatch getSpeciesVracAliveItemizedRootBatch(CatchBatch batch) { + return getSortingBatch( + batch, + "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 + ); + } + + public SortingBatch getBenthosVracAliveItemizedRootBatch(CatchBatch batch) { + return getSortingBatch( + batch, + "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 + ); + } + + public SortingBatch getSpeciesHorsVracRootBatch(CatchBatch batch) { + return getSortingBatch( + batch, + "Hors Vrac > Species", + enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, + enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES + ); + } + + public SortingBatch getBenthosHorsVracRootBatch(CatchBatch batch) { + return getSortingBatch( + batch, + "Hors Vrac > Benthos", + enumeration.PMFM_ID_SORTED_UNSORTED, enumeration.QUALITATIVE_HORS_VRAC_ID, + enumeration.PMFM_ID_SORTING_TYPE, enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS + ); + } + + public SortingBatch getMarineLitterRootBatch(CatchBatch batch) { + return getSortingBatch( + batch, + "Hors Vrac > Marine Litter", + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_HORS_VRAC_ID, + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER + ); + } + + public SortingBatch getVracBatch(CatchBatch batch) { + return getSortingBatch( + batch, + "Vrac", + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_VRAC_ID + ); + } + + public SortingBatch getHorsVracBatch(CatchBatch batch) { + return getSortingBatch( + batch, + "Hors Vrac", + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_HORS_VRAC_ID + ); + } + + public SortingBatch getRejectedBatch(CatchBatch batch) { + return getSortingBatch( + batch, + "Unsorted", + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_UNSORTED_ID + ); + } + + //------------------------------------------------------------------------// + //-- Get SortingBatch navigation methods --// + //------------------------------------------------------------------------// + + public SortingBatch getSpeciesVracRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Vrac > Species", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES + ); + } + + public SortingBatch getBenthosVracRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Vrac > Benthos", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS + ); + } + + public SortingBatch getSpeciesVracAliveNotItemizedRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Vrac > Species" + " > Alive not itemized", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED + ); + } + + public SortingBatch getBenthosVracAliveNotItemizedRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Vrac > Benthos" + " > Alive not itemized", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED + ); + } + + public SortingBatch getSpeciesVracInertRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Vrac > Species" + " > Inert (not alive)", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT + ); + } + + public SortingBatch getBenthosVracInertRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Vrac > Benthos" + " > Inert (not alive)", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT + ); + } + + public SortingBatch getSpeciesVracAliveItemizedRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Vrac > Species" + " > Alive itemized", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED + ); + } + + public SortingBatch getBenthosVracAliveItemizedRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Vrac > Benthos" + " > Alive itemized", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED + ); + } + + public SortingBatch getSpeciesHorsVracRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Hors Vrac > Species", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES + ); + } + + public SortingBatch getBenthosHorsVracRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Hors Vrac > Benthos", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS + ); + } + + public SortingBatch getMarineLitterRootBatch(SortingBatch batch) { + return getSortingBatch( + batch, + "Hors Vrac > MarineLitter", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER + ); + } + + //------------------------------------------------------------------------// + //-- getOrCreate methods --// + //------------------------------------------------------------------------// + + public SortingBatch getOrCreateVracBatch(CatchBatch batch, + Float weight, + Float weightBeforeSampling) { + return getOrCreate( + batch, + batch, + "Vrac", + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_VRAC_ID, + weight, + weightBeforeSampling, + (short) 1 + ); + } + + public SortingBatch getOrCreateSpeciesVracRootBatch(CatchBatch target, + SortingBatch batch, + Float totalWeight) { + return getOrCreate( + target, + batch, + "Vrac > Species", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, + totalWeight, + (short) 1 + ); + } + + public SortingBatch getOrCreateSpeciesVracAliveNotItemizedRootBatch(CatchBatch target, + SortingBatch batch, + Float totalWeight) { + return getOrCreate( + target, + batch, + "Vrac > Species > Alive Not Itemized", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED, + totalWeight, + (short) 1 + ); + } + + public SortingBatch getOrCreateSpeciesVracInertRootBatch(CatchBatch target, + SortingBatch batch, + Float totalWeight) { + return getOrCreate( + target, + batch, + "Vrac > Species > Inert", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT, + totalWeight, + (short) 2 + ); + } + + public SortingBatch getOrCreateSpeciesVracAliveItemizedRootBatch(CatchBatch target, + SortingBatch batch) { + return getOrCreate( + target, + batch, + "Vrac > Benthos > Alive Itemized", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED, + null, + (short) 3 + ); + } + + public SortingBatch getOrCreateBenthosVracRootBatch(CatchBatch target, + SortingBatch batch, + Float totalWeight) { + return getOrCreate( + target, + batch, + "Vrac > Benthos", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, + totalWeight, + (short) 2 + ); + } + + public SortingBatch getOrCreateBenthosVracAliveNotItemizedRootBatch(CatchBatch target, + SortingBatch batch, + Float totalWeight) { + return getOrCreate( + target, + batch, + "Vrac > Benthos > Alive Not itemized", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED, + totalWeight, + (short) 1 + ); + } + + public SortingBatch getOrCreateBenthosVracInertRootBatch(fr.ifremer.adagio.core.dao.data.batch.CatchBatch target, + SortingBatch batch, + Float totalWeight) { + return getOrCreate( + target, + batch, + "Vrac > Benthos > Inert", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT, + totalWeight, + (short) 2 + ); + } + + public SortingBatch getOrCreateBenthosVracAliveItemizedRootBatch(CatchBatch target, + SortingBatch batch) { + return getOrCreate( + target, + batch, + "Vrac > Benthos > Alive Itemized", + enumeration.PMFM_ID_SORTING_TYPE_2, + enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED, + null, + (short) 3 + ); + } + + public SortingBatch getOrCreateHorsVracBatch(CatchBatch batch) { + return getOrCreate( + batch, + batch, + "Hors Vrac", + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_HORS_VRAC_ID, + null, + (short) 2 + ); + } + + public SortingBatch getOrCreateSpeciesHorsVracRootBatch(CatchBatch target, + SortingBatch batch) { + return getOrCreate( + target, + batch, + "Hors Vrac > Species", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES, + null, + (short) 1 + ); + } + + public SortingBatch getOrCreateBenthosHorsVracRootBatch(CatchBatch target, + SortingBatch batch) { + return getOrCreate( + target, + batch, + "Hors Vrac > Benthos", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS, + null, + (short) 2 + ); + } + + public SortingBatch getOrCreateMarineLitterRootBatch(CatchBatch target, + SortingBatch batch, + Float totalWeight) { + return getOrCreate( + target, + batch, + "Hors Vrac > Marine Litter", + enumeration.PMFM_ID_SORTING_TYPE, + enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER, + totalWeight, + (short) 3 + ); + } + + public SortingBatch getOrCreateRejectedBatch(CatchBatch batch, + Float weight) { + + return getOrCreate( + batch, + batch, + "Unsorted", + enumeration.PMFM_ID_SORTED_UNSORTED, + enumeration.QUALITATIVE_UNSORTED_ID, + weight, + (short) 3 + ); + } + + //------------------------------------------------------------------------// + //-- Internal methods --// + //------------------------------------------------------------------------// + + protected SortingBatch get(Batch parentBatch, + Integer sortingPmfmId, + Integer sortingQualitativeValueId) { + SortingBatch result = getSortingBatch( + parentBatch, + null, + sortingPmfmId, + sortingQualitativeValueId); + return result; + } + + protected SortingBatch getSortingBatch(Batch source, + String debugMessage, + Integer... ids) { + + return getSortingBatch(source.getChildBatchs(), debugMessage, ids); + } + + protected 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; + } + + protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch, + Batch batch, + String debugMessage, + Integer sortingPmfmId, + Integer sortingQualitativeValueId, + Float totalWeight, + short rankOrder) { + return getOrCreate( + rootBatch, + batch, + debugMessage, + sortingPmfmId, + sortingQualitativeValueId, + totalWeight, + null, + rankOrder + ); + } + + protected SortingBatch getOrCreate(fr.ifremer.adagio.core.dao.data.batch.CatchBatch rootBatch, + Batch batch, + String debugMessage, + Integer sortingPmfmId, + Integer sortingQualitativeValueId, + Float weight, + Float weightBeforeSampling, + short rankOrder) { + SortingBatch result = getSortingBatch( + batch, + debugMessage, + sortingPmfmId, + sortingQualitativeValueId); + + if (result == null) { + + result = SortingBatch.Factory.newInstance(); + if (batch.getChildBatchs() == null) { + batch.setChildBatchs(Sets.<Batch>newHashSet()); + } + batch.getChildBatchs().add(result); + + Collection<SortingMeasurement> sortingMeasurements = result.getSortingMeasurements(); + + // Create lists to store all updates, then remove not updated items + Set<SortingMeasurement> notChangedSortingMeasurements = Sets.newHashSet(); + if (sortingMeasurements != null) { + notChangedSortingMeasurements.addAll(sortingMeasurements); + } + + // Some mandatory properties : + QualityFlagImpl qualityFlag = load(QualityFlagImpl.class, enumeration.QUALITY_FLAG_CODE_NOT_QUALIFIED); + result.setQualityFlag(qualityFlag); + result.setRootBatch(rootBatch); + result.setParentBatch(batch); + result.setExhaustiveInventory(true); + + // No taxon or taxon group + result.setReferenceTaxon(null); + result.setTaxonGroup(null); + + result.setRankOrder(rankOrder); + + // Sorting measurement + if (sortingPmfmId != null && sortingQualitativeValueId != null) { + SortingMeasurement sm = measurementPersistenceHelper.setSortingMeasurement( + result, + sortingPmfmId, + sortingQualitativeValueId); + notChangedSortingMeasurements.remove(sm); + } + // Removed not changed sorting measurements + if (sortingMeasurements != null) { + sortingMeasurements.removeAll(notChangedSortingMeasurements); + } + + catchBatchDao.createSortingBatch(result, rootBatch); + } + + Collection<QuantificationMeasurement> quantificationMeasurements = result.getQuantificationMeasurements(); + Set<QuantificationMeasurement> notChangedQuantificationMeasurements = Sets.newHashSet(); + if (quantificationMeasurements != null) { + notChangedQuantificationMeasurements.addAll(quantificationMeasurements); + } + + // Sampling Ratio + if (weightBeforeSampling == null || weight == null) { + result.setSamplingRatio(null); + result.setSamplingRatioText(null); + } else { + String samplingRatioText = weight + "/" + weightBeforeSampling; + samplingRatioText = samplingRatioText.replaceAll(",", "."); + result.setSamplingRatioText(samplingRatioText); + result.setSamplingRatio(weight / weightBeforeSampling); + } + + // Weight + if (weightBeforeSampling != null || weight != null) { + Float batchReferenceWeight = weight; + if (batchReferenceWeight == null) { + batchReferenceWeight = weightBeforeSampling; + } + QuantificationMeasurement quantificationMeasurement = measurementPersistenceHelper.setWeightMeasurementQuantificationMeasurement( + result, + batchReferenceWeight); + notChangedQuantificationMeasurements.remove(quantificationMeasurement); + } + // Removed not changed quantification measurements + if (quantificationMeasurements != null) { + quantificationMeasurements.removeAll(notChangedQuantificationMeasurements); + } + + return result; + } + + //------------------------------------------------------------------------// + //-- Debug methods --// + //------------------------------------------------------------------------// + + public void displayCatchBatch(CatchBatch result) { + StringBuilder sb = new StringBuilder(); + displayBatch(result, 0, sb); + if (log.isDebugEnabled()) { + log.debug(sb.toString()); + } + } + + 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()); + } + }; + + private void displayBatch(Batch batch, int level, StringBuilder sb) { + + ToStringBuilder builder = new ToStringBuilder(batch, ToStringStyle.MULTI_LINE_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()); + } + 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) { + builder.append("samplingRatio", sortingBatch.getSamplingRatio()); + } + if (sortingBatch.getSamplingRatioText() != null) { + builder.append("samplingRatioText", sortingBatch.getSamplingRatioText()); + } + if (sortingBatch.getReferenceTaxon() != null) { + ReferenceTaxon referenceTaxon = sortingBatch.getReferenceTaxon(); + Species speciesByReferenceTaxonId = referentialService.getSpeciesByReferenceTaxonId(referenceTaxon.getId()); + builder.append("referenceTaxon", speciesByReferenceTaxonId.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()); + } + } + } + } + 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 prefix = "\n" + StringUtils.leftPad("", 2 * level); + String batchStr = Joiner.on(prefix).join(builder.build().split("\n")); + sb.append(prefix).append(batchStr); + Collection<Batch> childBatchs = batch.getChildBatchs(); + if (childBatchs != null) { + List<Batch> childBatchList = new ArrayList<>(childBatchs); + Collections.sort(childBatchList, batchComparator); + for (Batch childBatch : childBatchList) { + displayBatch(childBatch, level + 1, sb); + } + } + } + + protected Caracteristic getPmfm(Pmfm pmfm) { + Caracteristic caracteristic = referentialService.getCaracteristic(pmfm.getId()); + return caracteristic; + } +} Property changes on: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/BatchTreeHelper.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/ScientificCruiseCatchBatchValidator.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -25,9 +25,7 @@ */ import com.google.common.collect.Lists; -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.batch.CatchBatchExtendDao; import fr.ifremer.adagio.core.dao.data.batch.SortingBatch; import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationError; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; @@ -36,19 +34,16 @@ import fr.ifremer.tutti.persistence.entities.data.SampleCategoryModelEntry; import fr.ifremer.tutti.persistence.entities.data.SpeciesAbleBatch; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; -import fr.ifremer.tutti.persistence.service.CatchBatchPersistenceService; -import fr.ifremer.tutti.persistence.service.TuttiEnumerationFile; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.Collection; +import javax.annotation.Resource; 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; @Component(value = "scientificCruiseCatchBatchValidator") public class ScientificCruiseCatchBatchValidator implements TuttiCatchBatchValidator { @@ -57,18 +52,9 @@ private static final Log log = LogFactory.getLog(ScientificCruiseCatchBatchValidator.class); - @Autowired - protected CatchBatchPersistenceService batchService; + @Resource(name = "batchTreeHelper") + protected BatchTreeHelper batchTreeHelper; - @Autowired - protected CatchBatchExtendDao catchBatchDao; - - @Autowired - protected TuttiEnumerationFile enumeration; - - @Autowired - protected BatchPersistenceHelper batchHelper; - // -----------------------------------------------------------------------// // -- CatchBatchValidator methods --// // -----------------------------------------------------------------------// @@ -82,7 +68,7 @@ @Override public List<CatchBatchValidationError> validate(CatchBatch catchBatch) { List<CatchBatchValidationError> errors = Lists.newArrayList(); - validateCatchBatch(catchBatch.getChildBatchs(), errors); + validateCatchBatch(catchBatch, errors); return errors; } @@ -161,15 +147,11 @@ // -- Internal methods --// // -----------------------------------------------------------------------// - protected void validateCatchBatch(Collection<Batch> batchs, + protected void validateCatchBatch(CatchBatch batch, List<CatchBatchValidationError> errors) { // Vrac - SortingBatch vracBatch = batchHelper.getSortingBatch( - batchs, - "Vrac", - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_VRAC_ID); + SortingBatch vracBatch = batchTreeHelper.getVracBatch(batch); if (log.isDebugEnabled()) { log.debug("Try to validate Vrac batch model " + vracBatch); @@ -179,18 +161,10 @@ addError(errors, n("tutti.persistence.batch.validation.vracNotFound")); } else { // Vrac > Species - SortingBatch speciesBatch = batchHelper.getSortingBatch( - vracBatch, - "Vrac > Species", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + SortingBatch speciesBatch = batchTreeHelper.getSpeciesVracRootBatch(vracBatch); // Vrac > Benthos - SortingBatch benthosBatch = batchHelper.getSortingBatch( - vracBatch, - "Vrac > Benthos", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + SortingBatch benthosBatch = batchTreeHelper.getBenthosVracRootBatch(vracBatch); if (speciesBatch == null) { @@ -201,31 +175,19 @@ } } else { // Vrac > Species > Alive not itemized - SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch( - speciesBatch, - "Vrac > Species > Alive not itemized", - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED); + SortingBatch livingNotItemizedBatch = batchTreeHelper.getSpeciesVracAliveNotItemizedRootBatch(speciesBatch); if (livingNotItemizedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracSpeciesLifeNotFound")); } // Vrac > Species > Inert - SortingBatch inertBatch = batchHelper.getSortingBatch( - speciesBatch, - "Vrac > Species > Inert", - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT); + SortingBatch inertBatch = batchTreeHelper.getSpeciesVracInertRootBatch(speciesBatch); if (inertBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracSpeciesInertNotFound")); } // Vrac > Species > Alive itemized - SortingBatch aliveItemizedBatch = batchHelper.getSortingBatch( - speciesBatch, - "Vrac > Species > Alive itemized", - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED); + SortingBatch aliveItemizedBatch = batchTreeHelper.getSpeciesVracAliveItemizedRootBatch(speciesBatch); if (aliveItemizedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracSpeciesAliveItemizedNotFound")); } @@ -242,31 +204,19 @@ } else { // Vrac > Benthos > Alive not itemized - SortingBatch livingNotItemizedBatch = batchHelper.getSortingBatch( - benthosBatch, - "Vrac > Benthos > Alive not itemized", - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_NOT_ITEMIZED); + SortingBatch livingNotItemizedBatch = batchTreeHelper.getBenthosVracAliveNotItemizedRootBatch(benthosBatch); if (livingNotItemizedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracBenthosLifeNotFound")); } // Vrac > Benthos > Inert - SortingBatch inertBatch = batchHelper.getSortingBatch( - benthosBatch, - "Vrac > Benthos > Inert", - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_INERT); + SortingBatch inertBatch = batchTreeHelper.getBenthosVracInertRootBatch(benthosBatch); if (inertBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracBenthosInertNotFound")); } // Vrac > Benthos > Alive itemized - SortingBatch aliveItemizedBatch = batchHelper.getSortingBatch( - benthosBatch, - "Vrac > Benthos > Alive itermized", - enumeration.PMFM_ID_SORTING_TYPE_2, - enumeration.QUALITATIVE_ID_SORTING_TYPE_2_ALIVE_ITEMIZED); + SortingBatch aliveItemizedBatch = batchTreeHelper.getBenthosVracAliveItemizedRootBatch(benthosBatch); if (aliveItemizedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.vracBenthosAliveItemizedNotFound")); } @@ -274,39 +224,23 @@ } // Hors Vrac - SortingBatch horsVracBatch = batchHelper.getSortingBatch( - batchs, - "Hors Vrac", - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_HORS_VRAC_ID); + SortingBatch horsVracBatch = batchTreeHelper.getHorsVracBatch(batch); if (horsVracBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.horsVracNotFound")); } else { // Hors Vrac > Species - SortingBatch speciesBatch = batchHelper.getSortingBatch( - horsVracBatch, - "Hors Vrac > Species", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_SPECIES); + SortingBatch speciesBatch = batchTreeHelper.getSpeciesHorsVracRootBatch(horsVracBatch); if (speciesBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.horsVracSpeciesNotFound")); } // Hors Vrac > Benthos - SortingBatch benthosBatch = batchHelper.getSortingBatch( - horsVracBatch, - "Hors Vrac > Benthos", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS); + SortingBatch benthosBatch = batchTreeHelper.getBenthosHorsVracRootBatch(horsVracBatch); if (benthosBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.horsVracBenthosNotFound")); } // Hors Vrac > Marine Litter - SortingBatch marineLitterBatch = batchHelper.getSortingBatch( - horsVracBatch, - "Hors Vrac > Marine Litter", - enumeration.PMFM_ID_SORTING_TYPE, - enumeration.QUALITATIVE_ID_SORTING_TYPE_MARINE_LITTER); + SortingBatch marineLitterBatch = batchTreeHelper.getMarineLitterRootBatch(horsVracBatch); if (marineLitterBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.horsVracMarineLitterNotFound")); @@ -314,11 +248,7 @@ } // Unsorted - SortingBatch unsortedBatch = batchHelper.getSortingBatch( - batchs, - "Unsorted", - enumeration.PMFM_ID_SORTED_UNSORTED, - enumeration.QUALITATIVE_UNSORTED_ID); + SortingBatch unsortedBatch = batchTreeHelper.getRejectedBatch(batch); if (unsortedBatch == null) { addWarning(errors, n("tutti.persistence.batch.validation.unsortedNotFound")); } 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceReadTest.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -67,7 +67,7 @@ @Before public void setUp() throws Exception { - enumerationFile = TuttiPersistenceServiceLocator.getReferentialPersistenceService().getEnumerationFile(); + enumerationFile = TuttiPersistenceServiceLocator.getTechnicalPersistenceService().getEnumerationFile(); service = TuttiPersistenceServiceLocator.getBenthosBatchPersistenceService(); fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService(); 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceWriteTest.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -124,7 +124,7 @@ catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService(); fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService(); referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService(); - enumerationFile = referentialService.getEnumerationFile(); + enumerationFile = TuttiPersistenceServiceLocator.getTechnicalPersistenceService().getEnumerationFile(); species = referentialService.getAllSpecies(); assertNotNull(species); @@ -443,7 +443,8 @@ if (expectedBatch.getSampleCategoryValue() != null && expectedBatch.getSampleCategoryValue() instanceof CaracteristicQualitativeValue) { assertNotNull("Bad sampleCategoryValue : expected <" + ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId() + "> but was <null>", - actualBatch.getSampleCategoryValue()); + actualBatch.getSampleCategoryValue() + ); assertEquals( ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId(), ((CaracteristicQualitativeValue) actualBatch.getSampleCategoryValue()).getId()); 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceReadTest.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -66,7 +66,7 @@ @Before public void setUp() throws Exception { - enumerationFile = TuttiPersistenceServiceLocator.getReferentialPersistenceService().getEnumerationFile(); + enumerationFile = TuttiPersistenceServiceLocator.getTechnicalPersistenceService().getEnumerationFile(); service = TuttiPersistenceServiceLocator.getSpeciesBatchPersistenceService(); fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService(); 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceWriteTest.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -116,7 +116,7 @@ CatchBatchPersistenceService catchBatchService = TuttiPersistenceServiceLocator.getCatchBatchPersistenceService(); FishingOperationPersistenceService fishingOperationService = TuttiPersistenceServiceLocator.getFishingOperationPersistenceService(); ReferentialPersistenceService referentialService = TuttiPersistenceServiceLocator.getReferentialPersistenceService(); - enumerationFile = referentialService.getEnumerationFile(); + enumerationFile = TuttiPersistenceServiceLocator.getTechnicalPersistenceService().getEnumerationFile(); species = referentialService.getAllSpecies(); assertNotNull(species); @@ -436,7 +436,8 @@ if (expectedBatch.getSampleCategoryValue() != null && expectedBatch.getSampleCategoryValue() instanceof CaracteristicQualitativeValue) { assertNotNull("Bad sampleCategoryValue : expected <" + ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId() + "> but was <null>", - actualBatch.getSampleCategoryValue()); + actualBatch.getSampleCategoryValue() + ); assertEquals( ((CaracteristicQualitativeValue) expectedBatch.getSampleCategoryValue()).getId(), ((CaracteristicQualitativeValue) actualBatch.getSampleCategoryValue()).getId()); 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-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -732,6 +732,11 @@ } @Override + public Species getSpeciesByReferenceTaxonId(Integer referenceTaxonId) { + return driver.getSpeciesByReferenceTaxonId(referenceTaxonId); + } + + @Override public Species getSpeciesByReferenceTaxonIdWithVernacularCode(Integer referenceTaxonId) { return driver.getSpeciesByReferenceTaxonIdWithVernacularCode(referenceTaxonId); } @@ -772,6 +777,11 @@ } @Override + public TuttiLocation getLocation(String id) { + return driver.getLocation(id); + } + + @Override public List<Gear> getAllScientificGear() { return driver.getAllScientificGear(); } @@ -961,6 +971,11 @@ driver.deleteAttachment(attachmentId); } + @Override + public void deleteAllAttachment(AttachementObjectTypeEnum objectType, Integer... objectIds) { + driver.deleteAllAttachment(objectType, objectIds); + } + //------------------------------------------------------------------------// //-- Program methods --// //------------------------------------------------------------------------// @@ -1055,6 +1070,11 @@ } @Override + public List<String> getAllProtocolId() { + return driver.getAllProtocolId(); + } + + @Override public TuttiProtocol getProtocol(String id) { return driver.getProtocol(id); } @@ -1078,7 +1098,6 @@ //-- FishingOperation methods --// //------------------------------------------------------------------------// - @Override public int getFishingOperationCount(String cruiseId) { return driver.getFishingOperationCount(cruiseId); @@ -1130,6 +1149,11 @@ } @Override + public Collection<FishingOperation> saveFishingOperations(Collection<FishingOperation> beans) { + return driver.saveFishingOperations(beans); + } + + @Override public void deleteFishingOperation(String id) { driver.deleteFishingOperation(id); } @@ -1159,6 +1183,11 @@ return driver.saveCatchBatch(bean); } + @Override + public void deleteCatchBatch(String fishingOperationId) { + driver.deleteCatchBatch(fishingOperationId); + } + //------------------------------------------------------------------------// //-- Species Batch methods --// //------------------------------------------------------------------------// @@ -1263,7 +1292,7 @@ } //------------------------------------------------------------------------// - //-- Macrodechet Batch methods --// + //-- MarineLitter Batch methods --// //------------------------------------------------------------------------// @Override @@ -1310,6 +1339,11 @@ driver.deleteAccidentalBatch(id); } + @Override + public void deleteAccidentalBatchForFishingOperation(String fishingOperationId) { + driver.deleteAccidentalBatchForFishingOperation(fishingOperationId); + } + //------------------------------------------------------------------------// //-- IndividualObservation Batch methods --// //------------------------------------------------------------------------// @@ -1333,4 +1367,9 @@ public void deleteIndividualObservationBatch(String id) { driver.deleteIndividualObservationBatch(id); } + + @Override + public void deleteIndividualObservationBatchForFishingOperation(String fishingOperationId) { + driver.deleteIndividualObservationBatchForFishingOperation(fishingOperationId); + } } Modified: trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportRow.java =================================================================== --- trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportRow.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/export/generic/CatchExportRow.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -26,6 +26,7 @@ import com.google.common.base.Joiner; import com.google.common.base.Preconditions; +import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; import fr.ifremer.tutti.persistence.entities.data.Cruise; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/UpdateSchemaTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/UpdateSchemaTest.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/UpdateSchemaTest.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -30,7 +30,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.ClassRule; -import org.junit.Ignore; import org.junit.Test; import org.nuiton.util.Version; Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportService2Test.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -25,7 +25,6 @@ */ import com.google.common.io.Files; -import org.nuiton.jaxx.application.ApplicationBusinessException; import fr.ifremer.tutti.persistence.ProgressionModel; import fr.ifremer.tutti.service.PersistenceService; import fr.ifremer.tutti.service.ServiceDbResource; @@ -35,6 +34,7 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; +import org.nuiton.jaxx.application.ApplicationBusinessException; import java.io.File; import java.net.URL; @@ -196,8 +196,8 @@ "2013;test elevation;1;OTB 20/28.10;B;2;1;1358;;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;5.8333335;1.0\n" + "2013;test elevation;1;OTB 20/28.10;B;2;1;1358;;Alosa alosa;Trait B-2-1 ALOSALO Vrac|Trait B-2-1 ALOSALO Vrac - Femelle 40.0;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;40.0;8.75;1.0\n" + "2013;test elevation;1;OTB 20/28.10;B;2;1;1938;;Agonus cataphractus;Trait B-2-1 AGONCAT-horsvrac 20;Hors Vrac;1;20.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;20.0;1.0;1.0\n" + - "2013;test elevation;1;OTB 20/28.10;B;2;1;4622;;Abietinaria abietina;Trait B-2-1 Benthos ABIEABI Vrac 30@@@@avec @@@@commentaire...;Vrac;1;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;1.0\n" + - "2013;test elevation;1;OTB 20/28.10;B;2;1;380;;Acanthocardia echinata;Trait B-2-1 Benthos ACANECH Vrac 18@@@@avec @@@@commentaire...;Vrac;2;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;1.0\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;4622;;Abietinaria abietina;Trait B-2-1 Benthos ABIEABI Vrac 30@@@@avec @@@@commentaire...;Vrac;101;30.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;30.0;7.0;1.0\n" + + "2013;test elevation;1;OTB 20/28.10;B;2;1;380;;Acanthocardia echinata;Trait B-2-1 Benthos ACANECH Vrac 18@@@@avec @@@@commentaire...;Vrac;102;18.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;18.0;7.0;1.0\n" + "2013;test elevation;1;OTB 20/28.10;A;1;1;1938;;Agonus cataphractus;AGONCAT-vrac-80;Vrac;1;80.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;80.0;5.4444447;1.0\n" + "2013;test elevation;1;OTB 20/28.10;A;1;1;1358;;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-male 60;Vrac;2;;;Poids;kg;NA;;;;;kg;Mâle;1;60.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;;60.0;9.074075;1.0\n" + "2013;test elevation;1;OTB 20/28.10;A;1;1;1358;;Alosa alosa;ALOSALO-vrac|ALOSALO-vrac-femelle 40;Vrac;2;;;Poids;kg;NA;;;;;kg;Femelle;2;40.0;;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;5.0;1;0.6;cm;1.0;4;0.6;907.4074;1.0\n" + Modified: trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java =================================================================== --- trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-service/src/test/java/fr/ifremer/tutti/service/export/generic/TuttiExportServiceTest.java 2014-04-21 05:40:03 UTC (rev 1717) @@ -112,35 +112,35 @@ public static final String CATCH_CONTENT_2 = "Annee;Serie;Serie_Partielle;Engin;Code_station;Id_Operation;Poche;Code_Taxon;Code_Espece_Campagne;Nom_scientifique;Commentaire;V_HV;Num_Ordre_V_HV_H2;Tot_V_HV;Ech_V_HV;Type_Volume_Poids_V_HV;Unite_Volume_Poids_V_HV;Class_Tri;Num_Ordre_Class_Tri_H2;Tot_Class_Tri;Ech_Class_Tri;Type_Volume_Poids_Class_Tri;Unite_Volume_Poids_Class_Tri;Sexe;Num_Ordre_Sexe_H2;Tot_Sexe;Ech_Sexe;Type_Volume_Poids_Sexe;Unite_Volume_Poids_Sexe;Maturite;Num_Ordre_Maturite_H2;Tot_Maturite;Ech_Maturite;Type_Volume_Poids_Maturite;Unite_Volume_Poids_Maturite;Age;Num_Ordre_Age_H2;Tot_Age;Ech_Age;Type_Volume_Poids_Age;Unite_Volume_Poids_Age;Code_Longueur;Libelle_Longueur;Taille;NumOrdre_Taille_H2;Poids_Classe_Taille;Unite_Taille;Precision_Mesure;Nbr;Poids_Reference;Coef_Elev_Espece_Capture;Coef_Final_Elevation\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;365;;Aequipecten opercularis;taxon;Vrac;1;0.005;0.005;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.005;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;491;ALLOSPP;Alloteuthis;taxon;Vrac;2;0.004;0.004;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.004;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;300;;Buccinum undatum;taxon;Vrac;3;0.015;0.015;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.015;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1811;CALMLYR;Callionymus lyra;taxon;Vrac;4;0.07;0.07;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.07;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1644;DICELAB;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;36.0;1;;cm;1.0;1;1.06;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1644;DICELAB;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;38.0;2;;cm;1.0;1;1.06;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1362;ENGRENC;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;2;0.038;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1362;ENGRENC;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;12.5;2;;cm;0.5;1;0.038;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1362;ENGRENC;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;13.0;3;;cm;0.5;1;0.038;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1986;;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;25.0;1;;cm;1.0;1;0.66;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1986;;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;28.0;2;;cm;1.0;1;0.66;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1986;;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;3;;cm;1.0;1;0.66;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;489;LOLIVUL;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;9.0;1;;cm;1.0;1;0.28;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;489;LOLIVUL;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;10.0;2;;cm;1.0;3;0.28;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;489;LOLIVUL;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;11.0;3;;cm;1.0;2;0.28;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1988;;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;15.0;1;;cm;1.0;1;0.152;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1988;;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;18.0;2;;cm;1.0;1;0.152;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1690;MULLSUR;Mullus surmuletus;taxon;Vrac;10;0.036;0.036;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;1;;cm;1.0;1;0.036;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1978;;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;26.0;1;;cm;1.0;1;0.852;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1978;;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;2;;cm;1.0;1;0.852;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1351;SARDPIL;Sardina pilchardus;taxon;Vrac;12;0.022;0.022;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;1;0.022;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1772;SCOMSCO;Scomber scombrus;taxon;Vrac;13;0.18;0.18;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;27.0;1;;cm;1.0;1;0.18;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1242;SCYOCAN;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;51.0;1;;cm;1.0;1;1.0;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1242;SCYOCAN;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;55.0;2;;cm;1.0;1;1.0;1.0001919;1.0\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;8.0;1;;cm;1.0;1;0.96;136.69289;136.58333\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;9.0;2;;cm;1.0;20;0.96;136.69289;136.58333\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;10.0;3;;cm;1.0;89;0.96;136.69289;136.58333\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;4;;cm;1.0;5;0.96;136.69289;136.58333\n" + - "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;G - Gros;2;0.13;0.13;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;23.0;1;;cm;1.0;1;0.13;1009.42444;1.0"; + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;365;;Aequipecten opercularis;taxon;Vrac;1;0.005;0.005;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.005;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;491;ALLOSPP;Alloteuthis;taxon;Vrac;2;0.004;0.004;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.004;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;300;;Buccinum undatum;taxon;Vrac;3;0.015;0.015;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.015;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1811;CALMLYR;Callionymus lyra;taxon;Vrac;4;0.07;0.07;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;;;;;;;;1;0.07;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1644;DICELAB;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;36.0;1;;cm;1.0;1;1.06;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1644;DICELAB;Dicentrarchus labrax;taxon;Vrac;5;1.06;1.06;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;38.0;2;;cm;1.0;1;1.06;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1362;ENGRENC;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;2;0.038;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1362;ENGRENC;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;12.5;2;;cm;0.5;1;0.038;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1362;ENGRENC;Engraulis encrasicolus;taxon;Vrac;6;0.038;0.038;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;13.0;3;;cm;0.5;1;0.038;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1986;;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;25.0;1;;cm;1.0;1;0.66;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1986;;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;28.0;2;;cm;1.0;1;0.66;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1986;;Limanda limanda;taxon;Vrac;7;0.66;0.66;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;3;;cm;1.0;1;0.66;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;489;LOLIVUL;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;9.0;1;;cm;1.0;1;0.28;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;489;LOLIVUL;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;10.0;2;;cm;1.0;3;0.28;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;489;LOLIVUL;Loligo vulgaris;taxon;Vrac;8;0.28;0.28;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;302;Longueur du manteau (LM) - individu - manteau - Mesure au cm par un observateur;11.0;3;;cm;1.0;2;0.28;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1988;;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;15.0;1;;cm;1.0;1;0.152;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1988;;Microstomus kitt;taxon;Vrac;9;0.152;0.152;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;18.0;2;;cm;1.0;1;0.152;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1690;MULLSUR;Mullus surmuletus;taxon;Vrac;10;0.036;0.036;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;1;;cm;1.0;1;0.036;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1978;;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;26.0;1;;cm;1.0;1;0.852;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1978;;Pleuronectes platessa;taxon;Vrac;11;0.852;0.852;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;30.0;2;;cm;1.0;1;0.852;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1351;SARDPIL;Sardina pilchardus;taxon;Vrac;12;0.022;0.022;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;307;Longueur totale (LT) - individu - totale - Mesure au 1/2 cm par un observateur;10.5;1;;cm;0.5;1;0.022;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1772;SCOMSCO;Scomber scombrus;taxon;Vrac;13;0.18;0.18;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;27.0;1;;cm;1.0;1;0.18;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1242;SCYOCAN;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;51.0;1;;cm;1.0;1;1.0;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1242;SCYOCAN;Scyliorhinus canicula;taxon|categorie_individu;Vrac;14;;;Poids;kg;NA;;;;;kg;Femelle;1;1.0;1.0;Poids;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;55.0;2;;cm;1.0;1;1.0;1.0;1.0\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;8.0;1;;cm;1.0;1;0.96;136.71875;136.58333\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;9.0;2;;cm;1.0;20;0.96;136.71875;136.58333\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;10.0;3;;cm;1.0;89;0.96;136.71875;136.58333\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;P - Petit;1;131.12;0.96;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;11.0;4;;cm;1.0;5;0.96;136.71875;136.58333\n" + + "2010;Campagne CGFS;;GOV 19.7/25.9;20;20;1;1662;TRACTRA;Trachurus trachurus;taxon|categorie_individu;Vrac;15;;;Poids;kg;G - Gros;2;0.13;0.13;Poids;kg;NA;;;;;kg;NA;;;;;kg;NA;;;;;kg;306;Longueur totale (LT) - individu - totale - Mesure au cm par un observateur;23.0;1;;cm;1.0;1;0.13;1009.6154;1.0"; public static final String MARINE_LITTER_CONTENT = "Annee;Serie;Serie_Partielle;Engin;Code_station;Id_Operation;Poche;MarineLitterCategory;MarineLitterSizeCategory;Number;Weight;Commentaire\n" + @@ -380,6 +380,8 @@ @Test public void exportCatchesAndSpecies() throws Exception { +// persistenceService.clearAllCaches(); + File protocolFile = new File("src/test/resources/tuttiProtocol.tuttiProtocol"); TuttiProtocol protocol = dbResource.loadProtocol(protocolFile); Modified: trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties =================================================================== --- trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties 2014-04-21 04:44:42 UTC (rev 1716) +++ trunk/tutti-ui-swing/src/main/filtered-resources/log4j.properties 2014-04-21 05:40:03 UTC (rev 1717) @@ -31,6 +31,7 @@ # tutti levels log4j.logger.fr.ifremer=INFO +log4j.logger.fr.ifremer.tutti.persistence.service.batch.BatchTreeHelper=DEBUG #See https://forum.hibernate.org/viewtopic.php?p=2404391 log4j.logger.org.hibernate.engine.StatefulPersistenceContext.ProxyWarnLog=ERROR