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.notifycrm.business;
35
36 import fr.paris.lutece.plugins.workflow.modules.notifycrm.service.NotifyCRMPlugin;
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
46 public class TaskNotifyCRMConfigDAO implements ITaskConfigDAO<TaskNotifyCRMConfig>
47 {
48 private static final String SQL_QUERY_FIND_BY_PRIMARY_KEY = " SELECT id_task, id_directory, position_directory_entry_id_demand, position_directory_entry_user_guid, send_notification, sender_name, subject, message, status_text,position_directory_entry_crm_web_app_code " +
49 " FROM task_notify_crm_cf WHERE id_task = ? ";
50 private static final String SQL_QUERY_INSERT = " INSERT INTO task_notify_crm_cf( id_task, id_directory, position_directory_entry_id_demand, position_directory_entry_user_guid, send_notification, sender_name, subject, message, status_text, position_directory_entry_crm_web_app_code )" +
51 " VALUES ( ?,?,?,?,?,?,?,?,?,?) ";
52 private static final String SQL_QUERY_UPDATE = "UPDATE task_notify_crm_cf SET id_directory = ?, position_directory_entry_id_demand = ?, position_directory_entry_user_guid = ?, send_notification = ?, sender_name = ?, subject = ?, message = ?, status_text = ?, position_directory_entry_crm_web_app_code = ? " +
53 " WHERE id_task = ? ";
54 private static final String SQL_QUERY_DELETE = " DELETE FROM task_notify_crm_cf WHERE id_task = ? ";
55
56
57
58
59 @Override
60 public synchronized void insert( TaskNotifyCRMConfig config )
61 {
62 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, NotifyCRMPlugin.getPlugin( ) );
63
64 int nIndex = 1;
65
66 daoUtil.setInt( nIndex++, config.getIdTask( ) );
67 daoUtil.setInt( nIndex++, config.getIdDirectory( ) );
68 daoUtil.setInt( nIndex++, config.getPositionEntryDirectoryIdDemand( ) );
69 daoUtil.setInt( nIndex++, config.getPositionEntryDirectoryUserGuid( ) );
70 daoUtil.setBoolean( nIndex++, config.getSendNotification( ) );
71 daoUtil.setString( nIndex++, config.getSenderName( ) );
72 daoUtil.setString( nIndex++, config.getSubject( ) );
73 daoUtil.setString( nIndex++, config.getMessage( ) );
74 daoUtil.setString( nIndex++, config.getStatusText( ) );
75 daoUtil.setInt( nIndex++, config.getPositionEntryDirectoryCrmWebAppCode() );
76
77 daoUtil.executeUpdate( );
78 daoUtil.free( );
79 }
80
81
82
83
84 @Override
85 public void store( TaskNotifyCRMConfig config )
86 {
87 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE, NotifyCRMPlugin.getPlugin( ) );
88
89 int nIndex = 1;
90
91 daoUtil.setInt( nIndex++, config.getIdDirectory( ) );
92 daoUtil.setInt( nIndex++, config.getPositionEntryDirectoryIdDemand( ) );
93 daoUtil.setInt( nIndex++, config.getPositionEntryDirectoryUserGuid( ) );
94 daoUtil.setBoolean( nIndex++, config.getSendNotification( ) );
95 daoUtil.setString( nIndex++, config.getSenderName( ) );
96 daoUtil.setString( nIndex++, config.getSubject( ) );
97 daoUtil.setString( nIndex++, config.getMessage( ) );
98 daoUtil.setString( nIndex++, config.getStatusText( ) );
99 daoUtil.setInt( nIndex++, config.getPositionEntryDirectoryCrmWebAppCode() );
100
101 daoUtil.setInt( nIndex++, config.getIdTask( ) );
102 daoUtil.executeUpdate( );
103 daoUtil.free( );
104 }
105
106
107
108
109 @Override
110 public TaskNotifyCRMConfig load( int nIdTask )
111 {
112 TaskNotifyCRMConfig config = null;
113 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_BY_PRIMARY_KEY, NotifyCRMPlugin.getPlugin( ) );
114
115 daoUtil.setInt( 1, nIdTask );
116
117 daoUtil.executeQuery( );
118
119 int nIndex = 1;
120
121 if ( daoUtil.next( ) )
122 {
123 config = new TaskNotifyCRMConfig( );
124 config.setIdTask( daoUtil.getInt( nIndex++ ) );
125 config.setIdDirectory( daoUtil.getInt( nIndex++ ) );
126 config.setPositionEntryDirectoryIdDemand( daoUtil.getInt( nIndex++ ) );
127 config.setPositionEntryDirectoryUserGuid( daoUtil.getInt( nIndex++ ) );
128 config.setSendNotification( daoUtil.getBoolean( nIndex++ ) );
129 config.setSenderName( daoUtil.getString( nIndex++ ) );
130 config.setSubject( daoUtil.getString( nIndex++ ) );
131 config.setMessage( daoUtil.getString( nIndex++ ) );
132 config.setStatusText( daoUtil.getString( nIndex++ ) );
133 config.setPositionEntryDirectoryCrmWebAppCode(daoUtil.getInt( nIndex++ ));
134 }
135
136 daoUtil.free( );
137
138 return config;
139 }
140
141
142
143
144 @Override
145 public void delete( int nIdTask )
146 {
147 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE, NotifyCRMPlugin.getPlugin( ) );
148
149 daoUtil.setInt( 1, nIdTask );
150 daoUtil.executeUpdate( );
151 daoUtil.free( );
152 }
153 }