1 /*
2 * Copyright (c) 2002-2025, City of Paris
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright notice
10 * and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright notice
13 * and the following disclaimer in the documentation and/or other materials
14 * provided with the distribution.
15 *
16 * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * License 1.0
33 */
34 package fr.paris.lutece.plugins.document.business;
35
36 import java.util.Collection;
37 import java.util.List;
38
39 /**
40 * Interface for DocumentDAO
41 */
42 public interface IDocumentDAO
43 {
44 /**
45 * Generates a new primary key
46 *
47 * @return The new primary key
48 */
49 int newPrimaryKey( );
50
51 /**
52 * Delete a record from the table
53 *
54 * @param nDocumentId
55 * the document identifier
56 */
57 void delete( int nDocumentId );
58
59 /**
60 * Insert a new record in the table.
61 *
62 * @param document
63 * The document object
64 */
65 void insert( Document document );
66
67 /**
68 * Load the data of Document from the table
69 *
70 * @param nDocumentId
71 * The identifier of Document
72 * @return the instance of the Document
73 */
74 Document load( int nDocumentId );
75
76 /**
77 * Returns an instance of a document whose identifier is specified in parameter
78 *
79 * @param nDocumentId
80 * The Primary key of the document
81 * @return An instance of document
82 */
83 Document loadWithoutBinaries( int nDocumentId );
84
85 /**
86 * Returns documents by space id
87 *
88 * @param nSpaceId
89 * The space Id
90 * @return A list of documents
91 */
92 List<Document> loadFromSpaceId( int nSpaceId );
93
94 /**
95 * Load a resource (image, file, ...) corresponding to an attribute of a Document
96 *
97 * @param nDocumentId
98 * The Document Id
99 * @return the instance of the DocumentResource
100 */
101 DocumentResource loadResource( int nDocumentId );
102
103 /**
104 * Load a resource (image, file, ...) corresponding to an attribute of a Document
105 *
106 * @param nDocumentId
107 * The Document Id
108 * @param nAttributeId
109 * The Attribute Id
110 * @param bValidated
111 * true if we want the validated resource
112 * @return the instance of the DocumentResource
113 */
114 DocumentResource loadSpecificResource( int nDocumentId, int nAttributeId, boolean bValidated );
115
116 /**
117 * Gets all documents id
118 *
119 * @return A collection of Integer
120 */
121 Collection<Integer> selectAllPrimaryKeys( );
122
123 /**
124 * Gets all documents
125 *
126 * @return the document list
127 */
128 List<Document> selectAll( );
129
130 /**
131 * Load the list of documents
132 *
133 * @return The Collection of the Document ids
134 * @param filter
135 * The DocumentFilter Object
136 */
137 Collection<Integer> selectPrimaryKeysByFilter( DocumentFilter filter );
138
139 /**
140 * Load the list of documents
141 *
142 * @param filter
143 * The DocumentFilter Object
144 * @return The Collection of the Documents
145 */
146 List<Document> selectByFilter( DocumentFilter filter );
147
148 /**
149 * Load the list of published documents in relation with categories of specified document
150 *
151 * @param document
152 * The document with the categories
153 * @return The Collection of the Documents
154 */
155 List<Document> selectByRelatedCategories( Document document );
156
157 /**
158 * Update the record in the table
159 *
160 * @param document
161 * The reference of document
162 * @param bUpdateContent
163 * the boolean
164 */
165 void store( Document document, boolean bUpdateContent );
166
167 /**
168 * Load document attributes
169 *
170 * @param document
171 * the reference of the document
172 */
173 void loadAttributes( Document document );
174
175 /**
176 * Load document attributes
177 *
178 * @param document
179 * the reference of the document
180 * @param bValidated
181 * true if the content of the document must be validated, false otherwise
182 */
183 void loadAttributesWithoutBinaries( Document document, boolean bValidated );
184
185 /**
186 * Load document pageTemplatePath
187 *
188 * @param idPageTemplateDocument
189 * the Id page template identifier
190 * @return The page template document path
191 */
192 String getPageTemplateDocumentPath( int idPageTemplateDocument );
193
194 /**
195 * Load document type and date last modification for HTTP GET conditional request ("If-Modified-Since")
196 *
197 * @param nDocumentId
198 * @return the document
199 */
200 Document loadLastModifiedAttributes( int nDocumentId );
201
202 /**
203 * Validate the document attributes
204 *
205 * @param nDocumentId
206 * the Id of the document
207 */
208 void validateAttributes( int nDocumentId );
209
210 /**
211 * Load the data of last Document the user worked in from the table
212 *
213 * @param strUserName
214 * the user name
215 * @return the instance of the Document
216 */
217 Document loadLastModifiedDocumentFromUser( String strUserName );
218
219 /**
220 * Load the data of last Document the user worked in from the table
221 *
222 * @return the instance of the Document
223 */
224 Document loadLastPublishedDocument( );
225 }