View Javadoc
1   /*
2    * Copyright (c) 2002-2021, 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.newsletter.business.topic;
35  
36  import fr.paris.lutece.portal.service.plugin.Plugin;
37  
38  import java.util.List;
39  
40  /**
41   * Interface for NewsletterTopic DAO
42   */
43  public interface INewsletterTopicDAO
44  {
45      /**
46       * Get a {@link NewsletterTopic} by its primary key from the database
47       * 
48       * @param nId
49       *            The id of the {@link NewsletterTopic} to get
50       * @param plugin
51       *            The plugin
52       * @return The {@link NewsletterTopic} with the given id, or null if no {@link NewsletterTopic} has this id.
53       */
54      NewsletterTopic findByPrimaryKey( int nId, Plugin plugin );
55  
56      /**
57       * Insert a new {@link NewsletterTopic} into the database
58       * 
59       * @param newsletterTopic
60       *            The {@link NewsletterTopic} to insert.
61       * @param plugin
62       *            The plugin
63       */
64      void insert( NewsletterTopic newsletterTopic, Plugin plugin );
65  
66      /**
67       * Update a {@link NewsletterTopic} in the database
68       * 
69       * @param newsletterTopic
70       *            The new values of the {@link NewsletterTopic}.
71       * @param plugin
72       *            The plugin
73       */
74      void update( NewsletterTopic newsletterTopic, Plugin plugin );
75  
76      /**
77       * Delete a {@link NewsletterTopic} from the database
78       * 
79       * @param nId
80       *            The id of the {@link NewsletterTopic} to delete.
81       * @param plugin
82       *            The plugin
83       */
84      void remove( int nId, Plugin plugin );
85  
86      /**
87       * Get the list of {@link NewsletterTopic} associated with a given newsletter.
88       * 
89       * @param nIdNewsletter
90       *            The id of the newsletter
91       * @param plugin
92       *            The plugin
93       * @return The list of {@link NewsletterTopic} found.
94       */
95      List<NewsletterTopic> findAllByIdNewsletter( int nIdNewsletter, Plugin plugin );
96  
97      /**
98       * Update the order of a newsletter topic
99       * 
100      * @param nIdNewsletterTopic
101      *            The id of the newsletter topic to update
102      * @param nNewOrder
103      *            The new order of the topic
104      * @param plugin
105      *            The plugin
106      */
107     void updateNewsletterTopicOrder( int nIdNewsletterTopic, int nNewOrder, Plugin plugin );
108 
109     /**
110      * Get the list of newsletter topics associated to a given newsletter and with the given order in a section
111      * 
112      * @param nIdNewsletter
113      *            The id of the newsletter the topic must be associated with.
114      * @param nOrder
115      *            The order the topics must have
116      * @param nSection
117      *            The section of the Topic
118      * @param plugin
119      *            The plugin
120      * @return The list of newsletter topics. The list should contain only one or zero element. If it has more, then it indicates that several topics have the
121      *         same order and should be reordered.
122      */
123     List<NewsletterTopic> findByNewsletterIdAndOrder( int nIdNewsletter, int nOrder, int nSection, Plugin plugin );
124 
125     /**
126      * Get the next available order value for topics of a newsletter
127      * 
128      * @param nIdNewsletter
129      *            The id of the newsletter
130      * @param nSection
131      *            The section of the newsletter
132      * @param plugin
133      *            The plugin
134      * @return The next available order value
135      */
136     int getNewOrder( int nIdNewsletter, int nSection, Plugin plugin );
137 
138     /**
139      * Get the highest order for a given newsletter and a given section
140      * 
141      * @param nIdNewsletter
142      *            The id of the newsletter
143      * @param nSection
144      *            The id of the section
145      * @param plugin
146      *            The plugin
147      * @return The highest order actually used for the given newsletter and the given section
148      */
149     int getLastOrder( int nIdNewsletter, int nSection, Plugin plugin );
150 
151     /**
152      * Fill a blank in the order of topics of a newsletter.
153      * 
154      * @param nIdNewsletter
155      *            The newsletter to update the topics of
156      * @param nOrder
157      *            The order with no topic
158      * @param nSection
159      *            The section of topics to update
160      * @param plugin
161      *            the plugin
162      */
163     void fillBlankInOrder( int nIdNewsletter, int nOrder, int nSection, Plugin plugin );
164 
165     /**
166      * Remove every topic associated with a given newsletter
167      * 
168      * @param nIdNewsletter
169      *            The id of the newsletter to remove the topics of.
170      * @param plugin
171      *            The plugin
172      */
173     void removeAllByIdNewsletter( int nIdNewsletter, Plugin plugin );
174 }