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.contact.business;
35  
36  import fr.paris.lutece.portal.service.plugin.Plugin;
37  import fr.paris.lutece.util.ReferenceList;
38  
39  import java.util.Collection;
40  
41  /**
42   * IContactDAO Interface
43   */
44  public interface IContactDAO
45  {
46      /**
47       * Delete a record from the table
48       *
49       * @param contact
50       *            The Contact object
51       * @param plugin
52       *            The plugin
53       */
54      void delete( Contact contact, Plugin plugin );
55  
56      /**
57       * Insert a new record in the table.
58       *
59       *
60       * @param contact
61       *            The contact object
62       * @param plugin
63       *            The plugin
64       */
65      void insert( Contact contact, Plugin plugin );
66  
67      /**
68       * Load the data of Contact from the table
69       * 
70       * @param nContactId
71       *            The identifier of Contact
72       * @param plugin
73       *            The plugin
74       * @return the instance of the Contact
75       */
76      Contact load( int nContactId, Plugin plugin );
77  
78      /**
79       * Load the list of contacts
80       *
81       *
82       * @param plugin
83       *            The plugin
84       * @return The Collection of the Contacts
85       */
86      Collection<Contact> selectAll( Plugin plugin );
87  
88      /**
89       * Load the list of contacts
90       * 
91       * @return The Collection of the Contacts with the string at the top
92       * @param nIdContactList
93       *            The id of contactList
94       * @param strComboItem
95       *            the string to display at the top of the list
96       * @param plugin
97       *            The plugin
98       */
99      ReferenceList selectContactsByListWithString( int nIdContactList, String strComboItem, Plugin plugin );
100 
101     /**
102      * Update the record in the table
103      *
104      * @param contact
105      *            The reference of contact
106      * @param plugin
107      *            The plugin
108      */
109     void store( Contact contact, Plugin plugin );
110 
111     /**
112      * Update hits of the contact in contact and contact_list_contact tables
113      * 
114      * @param nIdContact
115      *            id of the contact
116      * @param nIdContactList
117      *            id of contact list
118      * @param plugin
119      *            the plugin Contact
120      */
121     void updateHits( int nIdContact, int nIdContactList, Plugin plugin );
122 
123     ////////////////////////////////////////// ORDER MANAGEMENT ////////////////////////////////
124 
125     /**
126      * Modify the order of a contact
127      * 
128      * @param nIdContactList
129      *            the id of contactList
130      * @param nNewOrder
131      *            The order number
132      * @param nId
133      *            The contact identifier
134      * @param plugin
135      *            The plugin
136      */
137     void storeContactOrder( int nNewOrder, int nId, int nIdContactList, Plugin plugin );
138 
139     /**
140      * Returns a contact identifier in a distinct order
141      * 
142      * @return The order of the Contact
143      * @param nIdContactList
144      *            the id of contactList
145      * @param nContactOrder
146      *            The order number
147      * @param plugin
148      *            The plugin
149      */
150     int selectContactIdByOrder( int nContactOrder, int nIdContactList, Plugin plugin );
151 
152     /**
153      * Returns a contact identifier in a distinct order
154      * 
155      * @return The order of the Contact
156      * @param nIdContact
157      *            the id of contact
158      * @param nIdContactList
159      *            the id of the contact List
160      * @param plugin
161      *            The plugin
162      */
163     int selectContactOrderById( int nIdContact, int nIdContactList, Plugin plugin );
164 }