Author: tchemit Date: 2013-04-20 16:33:56 +0200 (Sat, 20 Apr 2013) New Revision: 838 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/838 Log: fixes #2334: Avoir une nouvelle base avec les pmfm cr?\195?\169es par Vincent fixes #2340: [TECH] Possibilit?\195?\169 d'avoir des collisions sur les pi?\195?\168ces jointes fixes #2281: [TECH] - R?\195?\169percution des nouveaut?\195?\169s du mod?\195?\168le adagio Modified: 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/data/AttachementObjectTypeEnum.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/AttachmentPersistenceService.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/BenthosBatchPersistenceServiceImpl.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/PlanktonBatchPersistenceServiceImpl.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/TuttiEnumerationFile.java trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceWriteTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceWriteTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/DatabaseSynchroFixtures.java trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeHelperTest.java trunk/tutti-persistence/src/test/server.properties trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java 2013-04-20 14:33:56 UTC (rev 838) @@ -25,6 +25,7 @@ */ 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; @@ -298,12 +299,14 @@ //------------------------------------------------------------------------// /** - * Get all attachments for the given object {@code objectId}. + * Get all attachments for the given object {@code objectId} of type. * - * @param objectId id of the object + * @param objectType type of attachment + * @param objectId id of the object * @return list of all attachments for the given {@code objectId}. */ - List<Attachment> getAllAttachments(Integer objectId); + List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType, + Integer objectId); /** * Get the file of the given {@code attachmentId}. 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -28,6 +28,7 @@ import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException; import fr.ifremer.adagio.core.service.technical.CacheService; 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; @@ -408,8 +409,9 @@ //------------------------------------------------------------------------// @Override - public List<Attachment> getAllAttachments(Integer objectId) { - return attachmentService.getAllAttachments(objectId); + public List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType, + Integer objectId) { + return attachmentService.getAllAttachments(objectType, objectId); } @Override Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -25,6 +25,7 @@ */ 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; @@ -510,7 +511,8 @@ } @Override - public List<Attachment> getAllAttachments(Integer objectId) { + public List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType, + Integer objectId) { throw new RuntimeException("method not implemented"); } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/AttachementObjectTypeEnum.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/AttachementObjectTypeEnum.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/AttachementObjectTypeEnum.java 2013-04-20 14:33:56 UTC (rev 838) @@ -44,6 +44,7 @@ SCIENTIFIC_CRUISE("OBJECT_TYPE_SCIENTIFIC_CRUISE"), OPERATION("OBJECT_TYPE_OPERATION"), CATCH_BATCH("OBJECT_TYPE_CATCH_BATCH"), + BATCH("OBJECT_TYPE_BATCH"), SAMPLE("OBJECT_TYPE_SAMPLE"); private final String fieldName; 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AccidentalBatchPersistenceServiceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -42,6 +42,7 @@ import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory; import fr.ifremer.tutti.persistence.entities.TuttiEntities; import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; import fr.ifremer.tutti.persistence.entities.referential.Species; @@ -167,7 +168,9 @@ log.info("Will delete accidental batch: " + batchId); } sampleDao.remove(batchId); - attachmentPersistenceService.deleteAllAttachment(batchId); + attachmentPersistenceService.deleteAllAttachment( + AttachementObjectTypeEnum.SAMPLE, + batchId); } // ------------------------------------------------------------------------// Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java 2013-04-20 14:33:56 UTC (rev 838) @@ -25,6 +25,7 @@ */ import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.Attachment; import org.springframework.transaction.annotation.Transactional; @@ -46,7 +47,8 @@ * @param objectId id of the object * @return list of all attachments for the given {@code objectId}. */ - List<Attachment> getAllAttachments(Integer objectId); + List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType, + Integer objectId); /** * Get the file of the given {@code attachmentId}. @@ -88,9 +90,11 @@ /** * Deletes all attachments of the given object id. * - * @param objectId id of the object + * @param objectType type of attachment + * @param objectId id of the object */ @Transactional(readOnly = false) - void deleteAllAttachment(Integer objectId); + void deleteAllAttachment(AttachementObjectTypeEnum objectType, + Integer objectId); } 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -38,6 +38,7 @@ import org.apache.commons.logging.Log; 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.dao.InvalidDataAccessResourceUsageException; @@ -88,10 +89,13 @@ //------------------------------------------------------------------------// @Override - public List<Attachment> getAllAttachments(Integer objectId) { + public List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType, + Integer objectId) { Iterator<Object[]> list = queryList( "allAttachment", - "objectId", IntegerType.INSTANCE, objectId); + "objectId", IntegerType.INSTANCE, objectId, + "objectTypeCode", StringType.INSTANCE, objectType.getFieldValue() + ); List<Attachment> result = Lists.newArrayList(); while (list.hasNext()) { @@ -239,8 +243,9 @@ } @Override - public void deleteAllAttachment(Integer objectId) { - List<Attachment> attachments = getAllAttachments(objectId); + public void deleteAllAttachment(AttachementObjectTypeEnum objectType, + Integer objectId) { + List<Attachment> attachments = getAllAttachments(objectType, objectId); for (Attachment attachment : attachments) { delete(attachment); } 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BenthosBatchPersistenceServiceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -38,6 +38,7 @@ import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxon; import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxonImpl; import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.BenthosBatch; import fr.ifremer.tutti.persistence.entities.data.BenthosBatchFrequency; @@ -45,6 +46,7 @@ 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 org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.FlushMode; @@ -212,7 +214,9 @@ Integer batchId = Integer.valueOf(id); catchBatchDao.removeWithChildren(batchId); - attachmentPersistenceService.deleteAllAttachment(batchId); + attachmentPersistenceService.deleteAllAttachment( + AttachementObjectTypeEnum.BATCH, + batchId); getCurrentSession().flush(); } @@ -220,7 +224,47 @@ @Override public void deleteBenthosSubBatch(String id) { Preconditions.checkNotNull(id); - deleteBenthosBatch(id); + getCurrentSession().setFlushMode(FlushMode.COMMIT); + + Integer benthosBatchId = Integer.valueOf(id); + + // get catch batch + Integer catchBatchId = catchBatchDao.getIdBySortingBatchId(benthosBatchId); + + Preconditions.checkNotNull( + catchBatchId, + "Could not find catchBatch for benthosBatch: " + benthosBatchId); + + CatchBatch catchBatch = + catchBatchDao.loadFullTree(catchBatchId); + + // get species batch + SortingBatch sortingBatch = catchBatchDao.getSortingBatchById( + catchBatch, benthosBatchId); + + // get his children + Collection<Batch> childBatchs = sortingBatch.getChildBatchs(); + + if (CollectionUtils.isNotEmpty(childBatchs)) { + + for (Batch childBatch : childBatchs) { + + // delete this child and all his children + Integer childBatchId = childBatch.getId(); + + if (log.isInfoEnabled()) { + log.info("Delete child [" + childBatchId + "] of species batch: " + id); + } + catchBatchDao.removeWithChildren(childBatchId); + + // delete his attachment (if any) + attachmentPersistenceService.deleteAllAttachment( + AttachementObjectTypeEnum.BATCH, + childBatchId); + } + } + + getCurrentSession().flush(); } @Override 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/FishingOperationPersistenceServiceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -63,6 +63,7 @@ import fr.ifremer.adagio.core.service.referential.location.LocationService; import fr.ifremer.tutti.persistence.entities.CaracteristicMap; import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; @@ -399,7 +400,9 @@ public void deleteFishingOperation(String id) { Preconditions.checkNotNull(id); - attachmentPersistenceService.deleteAllAttachment(Integer.valueOf(id)); + attachmentPersistenceService.deleteAllAttachment( + AttachementObjectTypeEnum.OPERATION, + Integer.valueOf(id)); } //------------------------------------------------------------------------// 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -44,6 +44,7 @@ import fr.ifremer.tutti.persistence.entities.CaracteristicMap; import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory; import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; @@ -202,7 +203,8 @@ if (sample != null) { sample.getSampleMeasurements().clear(); sampleDao.remove(sample); - attachmentPersistenceService.deleteAllAttachment(batchId); + attachmentPersistenceService.deleteAllAttachment(AttachementObjectTypeEnum.SAMPLE, + batchId); } } 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/MarineLitterBatchPersistenceServiceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -37,6 +37,7 @@ import fr.ifremer.adagio.core.dao.referential.pmfm.QualitativeValueImpl; import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory; import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; import fr.ifremer.tutti.persistence.entities.referential.Caracteristic; @@ -193,7 +194,9 @@ Integer batchId = Integer.valueOf(id); catchBatchDao.removeWithChildren(batchId); - attachmentPersistenceService.deleteAllAttachment(batchId); + attachmentPersistenceService.deleteAllAttachment( + AttachementObjectTypeEnum.BATCH, + batchId); getCurrentSession().flush(); } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/PlanktonBatchPersistenceServiceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -26,6 +26,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -70,6 +71,8 @@ @Override public void deletePlanktonBatch(String id) { Preconditions.checkNotNull(id); - attachmentPersistenceService.deleteAllAttachment(Integer.valueOf(id)); + attachmentPersistenceService.deleteAllAttachment( + AttachementObjectTypeEnum.BATCH, + Integer.valueOf(id)); } } 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/SpeciesBatchPersistenceServiceImpl.java 2013-04-20 14:33:56 UTC (rev 838) @@ -38,6 +38,7 @@ import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxon; import fr.ifremer.adagio.core.dao.referential.taxon.ReferenceTaxonImpl; import fr.ifremer.tutti.persistence.entities.TuttiBeanFactory; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum; import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch; @@ -209,7 +210,9 @@ Integer batchId = Integer.valueOf(id); catchBatchDao.removeWithChildren(batchId); - attachmentPersistenceService.deleteAllAttachment(batchId); + attachmentPersistenceService.deleteAllAttachment( + AttachementObjectTypeEnum.BATCH, + batchId); getCurrentSession().flush(); } @@ -252,7 +255,9 @@ catchBatchDao.removeWithChildren(childBatchId); // delete his attachment (if any) - attachmentPersistenceService.deleteAllAttachment(childBatchId); + attachmentPersistenceService.deleteAllAttachment( + AttachementObjectTypeEnum.BATCH, + childBatchId); } } Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/TuttiEnumerationFile.java 2013-04-20 14:33:56 UTC (rev 838) @@ -257,6 +257,9 @@ @Value("${ObjectTypeCode.CATCH_BATCH}") public final String OBJECT_TYPE_CATCH_BATCH = null; + @Value("${ObjectTypeCode.BATCH}") + public final String OBJECT_TYPE_BATCH = null; + @Value("${ObjectTypeCode.OPERATION}") public final String OBJECT_TYPE_OPERATION = null; Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java =================================================================== --- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/synchro/TuttiTable.java 2013-04-20 14:33:56 UTC (rev 838) @@ -100,6 +100,10 @@ PERSON, PERSON2USER_PROFIL(true), + // VESSEL_PERSON_ROLE + VESSEL_PERSON_ROLE, + VESSEL_PERSON, + //ORDER ORDER_ITEM, Modified: trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml =================================================================== --- trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/resources/queries-override.hbm.xml 2013-04-20 14:33:56 UTC (rev 838) @@ -440,9 +440,11 @@ MeasurementFileImpl m WHERE m.objectId = :objectId + AND m.objectType.code = :objectTypeCode ORDER BY m.id ]]> <query-param name="objectId" type="java.lang.Integer"/> + <query-param name="objectTypeCode" type="java.lang.Integer"/> </query> <query cacheable="true" name="attachment"> Modified: trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties =================================================================== --- trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/main/resources/tutti-db-enumerations.properties 2013-04-20 14:33:56 UTC (rev 838) @@ -385,15 +385,15 @@ #PSFM "Remis à l'eau mort ou vivant" PmfmId.DEAD_OR_ALIVE=1393 -#TODO A creer (type alphanumeric) FIXME Change Id when in next db +#TODO A creer (type alphanumeric) # PSFM "Pour référencer un autre id de pmfm" -PmfmId.ID_PSFM=1243 +PmfmId.ID_PSFM=1433 -#TODO A creer (type alphanumeric) FIXME Change Id when in next db -PmfmId.SAMPLE_ID=1424 +#TODO A creer (type alphanumeric) +PmfmId.SAMPLE_ID=1435 -#TODO A creer (type alphanumeric) FIXME Change Id when in next db -PmfmId.OTOLITHE_ID=1432 +#TODO A creer (type alphanumeric) +PmfmId.OTOLITHE_ID=1436 # (20=observateur volant, 95=Administrateur SIH) -> L'avantage du 20 est qu'il est inactif (=20), donc plus facilement detectable PersonId.UNKNOWN_RECORDER_PERSON=20 @@ -406,6 +406,7 @@ ObjectTypeCode.SCIENTIFIC_CRUISE=SCIENTIFIC_CRUISE ObjectTypeCode.OPERATION=OPERATION ObjectTypeCode.CATCH_BATCH=CATCH_BATCH +ObjectTypeCode.BATCH=BATCH ObjectTypeCode.SAMPLE=SAMPLE VesselPersonRoleId.SCIENTIFIC_CRUISE_MANAGER=2 Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/DatabaseFixtures.java 2013-04-20 14:33:56 UTC (rev 838) @@ -97,7 +97,7 @@ } public int refNbCaracteristic() { - return 478; + return 481; } public int refNbSpecies() { @@ -145,7 +145,7 @@ } public int refNbScientificVessel() { - return 2; + return 3; } public int refNbPerson() { Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceWriteTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceWriteTest.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceWriteTest.java 2013-04-20 14:33:56 UTC (rev 838) @@ -61,7 +61,8 @@ Integer cruiseId = Integer.valueOf(dbResource.getFixtures().cruiseId()); - allAttachments = service.getAllAttachments(cruiseId); + allAttachments = service.getAllAttachments( + AttachementObjectTypeEnum.SCIENTIFIC_CRUISE, cruiseId); Assert.assertTrue(allAttachments.isEmpty()); // @@ -91,7 +92,8 @@ // reload it // - allAttachments = service.getAllAttachments(cruiseId); + allAttachments = service.getAllAttachments( + AttachementObjectTypeEnum.SCIENTIFIC_CRUISE, cruiseId); Assert.assertFalse(allAttachments.isEmpty()); Assert.assertEquals(1, allAttachments.size()); @@ -112,7 +114,8 @@ // reload it // - allAttachments = service.getAllAttachments(cruiseId); + allAttachments = service.getAllAttachments( + AttachementObjectTypeEnum.SCIENTIFIC_CRUISE, cruiseId); Assert.assertFalse(allAttachments.isEmpty()); Assert.assertEquals(1, allAttachments.size()); @@ -124,7 +127,8 @@ // service.deleteAttachment(attachment.getId()); - allAttachments = service.getAllAttachments(cruiseId); + allAttachments = service.getAllAttachments( + AttachementObjectTypeEnum.SCIENTIFIC_CRUISE, cruiseId); Assert.assertTrue(allAttachments.isEmpty()); Assert.assertFalse(attachmentFile.exists()); } Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceWriteTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceWriteTest.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/IndividualObservationBatchPersistenceServiceWriteTest.java 2013-04-20 14:33:56 UTC (rev 838) @@ -105,9 +105,8 @@ caracteristicMap.put(ageCaracteristic, 10.f); // add a string caracteristic - //FIXME Can't add it until we have correct pmfm id (with no collision here) -// Caracteristic stringCaracteristic = referentialService.getCaracteristic(dbResource.getFixtures().refAlphanumericPmfmId()); -// caracteristicMap.put(stringCaracteristic, "Un texte!"); + Caracteristic stringCaracteristic = referentialService.getCaracteristic(dbResource.getFixtures().refAlphanumericPmfmId()); + caracteristicMap.put(stringCaracteristic, "Un texte!"); fullIndividualObservationBatch.setComment("IndividualObservationBatch-full"); fullIndividualObservationBatch.setSamplingCode("SamplingCode"); Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/ReferentialPersistenceServiceReadTest.java 2013-04-20 14:33:56 UTC (rev 838) @@ -294,7 +294,7 @@ @Test public void getMacroWasteSizeCategoryCaracteristic() { Caracteristic result = service.getMarineLitterSizeCategoryCaracteristic(); - assertCaracteristicQualitative(result, 6); + assertCaracteristicQualitative(result, 7); } @Test(expected = UnsupportedOperationException.class) Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/DatabaseSynchroFixtures.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/DatabaseSynchroFixtures.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/DatabaseSynchroFixtures.java 2013-04-20 14:33:56 UTC (rev 838) @@ -129,6 +129,14 @@ return count(TuttiTable.PERSON); } + public int nbVesselPerson() { + return count(TuttiTable.VESSEL_PERSON); + } + + public int nbVesselPersonRole() { + return count(TuttiTable.VESSEL_PERSON_ROLE); + } + public int nbQualitativeValue() { return count(TuttiTable.QUALITATIVE_VALUE); } Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeHelperTest.java =================================================================== --- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeHelperTest.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/synchro/ReferentialSynchronizeHelperTest.java 2013-04-20 14:33:56 UTC (rev 838) @@ -82,7 +82,7 @@ protected Properties localConnectionProperties; - protected boolean checkDate = true; + protected boolean checkDate = false; @Before public void setUp() throws Exception { @@ -180,34 +180,34 @@ getLastUpdateDate(TuttiTable.UNIT, internalDb, getSqlDate(2012, 8, 17)); getLastUpdateDate(TuttiTable.AGGREGATION_LEVEL, internalDb, getSqlDate(2011, 6, 9)); - getLastUpdateDate(TuttiTable.PARAMETER_GROUP, internalDb, getSqlDate(2013, 4, 2)); - getLastUpdateDate(TuttiTable.PARAMETER, internalDb, getSqlDate(2013, 4, 2)); + getLastUpdateDate(TuttiTable.PARAMETER_GROUP, internalDb, getSqlDate(2013, 4, 18)); + getLastUpdateDate(TuttiTable.PARAMETER, internalDb, getSqlDate(2013, 4, 19)); getLastUpdateDate(TuttiTable.MATRIX, internalDb, getSqlDate(2013, 1, 24)); getLastUpdateDate(TuttiTable.FRACTION, internalDb, getSqlDate(2013, 1, 24)); getLastUpdateDate(TuttiTable.METHOD, internalDb, getSqlDate(2013, 1, 29)); - getLastUpdateDate(TuttiTable.PMFM, internalDb, getSqlDate(2013, 4, 2)); + getLastUpdateDate(TuttiTable.PMFM, internalDb, getSqlDate(2013, 4, 18)); getLastUpdateDate(TuttiTable.GEAR_CLASSIFICATION, internalDb, getSqlDate(2012, 12, 18)); getLastUpdateDate(TuttiTable.GEAR, internalDb, getSqlDate(2012, 12, 18)); getLastUpdateDate(TuttiTable.LOCATION_CLASSIFICATION, internalDb, getSqlDate(2010, 10, 26)); getLastUpdateDate(TuttiTable.LOCATION_LEVEL, internalDb, getSqlDate(2013, 1, 28)); - getLastUpdateDate(TuttiTable.LOCATION, internalDb, getSqlDate(2013, 3, 28)); + getLastUpdateDate(TuttiTable.LOCATION, internalDb, getSqlDate(2013, 4, 16)); getLastUpdateDate(TuttiTable.TAXONOMIC_LEVEL, internalDb, getSqlDate(2013, 2, 21)); - getLastUpdateDate(TuttiTable.REFERENCE_TAXON, internalDb, getSqlDate(2013, 3, 26)); - getLastUpdateDate(TuttiTable.TAXON_NAME, internalDb, getSqlDate(2013, 3, 28)); + getLastUpdateDate(TuttiTable.REFERENCE_TAXON, internalDb, getSqlDate(2013, 4, 12)); + getLastUpdateDate(TuttiTable.TAXON_NAME, internalDb, getSqlDate(2013, 4, 19)); getLastUpdateDate(TuttiTable.TAXON_GROUP_TYPE, internalDb, getSqlDate(2012, 5, 24)); getLastUpdateDate(TuttiTable.TAXON_GROUP, internalDb, getSqlDate(2013, 2, 20)); - getLastUpdateDate(TuttiTable.ROUND_WEIGHT_CONVERSION, internalDb, getSqlDate(2013, 3, 28)); + getLastUpdateDate(TuttiTable.ROUND_WEIGHT_CONVERSION, internalDb, getSqlDate(2013, 4, 5)); getLastUpdateDate(TuttiTable.WEIGHT_LENGTH_CONVERSION, internalDb, getSqlDate(2013, 2, 18)); getLastUpdateDate(TuttiTable.VESSEL_TYPE, internalDb, getSqlDate(2012, 4, 25)); - getLastUpdateDate(TuttiTable.VESSEL, internalDb, getSqlDate(2013, 3, 29)); + getLastUpdateDate(TuttiTable.VESSEL, internalDb, getSqlDate(2013, 4, 12)); getLastUpdateDate(TuttiTable.USER_PROFIL, internalDb, getSqlDate(2009, 6, 18)); getLastUpdateDate(TuttiTable.DEPARTMENT, internalDb, getSqlDate(2013, 2, 14)); - getLastUpdateDate(TuttiTable.PERSON, internalDb, getSqlDate(2013, 4, 2)); + getLastUpdateDate(TuttiTable.PERSON, internalDb, getSqlDate(2013, 4, 19)); getLastUpdateDate(TuttiTable.FRACTION2MATRIX, internalDb, null); getLastUpdateDate(TuttiTable.PMFM2QUALITATIVE_VALUE, internalDb, null); getLastUpdateDate(TuttiTable.GEAR_CLASSIFICATION_ASSOCIATIO, internalDb, getSqlDate(2012, 12, 18)); getLastUpdateDate(TuttiTable.GEAR_ASSOCIATION, internalDb, getSqlDate(2012, 12, 18)); - getLastUpdateDate(TuttiTable.LOCATION_ASSOCIATION, internalDb, getSqlDate(2013, 3, 27)); + getLastUpdateDate(TuttiTable.LOCATION_ASSOCIATION, internalDb, getSqlDate(2013, 4, 11)); getLastUpdateDate(TuttiTable.LOCATION_HIERARCHY, internalDb, null); getLastUpdateDate(TuttiTable.LOCATION_HIERARCHY_EXCEPTION, internalDb, null); getLastUpdateDate(TuttiTable.TAXON_INFORMATION, internalDb, getSqlDate(2012, 2, 13)); @@ -217,10 +217,10 @@ getLastUpdateDate(TuttiTable.UNIT_CONVERSION, internalDb, getSqlDate(2011, 11, 21)); getLastUpdateDate(TuttiTable.VESSEL_REGISTRATION_PERIOD, internalDb, null); getLastUpdateDate(TuttiTable.PERSON2USER_PROFIL, internalDb, null); - getLastUpdateDate(TuttiTable.TAXON_NAME_HISTORY, internalDb, getSqlDate(2013, 3, 28)); + getLastUpdateDate(TuttiTable.TAXON_NAME_HISTORY, internalDb, getSqlDate(2013, 4, 19)); getLastUpdateDate(TuttiTable.REFERENCE_DOCUMENT, internalDb, getSqlDate(2011, 11, 4)); getLastUpdateDate(TuttiTable.AUTHOR, internalDb, null); - getLastUpdateDate(TuttiTable.CITATION, internalDb, getSqlDate(2013, 3, 28)); + getLastUpdateDate(TuttiTable.CITATION, internalDb, getSqlDate(2013, 4, 19)); getLastUpdateDate(TuttiTable.TAXON_GROUP_HISTORICAL_RECORD, internalDb, getSqlDate(2013, 2, 20)); getLastUpdateDate(TuttiTable.ORDER_ITEM, internalDb, getSqlDate(2010, 5, 5)); getLastUpdateDate(TuttiTable.PRECISION_TYPE, internalDb, null); @@ -228,6 +228,8 @@ getLastUpdateDate(TuttiTable.PHOTO_TYPE, internalDb, getSqlDate(2010, 5, 26)); getLastUpdateDate(TuttiTable.OBJECT_TYPE, internalDb, getSqlDate(2013, 2, 14)); getLastUpdateDate(TuttiTable.ORDER_TYPE, internalDb, getSqlDate(2009, 10, 16)); + getLastUpdateDate(TuttiTable.VESSEL_PERSON, internalDb, null); + getLastUpdateDate(TuttiTable.VESSEL_PERSON_ROLE, internalDb, getSqlDate(2009, 10, 16)); getLastUpdateDate(TuttiTable.ANALYSIS_INSTRUMENT, internalDb, null); // try it on a empty db (all values are to null) @@ -283,6 +285,8 @@ getExistingPrimaryKeys(TuttiTable.USER_PROFIL, fixtures.nbUserProfil()); getExistingPrimaryKeys(TuttiTable.DEPARTMENT, fixtures.nbDepartment()); getExistingPrimaryKeys(TuttiTable.PERSON, fixtures.nbPerson()); + getExistingPrimaryKeys(TuttiTable.VESSEL_PERSON, fixtures.nbVesselPerson()); + getExistingPrimaryKeys(TuttiTable.VESSEL_PERSON_ROLE, fixtures.nbVesselPersonRole()); getExistingPrimaryKeys(TuttiTable.TAXON_NAME_HISTORY, fixtures.nbTaxonNameHistory()); getExistingPrimaryKeys(TuttiTable.REFERENCE_DOCUMENT, fixtures.nbReferenceDocument()); @@ -393,6 +397,9 @@ getDataToUpdate(TuttiTable.ORDER_TYPE, internalDb, internalConnection, fromDate, fixtures.nbOrderType()); getDataToUpdate(TuttiTable.ANALYSIS_INSTRUMENT, internalDb, internalConnection, fromDate, fixtures.nbAnalysisInstrument()); + getDataToUpdate(TuttiTable.VESSEL_PERSON, internalDb, internalConnection, fromDate, fixtures.nbVesselPerson()); + getDataToUpdate(TuttiTable.VESSEL_PERSON_ROLE, internalDb, internalConnection, fromDate, fixtures.nbVesselPersonRole()); + // try it on a empty db (nothing to synch) // create a external empty db @@ -485,6 +492,8 @@ updateTable(TuttiTable.OBJECT_TYPE, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbObjectType(), 0); updateTable(TuttiTable.ORDER_TYPE, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbOrderType(), 0); updateTable(TuttiTable.ANALYSIS_INSTRUMENT, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbAnalysisInstrument(), 0); + updateTable(TuttiTable.VESSEL_PERSON, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbVesselPerson(), 0); + updateTable(TuttiTable.VESSEL_PERSON_ROLE, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbVesselPersonRole(), 0); externalConnection.commit(); // externalConnection.rollback(); @@ -552,6 +561,8 @@ updateTable(TuttiTable.OBJECT_TYPE, internalDb, internalConnection, externalConnection, fromDate, 0, fixtures.nbObjectType()); updateTable(TuttiTable.ORDER_TYPE, internalDb, internalConnection, externalConnection, fromDate, 0, fixtures.nbOrderType()); updateTable(TuttiTable.ANALYSIS_INSTRUMENT, internalDb, internalConnection, externalConnection, fromDate, 0, fixtures.nbAnalysisInstrument()); + updateTable(TuttiTable.VESSEL_PERSON, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbVesselPerson(), 0); + updateTable(TuttiTable.VESSEL_PERSON_ROLE, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbVesselPersonRole(), 0); externalConnection.commit(); @@ -624,6 +635,8 @@ updateTable(TuttiTable.OBJECT_TYPE, internalDb, internalConnection, externalConnection, fromDate, 0, 0); updateTable(TuttiTable.ORDER_TYPE, internalDb, internalConnection, externalConnection, fromDate, 0, 0); updateTable(TuttiTable.ANALYSIS_INSTRUMENT, internalDb, internalConnection, externalConnection, fromDate, 0, 0); + updateTable(TuttiTable.VESSEL_PERSON, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbVesselPerson(), 0); + updateTable(TuttiTable.VESSEL_PERSON_ROLE, internalDb, internalConnection, externalConnection, fromDate, fixtures.nbVesselPersonRole(), 0); // add a aggregation level then synch String query = "INSERT INTO AGGREGATION_LEVEL (ID, NAME, RANK_ORDER, UPDATE_DATE) VALUES (-1000, 'NAME', -1000, NULL)"; Modified: trunk/tutti-persistence/src/test/server.properties =================================================================== --- trunk/tutti-persistence/src/test/server.properties 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-persistence/src/test/server.properties 2013-04-20 14:33:56 UTC (rev 838) @@ -23,5 +23,5 @@ ### server.database.0=file:db/allegro server.dbname.0=allegro -server.database.1=file:dbEmpty/allegro -server.dbname.1=allegroEmpty \ No newline at end of file +#server.database.1=file:dbEmpty/allegro +#server.dbname.1=allegroEmpty \ No newline at end of file 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 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java 2013-04-20 14:33:56 UTC (rev 838) @@ -32,6 +32,7 @@ import fr.ifremer.tutti.persistence.TuttiPersistenceNoDbImpl; import fr.ifremer.tutti.persistence.config.TuttiPersistenceConfig; 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; @@ -485,8 +486,9 @@ //------------------------------------------------------------------------// @Override - public List<Attachment> getAllAttachments(Integer objectId) { - return driver.getAllAttachments(objectId); + public List<Attachment> getAllAttachments(AttachementObjectTypeEnum objectType, + Integer objectId) { + return driver.getAllAttachments(objectType, objectId); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-04-20 14:33:56 UTC (rev 838) @@ -98,7 +98,8 @@ model.fromBean(cruise); // load attachments - List<Attachment> attachments = persistenceService.getAllAttachments(Integer.valueOf(model.getObjectId())); + List<Attachment> attachments = persistenceService.getAllAttachments( + model.getObjectType(), model.getObjectId()); model.addAllAttachment(attachments); if (log.isDebugEnabled()) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -152,8 +152,8 @@ } @Override - public String getObjectId() { - return getId(); + public Integer getObjectId() { + return getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/ValidateCruiseUIModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -77,7 +77,7 @@ } @Override - public String getObjectId() { + public Integer getObjectId() { return null; //To change body of implemented methods use File | Settings | File Templates. } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-04-20 14:33:56 UTC (rev 838) @@ -445,12 +445,13 @@ VesselUseFeatureTabUI vesselUseFeatureTabContent = ui.getVesselUseFeatureTabContent(); vesselUseFeatureTabContent.getHandler().reset(bean); - String id = editFishingOperationUIModel.getObjectId(); - if (id != null) { - Integer objectId = Integer.valueOf(id); + Integer objectId = editFishingOperationUIModel.getObjectId(); + if (objectId != null) { List<Attachment> attachments = - getContext().getPersistenceService().getAllAttachments(objectId); + getContext().getPersistenceService().getAllAttachments( + editFishingOperationUIModel.getObjectType(), + objectId); editFishingOperationUIModel.addAllAttachment(attachments); } @@ -532,7 +533,7 @@ batch = persistenceService.getCatchBatchFromFishingOperation(operationId); batch.setFishingOperation(bean); Integer objectId = Integer.valueOf(batch.getId()); - attachments = persistenceService.getAllAttachments(objectId); + attachments = persistenceService.getAllAttachments(catchesUIModel.getObjectType(), objectId); getModel().setCatchEnabled(true); } catch (InvalidBatchModelException e) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-04-20 14:33:56 UTC (rev 838) @@ -639,10 +639,10 @@ public void reset(FishingOperation bean) { - Integer objectId = Integer.valueOf(bean.getId()); - List<Attachment> attachments = - getContext().getPersistenceService().getAllAttachments(objectId); + getContext().getPersistenceService().getAllAttachments( + getModel().getObjectType(), + bean.getIdAsInt()); getModel().removeAllAttachment(getModel().getAttachment()); getModel().addAllAttachment(attachments); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -560,8 +560,8 @@ } @Override - public String getObjectId() { - return getId(); + public Integer getObjectId() { + return getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -90,8 +90,6 @@ protected TuttiComputedOrNotData<Float> marineLitterTotalComputedOrNotWeight = new TuttiComputedOrNotData<Float>(); - ; - protected TuttiComputedOrNotData<Float> catchTotalComputedOrNotWeight = new TuttiComputedOrNotData<Float>(); @@ -633,8 +631,8 @@ } @Override - public String getObjectId() { - return catchBatch == null ? null : catchBatch.getId(); + public Integer getObjectId() { + return catchBatch == null ? null : catchBatch.getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchRowModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -81,11 +81,9 @@ super(AccidentalBatch.class, fromBeanBinder, toBeanBinder); } - public AccidentalBatchRowModel(AccidentalBatch aBatch, - List<Attachment> attachments) { + public AccidentalBatchRowModel(AccidentalBatch aBatch) { this(); fromBean(aBatch); - this.attachment.addAll(attachments); } @Override @@ -213,8 +211,8 @@ } @Override - public String getObjectId() { - return getId(); + public Integer getObjectId() { + return getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-04-20 14:33:56 UTC (rev 838) @@ -38,7 +38,6 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.create.CreateAccidentalBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.create.CreateAccidentalBatchUIModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.IndividualObservationBatchTableModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.marinelitter.MarineLitterBatchRowModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; import fr.ifremer.tutti.ui.swing.util.TuttiUI; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; @@ -135,13 +134,14 @@ protected AccidentalBatchRowModel loadBatch(AccidentalBatch aBatch) { - Integer id = aBatch.getIdAsInt(); + AccidentalBatchRowModel newRow = + new AccidentalBatchRowModel(aBatch); List<Attachment> attachments = - persistenceService.getAllAttachments(id); + persistenceService.getAllAttachments(newRow.getObjectType(), + newRow.getObjectId()); - AccidentalBatchRowModel newRow = - new AccidentalBatchRowModel(aBatch, attachments); + newRow.addAllAttachment(attachments); return newRow; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -259,14 +259,12 @@ } public BenthosBatchRowModel(BenthosBatch aBatch, - List<BenthosBatchFrequency> frequencies, - List<Attachment> attachments) { + List<BenthosBatchFrequency> frequencies) { this(); fromBean(aBatch); List<BenthosFrequencyRowModel> frequencyRows = BenthosFrequencyRowModel.fromBeans(frequencies); frequency.addAll(frequencyRows); - this.attachment.addAll(attachments); Collections.sort(frequency); } @@ -628,8 +626,8 @@ } @Override - public String getObjectId() { - return getId(); + public Integer getObjectId() { + return getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-04-20 14:33:56 UTC (rev 838) @@ -222,11 +222,12 @@ BatchContainer<BenthosBatch> rootBenthosBatch = persistenceService.getRootBenthosBatch(bean.getId()); - model.setRootBatchId(rootBenthosBatch.getId()); + model.setRootBatchId(rootBenthosBatch.getIdAsInt()); List<Attachment> attachments = persistenceService.getAllAttachments( - Integer.valueOf(model.getObjectId())); + model.getObjectType(), + model.getObjectId()); model.addAllAttachment(attachments); if (log.isInfoEnabled()) { @@ -1055,16 +1056,20 @@ BenthosBatchRowModel parentRow, List<BenthosBatchRowModel> rows) { - String id = aBatch.getId(); - List<BenthosBatchFrequency> frequencies = - persistenceService.getAllBenthosBatchFrequency(id); + persistenceService.getAllBenthosBatchFrequency(aBatch.getId()); + + + BenthosBatchRowModel newRow = + new BenthosBatchRowModel(aBatch, frequencies); + List<Attachment> attachments = - persistenceService.getAllAttachments(Integer.valueOf(id)); + persistenceService.getAllAttachments(newRow.getObjectType(), + newRow.getObjectId()); - BenthosBatchRowModel newRow = - new BenthosBatchRowModel(aBatch, frequencies, attachments); + newRow.addAllAttachment(attachments); + // set the surveycode, do it only on the parent, // the species of the parent is set to the children in loadBatchRow if (parentRow == null && context.isProtocolFilled()) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -131,7 +131,7 @@ protected final List<Attachment> attachment = Lists.newArrayList(); - private String rootBatchId; + private Integer rootBatchId; public BenthosBatchUIModel(EditCatchesUIModel catchesUIModel) { super(catchesUIModel, @@ -355,13 +355,13 @@ firePropertyChange(PROPERTY_CREATE_MELAG_ENABLED, oldValue, createMelagEnabled); } - public void setRootBatchId(String rootBatchId) { - String oldValue = getObjectId(); + public void setRootBatchId(Integer rootBatchId) { + Integer oldValue = getObjectId(); this.rootBatchId = rootBatchId; firePropertyChange(PROPERTY_OBJECT_ID, oldValue, getObjectId()); } - public String getRootBatchId() { + public Integer getRootBatchId() { return rootBatchId; } @@ -371,11 +371,11 @@ @Override public AttachementObjectTypeEnum getObjectType() { - return AttachementObjectTypeEnum.CATCH_BATCH; + return AttachementObjectTypeEnum.BATCH; } @Override - public String getObjectId() { + public Integer getObjectId() { return rootBatchId; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchRowModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -76,11 +76,9 @@ super(IndividualObservationBatch.class, fromBeanBinder, toBeanBinder); } - public IndividualObservationBatchRowModel(IndividualObservationBatch aBatch, - List<Attachment> attachments) { + public IndividualObservationBatchRowModel(IndividualObservationBatch aBatch) { this(); fromBean(aBatch); - this.attachment.addAll(attachments); } @Override @@ -208,8 +206,8 @@ } @Override - public String getObjectId() { - return getId(); + public Integer getObjectId() { + return getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/individualobservation/IndividualObservationBatchUIHandler.java 2013-04-20 14:33:56 UTC (rev 838) @@ -25,7 +25,6 @@ import com.google.common.collect.Lists; import fr.ifremer.tutti.PropagatePropertyChangeListener; import fr.ifremer.tutti.persistence.entities.TuttiEntities; -import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.IndividualObservationBatch; @@ -36,7 +35,6 @@ import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel; -import fr.ifremer.tutti.ui.swing.content.operation.catches.accidental.AccidentalBatchRowModel; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.create.CreateIndividualObservationBatchUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.individualobservation.create.CreateIndividualObservationBatchUIModel; import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor; @@ -132,13 +130,14 @@ protected IndividualObservationBatchRowModel loadBatch(IndividualObservationBatch aBatch) { - Integer id = aBatch.getIdAsInt(); + IndividualObservationBatchRowModel newRow = + new IndividualObservationBatchRowModel(aBatch); List<Attachment> attachments = - persistenceService.getAllAttachments(id); + persistenceService.getAllAttachments(newRow.getObjectType(), + newRow.getObjectId()); - IndividualObservationBatchRowModel newRow = - new IndividualObservationBatchRowModel(aBatch, attachments); + newRow.addAllAttachment(attachments); return newRow; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchRowModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -76,11 +76,9 @@ super(MarineLitterBatch.class, fromBeanBinder, toBeanBinder); } - public MarineLitterBatchRowModel(MarineLitterBatch aBatch, - List<Attachment> attachments) { + public MarineLitterBatchRowModel(MarineLitterBatch aBatch) { this(); fromBean(aBatch); - this.attachment.addAll(attachments); } @Override @@ -172,8 +170,8 @@ } @Override - public String getObjectId() { - return getId(); + public Integer getObjectId() { + return getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIHandler.java 2013-04-20 14:33:56 UTC (rev 838) @@ -33,7 +33,6 @@ import fr.ifremer.tutti.persistence.entities.data.FishingOperation; import fr.ifremer.tutti.persistence.entities.data.MarineLitterBatch; import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue; -import fr.ifremer.tutti.service.DecoratorService; import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchTableUIHandler; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI; import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIHandler; @@ -59,7 +58,6 @@ import org.jdesktop.swingx.decorator.HighlightPredicate; import org.jdesktop.swingx.decorator.Highlighter; import org.jdesktop.swingx.table.DefaultTableColumnModelExt; -import org.nuiton.util.decorator.Decorator; import javax.swing.JComponent; import java.awt.Color; @@ -115,10 +113,12 @@ BatchContainer<MarineLitterBatch> batchContainer = persistenceService.getRootMarineLitterBatch(bean.getId()); - model.setRootBatchId(batchContainer.getId()); + model.setRootBatchId(batchContainer.getIdAsInt()); List<Attachment> attachments = - persistenceService.getAllAttachments(Integer.valueOf(model.getObjectId())); + persistenceService.getAllAttachments( + model.getObjectType(), + model.getObjectId()); model.addAllAttachment(attachments); if (log.isInfoEnabled()) { @@ -137,14 +137,13 @@ protected MarineLitterBatchRowModel loadBatch(MarineLitterBatch aBatch) { - Integer id = aBatch.getIdAsInt(); + MarineLitterBatchRowModel newRow = new MarineLitterBatchRowModel(aBatch); List<Attachment> attachments = - persistenceService.getAllAttachments(id); + persistenceService.getAllAttachments(newRow.getObjectType(), + newRow.getObjectId()); - MarineLitterBatchRowModel newRow = - new MarineLitterBatchRowModel(aBatch, attachments); - + newRow.addAllAttachment(attachments); return newRow; } @@ -322,18 +321,18 @@ // MarineLitter Category column addColumnToModel(columnModel, - null, - newTableCellRender(CaracteristicQualitativeValue.class, null), - MarineLitterBatchTableModel.MACRO_WASTE_CATEGORY); + null, + newTableCellRender(CaracteristicQualitativeValue.class, null), + MarineLitterBatchTableModel.MACRO_WASTE_CATEGORY); } { // MarineLitter Size Category column addColumnToModel(columnModel, - null, - newTableCellRender(CaracteristicQualitativeValue.class, null), - MarineLitterBatchTableModel.MACRO_WASTE_SIZE_CATEGORY); + null, + newTableCellRender(CaracteristicQualitativeValue.class, null), + MarineLitterBatchTableModel.MACRO_WASTE_SIZE_CATEGORY); } { // Number column Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/marinelitter/MarineLitterBatchUIModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -59,7 +59,7 @@ */ protected boolean removeBatchEnabled; - private String rootBatchId; + private Integer rootBatchId; public MarineLitterBatchUIModel(EditCatchesUIModel catchesUIModel) { super(catchesUIModel, @@ -96,13 +96,13 @@ firePropertyChange(PROPERTY_REMOVE_BATCH_ENABLED, oldValue, removeBatchEnabled); } - public void setRootBatchId(String rootBatchId) { - String oldValue = getObjectId(); + public void setRootBatchId(Integer rootBatchId) { + Integer oldValue = getObjectId(); this.rootBatchId = rootBatchId; firePropertyChange(PROPERTY_OBJECT_ID, oldValue, getObjectId()); } - public String getRootBatchId() { + public Integer getRootBatchId() { return rootBatchId; } @@ -116,11 +116,11 @@ @Override public AttachementObjectTypeEnum getObjectType() { - return AttachementObjectTypeEnum.CATCH_BATCH; + return AttachementObjectTypeEnum.BATCH; } @Override - public String getObjectId() { + public Integer getObjectId() { return rootBatchId; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchRowModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -183,8 +183,8 @@ } @Override - public String getObjectId() { - return getId(); + public Integer getObjectId() { + return getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -227,14 +227,12 @@ } public SpeciesBatchRowModel(SpeciesBatch aBatch, - List<SpeciesBatchFrequency> frequencies, - List<Attachment> attachments) { + List<SpeciesBatchFrequency> frequencies) { this(); fromBean(aBatch); List<SpeciesFrequencyRowModel> frequencyRows = SpeciesFrequencyRowModel.fromBeans(frequencies); frequency.addAll(frequencyRows); - this.attachment.addAll(attachments); Collections.sort(frequency); } @@ -720,8 +718,8 @@ } @Override - public String getObjectId() { - return getId(); + public Integer getObjectId() { + return getIdAsInt(); } @Override Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-04-20 14:33:56 UTC (rev 838) @@ -221,10 +221,11 @@ BatchContainer<SpeciesBatch> rootSpeciesBatch = persistenceService.getRootSpeciesBatch(bean.getId()); - model.setRootBatchId(rootSpeciesBatch.getId()); + model.setRootBatchId(rootSpeciesBatch.getIdAsInt()); List<Attachment> attachments = - persistenceService.getAllAttachments(Integer.valueOf(model.getObjectId())); + persistenceService.getAllAttachments(model.getObjectType(), + model.getObjectId()); model.addAllAttachment(attachments); if (log.isInfoEnabled()) { @@ -1083,11 +1084,15 @@ List<SpeciesBatchFrequency> frequencies = persistenceService.getAllSpeciesBatchFrequency(id); + SpeciesBatchRowModel newRow = + new SpeciesBatchRowModel(aBatch, frequencies); + List<Attachment> attachments = - persistenceService.getAllAttachments(Integer.valueOf(id)); + persistenceService.getAllAttachments(newRow.getObjectType(), + newRow.getObjectId()); + newRow.addAllAttachment(attachments); - SpeciesBatchRowModel newRow = - new SpeciesBatchRowModel(aBatch, frequencies, attachments); + // set the surveycode, do it only on the parent, // the species of the parent is set to the children in loadBatchRow if (parentRow == null && context.isProtocolFilled()) { Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-04-20 14:33:56 UTC (rev 838) @@ -131,7 +131,7 @@ protected final List<Attachment> attachment = Lists.newArrayList(); - private String rootBatchId; + private Integer rootBatchId; public SpeciesBatchUIModel(EditCatchesUIModel catchesUIModel) { super(catchesUIModel, @@ -336,13 +336,13 @@ firePropertyChange(PROPERTY_CREATE_MELAG_ENABLED, oldValue, createMelagEnabled); } - public void setRootBatchId(String rootBatchId) { - String oldValue = getObjectId(); + public void setRootBatchId(Integer rootBatchId) { + Integer oldValue = getObjectId(); this.rootBatchId = rootBatchId; firePropertyChange(PROPERTY_OBJECT_ID, oldValue, getObjectId()); } - public String getRootBatchId() { + public Integer getRootBatchId() { return rootBatchId; } @@ -352,11 +352,11 @@ @Override public AttachementObjectTypeEnum getObjectType() { - return AttachementObjectTypeEnum.CATCH_BATCH; + return AttachementObjectTypeEnum.BATCH; } @Override - public String getObjectId() { + public Integer getObjectId() { return rootBatchId; } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-04-20 14:33:56 UTC (rev 838) @@ -37,8 +37,6 @@ import jaxx.runtime.swing.ComponentResizer; import jaxx.runtime.validator.swing.SwingValidator; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import javax.swing.AbstractAction; import javax.swing.Action; @@ -66,10 +64,6 @@ */ public class AttachmentEditorUIHandler extends AbstractTuttiUIHandler<TuttiUIContext, AttachmentEditorUI> { - /** Logger. */ - private static final Log log = - LogFactory.getLog(AttachmentEditorUIHandler.class); - public static final String CLOSE_DIALOG_ACTION = "closeDialog"; public static final String SHOW_DIALOG_ACTION = "showDialog"; @@ -233,7 +227,7 @@ name = file.getName(); } attachment.setObjectType(bean.getObjectType()); - attachment.setObjectId(Integer.valueOf(bean.getObjectId())); + attachment.setObjectId(bean.getObjectId()); attachment.setName(name); attachment.setComment(ui.getFileComment().getText()); Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java 2013-04-20 12:52:37 UTC (rev 837) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java 2013-04-20 14:33:56 UTC (rev 838) @@ -45,7 +45,7 @@ AttachementObjectTypeEnum getObjectType(); - String getObjectId(); + Integer getObjectId(); List<Attachment> getAttachment();