1 package fr.ifremer.tutti.persistence.service;
2
3 /*
4 * #%L
5 * Tutti :: Persistence
6 * %%
7 * Copyright (C) 2012 - 2014 Ifremer
8 * %%
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation, either version 3 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program. If not, see
21 * <http://www.gnu.org/licenses/gpl-3.0.html>.
22 * #L%
23 */
24
25 import fr.ifremer.adagio.core.dao.referential.ObjectTypeCode;
26 import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
27 import fr.ifremer.tutti.persistence.entities.data.Attachment;
28 import org.springframework.transaction.annotation.Transactional;
29
30 import java.io.File;
31 import java.util.List;
32 import java.util.Set;
33
34 /**
35 * To persist {@link Attachment}.
36 *
37 * @author Tony Chemit - chemit@codelutin.com
38 * @since 1.0.2
39 */
40 @Transactional(readOnly = true)
41 public interface AttachmentPersistenceService extends TuttiPersistenceServiceImplementor {
42
43 /**
44 * Get all attachments for the given object {@code objectId}.
45 *
46 * @param objectType type of object.
47 * @param objectId id of the object
48 * @return list of all attachments for the given {@code objectId}.
49 * (see {@link ObjectTypeCode})
50 */
51 List<Attachment> getAllAttachments(ObjectTypeCode objectType,
52 Integer objectId);
53
54 /**
55 * Get the file of the given {@code attachmentId}.
56 *
57 * @param attachmentId id of the attachment
58 * @return the file for the given attachment
59 */
60 File getAttachmentFile(String attachmentId);
61
62 /**
63 * Creates the given attachment.
64 *
65 * @param attachment attachment to create
66 * @param file file to store in this attachment
67 * @return the attachment with his id.
68 */
69 @Transactional(readOnly = false)
70 Attachment createAttachment(Attachment attachment, File file);
71
72
73 /**
74 * Saves the given attachment.
75 *
76 * @param attachment attachment to create
77 * @return the attachment with his id.
78 */
79 @Transactional(readOnly = false)
80 Attachment saveAttachment(Attachment attachment);
81
82
83 /**
84 * Deletes the given attachment given his id.
85 *
86 * @param attachmentId id of the attachment to delete
87 */
88 @Transactional(readOnly = false)
89 void deleteAttachment(String attachmentId);
90
91 /**
92 * Deletes all attachments of the given object id.
93 * @param objectType type of attachment
94 * @param objectId id of object
95 */
96 @Transactional(readOnly = false)
97 void deleteAllAttachment(ObjectTypeCode objectType, Integer objectId);
98
99 /**
100 * Deletes all attachments of the given object ids.
101 * @param objectType type of attachment
102 * @param objectIds ids of object
103 */
104 @Transactional(readOnly = false)
105 void deleteAllAttachment(ObjectTypeCode objectType, Set<Integer> objectIds);
106
107 }