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.workflow.modules.ticketing.business.anonymisation;
35
36 import java.util.ArrayList;
37 import java.util.HashMap;
38 import java.util.List;
39 import java.util.Map;
40
41 import org.apache.commons.lang3.StringUtils;
42
43 import fr.paris.lutece.portal.service.plugin.Plugin;
44 import fr.paris.lutece.util.sql.DAOUtil;
45
46 public class AnonymisationDAO implements IAnonymisationDAO
47 {
48 private static final String IDS_TO_REPLACE = "%IDS%";
49 private static final String SQL_QUERY_SELECT_UPLOAD_FILES_HISTORY = "SELECT id_file FROM workflow_task_upload_files WHERE id_history = ?";
50
51 private static final String SQL_QUERY_SELECT_MESSAGE_NOTIFY_GRU_HISTORY_TOTAL = "SELECT message_email, message_guichet, message_agent,message_broadcast,message_sms FROM workflow_task_notify_gru_history WHERE id_history = ?";
52
53
54 private static final String SQL_QUERY_DELETE_MESSAGE_NOTIFY_GRU_HISTORY_LIST = "DELETE FROM workflow_task_notify_gru_history WHERE id_history IN (" + IDS_TO_REPLACE + ")";
55 private static final String SQL_QUERY_DELETE_ANONYMISATION_COMMENT_VALUE_HISTORY_LIST = "DELETE FROM workflow_task_comment_value WHERE id_history IN (" + IDS_TO_REPLACE + ")";
56 private static final String SQL_QUERY_DELETE_UPLOAD_FILES_HISTORY_LIST = "DELETE FROM workflow_task_upload_files WHERE id_history IN (" + IDS_TO_REPLACE + ")";
57 private static final String SQL_QUERY_DELETE_UPLOAD_HISTORY_LIST = "DELETE FROM workflow_task_upload_history WHERE id_history IN (" + IDS_TO_REPLACE + ")";
58
59 private static final String SQL_QUERY_DELETE_WORKFLOW_TICKETING_HISTORY_LIST = "DELETE FROM workflow_resource_history_ticketing WHERE id_history IN (" + IDS_TO_REPLACE + ")";
60
61 private static final String SQL_QUERY_DELETE_HIST_WORKFLOW_HISTORY_LIST = "DELETE FROM workflow_resource_history WHERE id_history IN (" + IDS_TO_REPLACE + ")";
62
63 private static final String SQL_QUERY_DELETE_USER_WORKFLOW_HISTORY_LIST = "DELETE FROM workflow_resource_user_history WHERE id_history IN (" + IDS_TO_REPLACE + ")";
64
65 private static final String SQL_QUERY_DELETE_RESOURCE_WORKFLOW = "DELETE FROM workflow_resource_workflow WHERE id_resource = ? ";
66
67
68
69
70 @Override
71 public Map<String, String> loadMessageNotifyHIstoryTotal( int idHistory, Plugin plugin )
72 {
73 Map<String, String> messageListHistory = new HashMap<>( );
74 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_MESSAGE_NOTIFY_GRU_HISTORY_TOTAL, plugin ) )
75 {
76 daoUtil.setInt( 1, idHistory );
77 daoUtil.executeQuery( );
78
79 if ( daoUtil.next( ) )
80 {
81 messageListHistory.put( "message_email", daoUtil.getString( 1 ) );
82 messageListHistory.put( "message_guichet", daoUtil.getString( 2 ) );
83 messageListHistory.put( "message_agent", daoUtil.getString( 3 ) );
84 messageListHistory.put( "message_broadcast", daoUtil.getString( 4 ) );
85 messageListHistory.put( "message_sms", daoUtil.getString( 5 ) );
86
87 }
88 }
89 return messageListHistory;
90 }
91
92
93
94
95
96 @Override
97 public List<Integer> getIdUploadFilesByIdHistory( int idHistory, Plugin plugin )
98 {
99 List<Integer> uploadIdFilesHistoryList = new ArrayList<>( );
100
101 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_SELECT_UPLOAD_FILES_HISTORY, plugin ) )
102 {
103 daoUtil.setInt( 1, idHistory );
104
105 daoUtil.executeQuery( );
106
107 while ( daoUtil.next( ) )
108 {
109 uploadIdFilesHistoryList.add( daoUtil.getInt( 1 ) );
110 }
111 }
112 return uploadIdFilesHistoryList;
113 }
114
115
116
117
118
119
120 @Override
121 public void deleteMessageNotifyGruByIdHistoryList( List<Integer> idHistoryList, Plugin plugin )
122 {
123 final String sql = StringUtils.replace( SQL_QUERY_DELETE_MESSAGE_NOTIFY_GRU_HISTORY_LIST, IDS_TO_REPLACE, StringUtils.join( idHistoryList, "," ) );
124 try ( DAOUtil daoUtil = new DAOUtil( sql, plugin ) )
125 {
126 daoUtil.executeUpdate( );
127 }
128 }
129
130
131
132
133 @Override
134 public void deleteHistoryWorkflowHistoryList( List<Integer> idHistoryList, Plugin plugin )
135 {
136 final String sql = StringUtils.replace( SQL_QUERY_DELETE_HIST_WORKFLOW_HISTORY_LIST, IDS_TO_REPLACE, StringUtils.join( idHistoryList, "," ) );
137 try ( DAOUtil daoUtil = new DAOUtil( sql, plugin ) )
138 {
139 daoUtil.executeUpdate( );
140 }
141 }
142
143
144
145
146 @Override
147 public void deleteWorkflowResource( int idTicket, Plugin plugin )
148 {
149 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE_RESOURCE_WORKFLOW, plugin ) )
150 {
151 daoUtil.setInt( 1, idTicket );
152 daoUtil.executeUpdate( );
153 }
154 }
155
156
157
158
159 @Override
160 public void deleteWorkflowTicketingHistoryList( List<Integer> idHistoryList, Plugin plugin )
161 {
162 final String sql = StringUtils.replace( SQL_QUERY_DELETE_WORKFLOW_TICKETING_HISTORY_LIST, IDS_TO_REPLACE, StringUtils.join( idHistoryList, "," ) );
163 try ( DAOUtil daoUtil = new DAOUtil( sql, plugin ) )
164 {
165 daoUtil.executeUpdate( );
166 }
167 }
168
169
170
171
172 @Override
173 public void deleteCommentValueIdHistoryList( List<Integer> idHistoryList, Plugin plugin )
174 {
175 final String sql = StringUtils.replace( SQL_QUERY_DELETE_ANONYMISATION_COMMENT_VALUE_HISTORY_LIST, IDS_TO_REPLACE, StringUtils.join( idHistoryList, "," ) );
176 try ( DAOUtil daoUtil = new DAOUtil( sql, plugin ) )
177 {
178 daoUtil.executeUpdate( );
179 }
180 }
181
182
183
184
185 @Override
186 public void deleteWorkflowUserHistoryList( List<Integer> idHistoryList, Plugin plugin )
187 {
188 final String sql = StringUtils.replace( SQL_QUERY_DELETE_USER_WORKFLOW_HISTORY_LIST, IDS_TO_REPLACE, StringUtils.join( idHistoryList, "," ) );
189 try ( DAOUtil daoUtil = new DAOUtil( sql, plugin ) )
190 {
191 daoUtil.executeUpdate( );
192 }
193 }
194
195
196
197
198 @Override
199 public void deleteUploadFilesIdHistoryList( List<Integer> idHistoryList, Plugin plugin )
200 {
201 final String sql = StringUtils.replace( SQL_QUERY_DELETE_UPLOAD_FILES_HISTORY_LIST, IDS_TO_REPLACE, StringUtils.join( idHistoryList, "," ) );
202 try ( DAOUtil daoUtil = new DAOUtil( sql, plugin ) )
203 {
204 daoUtil.executeUpdate( );
205 }
206 }
207
208
209
210
211 @Override
212 public void deleteUploadHistoryList( List<Integer> idHistoryList, Plugin plugin )
213 {
214 final String sql = StringUtils.replace( SQL_QUERY_DELETE_UPLOAD_HISTORY_LIST, IDS_TO_REPLACE, StringUtils.join( idHistoryList, "," ) );
215 try ( DAOUtil daoUtil = new DAOUtil( sql, plugin ) )
216 {
217 daoUtil.executeUpdate( );
218 }
219 }
220
221 }