View Javadoc
1   /*
2    * Copyright (c) 2002-2020, 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  /**
41   * Interface for DocumentDAO
42   */
43  public interface IDocumentDAO
44  {
45      /**
46       * Generates a new primary key
47       * @return The new primary key
48       */
49      int newPrimaryKey(  );
50  
51      /**
52       * Delete a record from the table
53       * @param nDocumentId the document identifier
54       */
55      void delete( int nDocumentId );
56  
57      /**
58       * Insert a new record in the table.
59       * @param document The document object
60       */
61      void insert( Document document );
62  
63      /**
64       * Load the data of Document from the table
65       * @param nDocumentId The identifier of Document
66       * @return the instance of the Document
67       */
68      Document load( int nDocumentId );
69  
70      /**
71       * Returns an instance of a document whose identifier is specified in parameter
72       *
73       * @param nDocumentId The Primary key of the document
74       * @return An instance of document
75       */
76      Document loadWithoutBinaries( int nDocumentId );
77  
78      /**
79       * Returns documents by space id
80       * @param nSpaceId The space Id
81       * @return A list of documents
82       */
83      List<Document> loadFromSpaceId( int nSpaceId );
84  
85      /**
86       * Load a resource (image, file, ...) corresponding to an attribute of a Document
87       * @param nDocumentId The Document Id
88       * @return the instance of the DocumentResource
89       */
90      DocumentResource loadResource( int nDocumentId );
91  
92      /**
93       * Load a resource (image, file, ...) corresponding to an attribute of a Document
94       * @param nDocumentId The Document Id
95       * @param nAttributeId The Attribute Id
96       * @param bValidated true if we want the validated resource
97       * @return the instance of the DocumentResource
98       */
99      DocumentResource loadSpecificResource( int nDocumentId, int nAttributeId, boolean bValidated );
100 
101     /**
102      * Gets all documents id
103      * @return A collection of Integer
104      */
105     Collection<Integer> selectAllPrimaryKeys(  );
106 
107     /**
108      * Gets all documents
109      *
110      * @return the document list
111      */
112     List<Document> selectAll(  );
113 
114     /**
115      * Load the list of documents
116      *
117      * @return The Collection of the Document ids
118      * @param filter The DocumentFilter Object
119      */
120     Collection<Integer> selectPrimaryKeysByFilter( DocumentFilter filter );
121 
122     /**
123      * Load the list of documents
124      * @param filter The DocumentFilter Object
125      * @return The Collection of the Documents
126      */
127     List<Document> selectByFilter( DocumentFilter filter );
128 
129     /**
130      * Load the list of published documents in relation with categories of specified document
131      * @param document The document with the categories
132      * @return The Collection of the Documents
133      */
134     List<Document> selectByRelatedCategories( Document document );
135 
136     /**
137      * Update the record in the table
138      * @param document The reference of document
139      * @param bUpdateContent the boolean
140      */
141     void store( Document document, boolean bUpdateContent );
142 
143     /**
144      * Load document attributes
145      * @param document the reference of the document
146      */
147     void loadAttributes( Document document );
148 
149     /**
150      * Load document attributes
151      * @param document the reference of the document
152      * @param bValidated true if the content of the document must be validated, false otherwise
153      */
154     void loadAttributesWithoutBinaries( Document document, boolean bValidated );
155 
156     /**
157      * Load document pageTemplatePath
158      * @param idPageTemplateDocument the Id page template identifier
159      * @return The page template document path
160      */
161     String getPageTemplateDocumentPath( int idPageTemplateDocument );
162 
163     /**
164      * Load document type and date last modification for HTTP GET conditional request ("If-Modified-Since")
165      * @param nDocumentId
166      * @return the document
167      */
168     Document loadLastModifiedAttributes( int nDocumentId );
169 
170     /**
171      * Validate the document attributes
172      * @param nDocumentId the Id of the document
173      */
174     void validateAttributes( int nDocumentId );
175 
176     /**
177      * Load the data of last Document the user worked in from the table
178      *
179      * @param strUserName the user name
180      * @return the instance of the Document
181      */
182     Document loadLastModifiedDocumentFromUser( String strUserName );
183 
184     /**
185      * Load the data of last Document the user worked in from the table
186      *
187      * @return the instance of the Document
188      */
189     Document loadLastPublishedDocument(  );
190 }