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.appointment.business;
35
36 import fr.paris.lutece.plugins.workflow.modules.appointment.service.WorkflowAppointmentPlugin;
37 import fr.paris.lutece.plugins.workflowcore.business.config.ITaskConfigDAO;
38 import fr.paris.lutece.util.sql.DAOUtil;
39
40
41
42
43
44
45 public class TaskNotifyAdminAppointmentConfigDAO implements ITaskConfigDAO<TaskNotifyAdminAppointmentConfig>
46 {
47 private static final String SQL_QUERY_FIND_BY_PRIMARY_KEY = "SELECT id_task,id_admin_user,sender_name,sender_email,subject,message,recipients_cc,recipients_bcc,id_action_cancel,id_action_validate,ical_notification,create_notif,location FROM workflow_task_notify_admin_appointment_cf WHERE id_task=?";
48 private static final String SQL_QUERY_INSERT = "INSERT INTO workflow_task_notify_admin_appointment_cf( "
49 + "id_task,id_admin_user,sender_name,sender_email,subject,message,recipients_cc,recipients_bcc,id_action_cancel,id_action_validate,ical_notification, create_notif, location) "
50 + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)";
51 private static final String SQL_QUERY_UPDATE = "UPDATE workflow_task_notify_admin_appointment_cf "
52 + " SET id_admin_user = ?, sender_name = ?, sender_email = ?, subject = ?, message = ?, recipients_cc = ?, recipients_bcc = ?, id_action_cancel = ?, id_action_validate = ?, ical_notification = ?, create_notif = ?, location = ? WHERE id_task = ? ";
53 private static final String SQL_QUERY_DELETE = "DELETE FROM workflow_task_notify_admin_appointment_cf WHERE id_task = ? ";
54
55
56
57
58 @Override
59 public synchronized void insert( TaskNotifyAdminAppointmentConfig config )
60 {
61 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, WorkflowAppointmentPlugin.getPlugin( ) ) )
62 {
63 int nIndex = 1;
64
65 daoUtil.setInt( nIndex++, config.getIdTask( ) );
66 daoUtil.setInt( nIndex++, config.getIdAdminUser( ) );
67 daoUtil.setString( nIndex++, config.getSenderName( ) );
68 daoUtil.setString( nIndex++, config.getSenderEmail( ) );
69 daoUtil.setString( nIndex++, config.getSubject( ) );
70 daoUtil.setString( nIndex++, config.getMessage( ) );
71 daoUtil.setString( nIndex++, config.getRecipientsCc( ) );
72 daoUtil.setString( nIndex++, config.getRecipientsBcc( ) );
73 daoUtil.setInt( nIndex++, config.getIdActionCancel( ) );
74 daoUtil.setInt( nIndex++, config.getIdActionValidate( ) );
75 daoUtil.setBoolean( nIndex++, config.getSendICalNotif( ) );
76 daoUtil.setBoolean( nIndex++, config.getCreateNotif( ) );
77 daoUtil.setString( nIndex, config.getLocation( ) );
78
79 daoUtil.executeUpdate( );
80 }
81 }
82
83
84
85
86 @Override
87 public void store( TaskNotifyAdminAppointmentConfig config )
88 {
89 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE, WorkflowAppointmentPlugin.getPlugin( ) ) )
90 {
91 int nIndex = 1;
92 daoUtil.setInt( nIndex++, config.getIdAdminUser( ) );
93 daoUtil.setString( nIndex++, config.getSenderName( ) );
94 daoUtil.setString( nIndex++, config.getSenderEmail( ) );
95 daoUtil.setString( nIndex++, config.getSubject( ) );
96 daoUtil.setString( nIndex++, config.getMessage( ) );
97 daoUtil.setString( nIndex++, config.getRecipientsCc( ) );
98 daoUtil.setString( nIndex++, config.getRecipientsBcc( ) );
99 daoUtil.setInt( nIndex++, config.getIdActionCancel( ) );
100 daoUtil.setInt( nIndex++, config.getIdActionValidate( ) );
101 daoUtil.setBoolean( nIndex++, config.getSendICalNotif( ) );
102 daoUtil.setBoolean( nIndex++, config.getCreateNotif( ) );
103 daoUtil.setString( nIndex++, config.getLocation( ) );
104
105 daoUtil.setInt( nIndex, config.getIdTask( ) );
106 daoUtil.executeUpdate( );
107 }
108 }
109
110
111
112
113 @Override
114 public TaskNotifyAdminAppointmentConfig load( int nIdTask )
115 {
116 TaskNotifyAdminAppointmentConfig config = null;
117 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_BY_PRIMARY_KEY, WorkflowAppointmentPlugin.getPlugin( ) ) )
118 {
119 daoUtil.setInt( 1, nIdTask );
120
121 daoUtil.executeQuery( );
122 if ( daoUtil.next( ) )
123 {
124 int nIndex = 1;
125 config = new TaskNotifyAdminAppointmentConfig( );
126 config.setIdTask( daoUtil.getInt( nIndex++ ) );
127 config.setIdAdminUser( daoUtil.getInt( nIndex++ ) );
128 config.setSenderName( daoUtil.getString( nIndex++ ) );
129 config.setSenderEmail( daoUtil.getString( nIndex++ ) );
130 config.setSubject( daoUtil.getString( nIndex++ ) );
131 config.setMessage( daoUtil.getString( nIndex++ ) );
132 config.setRecipientsCc( daoUtil.getString( nIndex++ ) );
133 config.setRecipientsBcc( daoUtil.getString( nIndex++ ) );
134 config.setIdActionCancel( daoUtil.getInt( nIndex++ ) );
135 config.setIdActionValidate( daoUtil.getInt( nIndex++ ) );
136 config.setSendICalNotif( daoUtil.getBoolean( nIndex++ ) );
137 config.setCreateNotif( daoUtil.getBoolean( nIndex++ ) );
138 config.setLocation( daoUtil.getString( nIndex ) );
139 }
140 }
141 return config;
142 }
143
144
145
146
147 @Override
148 public void delete( int nIdTask )
149 {
150 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE, WorkflowAppointmentPlugin.getPlugin( ) ) )
151 {
152 daoUtil.setInt( 1, nIdTask );
153 daoUtil.executeUpdate( );
154 }
155 }
156 }