This is an automated email from the git hooks/post-receive script. New commit to branch feature/8114 in repository tutti. See http://git.codelutin.com/tutti.git commit a5abb230dd5e1b3e2b5de99484255308aebcf2dc Author: Tony CHEMIT <chemit@codelutin.com> Date: Sat Mar 12 07:46:40 2016 +0100 Meilleur API de suppression des pièces jointes --- .../persistence/service/AttachmentPersistenceService.java | 15 +++++++++++---- .../service/AttachmentPersistenceServiceImpl.java | 13 ++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java index 86e9269..8946fb0 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceService.java @@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; import java.io.File; import java.util.List; +import java.util.Set; /** * To persist {@link Attachment}. @@ -88,13 +89,19 @@ public interface AttachmentPersistenceService extends TuttiPersistenceServiceImp void deleteAttachment(String attachmentId); /** + * Deletes all attachments of the given object id. + * @param objectType type of attachment + * @param objectId id of object + */ + @Transactional(readOnly = false) + void deleteAllAttachment(ObjectTypeCode objectType, Integer objectId); + + /** * Deletes all attachments of the given object ids. - * - * @param objectType type of attachment + * @param objectType type of attachment * @param objectIds ids of object */ @Transactional(readOnly = false) - void deleteAllAttachment(ObjectTypeCode objectType, - Integer... objectIds); + void deleteAllAttachment(ObjectTypeCode objectType, Set<Integer> objectIds); } diff --git a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java index d7b8693..4a02b0c 100644 --- a/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java +++ b/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceImpl.java @@ -47,6 +47,7 @@ import java.io.File; import java.util.Collections; import java.util.Iterator; import java.util.List; +import java.util.Set; import static org.nuiton.i18n.I18n.t; @@ -238,11 +239,21 @@ public class AttachmentPersistenceServiceImpl extends AbstractPersistenceService } @Override - public void deleteAllAttachment(ObjectTypeCode objectType, Integer... objectIds) { + public void deleteAllAttachment(ObjectTypeCode objectType, Integer objectId) { + + List<Attachment> attachments = getAllAttachments(objectType, objectId); + attachments.forEach(this::delete); + + } + + @Override + public void deleteAllAttachment(ObjectTypeCode objectType, Set<Integer> objectIds) { + for (Integer objectId : objectIds) { List<Attachment> attachments = getAllAttachments(objectType, objectId); attachments.forEach(this::delete); } + } //------------------------------------------------------------------------// -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.