1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.newsletter.business.portlet;
35
36 import fr.paris.lutece.plugins.newsletter.service.NewsletterPlugin;
37 import fr.paris.lutece.portal.business.portlet.Portlet;
38 import fr.paris.lutece.portal.service.plugin.Plugin;
39 import fr.paris.lutece.portal.service.plugin.PluginService;
40 import fr.paris.lutece.util.sql.DAOUtil;
41
42 import java.util.ArrayList;
43
44
45
46
47 public final class NewsLetterArchivePortletDAO implements INewsLetterArchivePortletDAO
48 {
49
50 private static final String SQL_QUERY_SELECT = "SELECT id_portlet FROM core_portlet WHERE id_portlet = ?";
51 private static final String SQL_QUERY_SELECT_SENDINGS_BY_PORTLET = "SELECT id_sending FROM newsletter_portlet_archive WHERE id_portlet = ?";
52 private static final String SQL_QUERY_INSERT_SENDING = "INSERT INTO newsletter_portlet_archive ( id_portlet, id_sending ) VALUES ( ?, ? )";
53 private static final String SQL_QUERY_DELETE_SENDING = "DELETE FROM newsletter_portlet_archive WHERE id_portlet = ? AND id_sending = ?";
54 private static final String SQL_QUERY_DELETE = "DELETE FROM newsletter_portlet_archive WHERE id_portlet=? ";
55
56
57
58
59
60
61
62
63
64
65 public void insert( Portlet portlet )
66 {
67
68 }
69
70
71
72
73
74
75
76
77 public void delete( int nPortletId )
78 {
79 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE, PluginService.getPlugin( NewsletterPlugin.PLUGIN_NAME ) );
80 daoUtil.setInt( 1, nPortletId );
81 daoUtil.executeUpdate( );
82 daoUtil.free( );
83 }
84
85
86
87
88
89
90
91
92 public Portlet load( int nPortletId )
93 {
94 NewsLetterArchivePortletiness/portlet/NewsLetterArchivePortlet.html#NewsLetterArchivePortlet">NewsLetterArchivePortlet portlet = new NewsLetterArchivePortlet( );
95
96 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT );
97
98 daoUtil.setInt( 1, nPortletId );
99
100 daoUtil.executeQuery( );
101
102 if ( daoUtil.next( ) )
103 {
104 portlet.setId( nPortletId );
105 }
106
107 daoUtil.free( );
108
109 return portlet;
110 }
111
112
113
114
115
116
117
118 public void store( Portlet portlet )
119 {
120
121 }
122
123
124
125
126
127
128
129
130
131 public void insertSending( int nPortletId, int nSendingId, Plugin plugin )
132 {
133 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT_SENDING, plugin );
134 daoUtil.setInt( 1, nPortletId );
135 daoUtil.setInt( 2, nSendingId );
136
137 daoUtil.executeUpdate( );
138 daoUtil.free( );
139 }
140
141
142
143
144
145
146
147
148
149 public void removeSending( int nPortletId, int nSendingId, Plugin plugin )
150 {
151 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE_SENDING, plugin );
152 daoUtil.setInt( 1, nPortletId );
153 daoUtil.setInt( 2, nSendingId );
154
155 daoUtil.executeUpdate( );
156 daoUtil.free( );
157 }
158
159
160
161
162
163
164
165
166 public ArrayList<Integer> findSendingsInPortlet( int nPortletId, Plugin plugin )
167 {
168 ArrayList<Integer> results = new ArrayList<Integer>( );
169
170 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_SENDINGS_BY_PORTLET, plugin );
171 daoUtil.setInt( 1, nPortletId );
172 daoUtil.executeQuery( );
173
174 while ( daoUtil.next( ) )
175 {
176 results.add( Integer.valueOf( daoUtil.getInt( 1 ) ) );
177 }
178
179 daoUtil.free( );
180
181 return results;
182 }
183 }