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.announce.modules.workflow.business;
35
36 import fr.paris.lutece.plugins.announce.modules.workflow.service.AnnounceWorkflowPlugin;
37 import fr.paris.lutece.plugins.workflowcore.business.config.ITaskConfigDAO;
38 import fr.paris.lutece.util.sql.DAOUtil;
39
40
41
42
43 public class TaskChangeAnnounceStatusConfigDAO implements ITaskConfigDAO<TaskChangeAnnounceStatusConfig>
44 {
45 private static final String SQL_QUERY_FIND_BY_PRIMARY_KEY = "SELECT id_task,announce_published "
46 + "FROM workflow_task_change_announce_status_cf WHERE id_task=?";
47 private static final String SQL_QUERY_INSERT = "INSERT INTO workflow_task_change_announce_status_cf( " + "id_task,announce_published)" + "VALUES (?,?)";
48 private static final String SQL_QUERY_UPDATE = "UPDATE workflow_task_change_announce_status_cf SET announce_published = ?" + " WHERE id_task = ? ";
49 private static final String SQL_QUERY_DELETE = "DELETE FROM workflow_task_change_announce_status_cf WHERE id_task = ? ";
50
51
52
53
54 @Override
55 public synchronized void insert( TaskChangeAnnounceStatusConfig config )
56 {
57 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_INSERT, AnnounceWorkflowPlugin.getPlugin( ) );
58
59 int nPos = 0;
60
61 daoUtil.setInt( ++nPos, config.getIdTask( ) );
62 daoUtil.setBoolean( ++nPos, config.getPublish( ) );
63
64 daoUtil.executeUpdate( );
65 daoUtil.free( );
66 }
67
68
69
70
71 @Override
72 public void store( TaskChangeAnnounceStatusConfig config )
73 {
74 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE, AnnounceWorkflowPlugin.getPlugin( ) );
75
76 int nPos = 0;
77
78 daoUtil.setBoolean( ++nPos, config.getPublish( ) );
79
80 daoUtil.setInt( ++nPos, config.getIdTask( ) );
81 daoUtil.executeUpdate( );
82 daoUtil.free( );
83 }
84
85
86
87
88 @Override
89 public TaskChangeAnnounceStatusConfig load( int nIdTask )
90 {
91 TaskChangeAnnounceStatusConfig config = null;
92 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_BY_PRIMARY_KEY, AnnounceWorkflowPlugin.getPlugin( ) );
93
94 daoUtil.setInt( 1, nIdTask );
95
96 daoUtil.executeQuery( );
97
98 int nPos = 0;
99
100 if ( daoUtil.next( ) )
101 {
102 config = new TaskChangeAnnounceStatusConfig( );
103 config.setIdTask( daoUtil.getInt( ++nPos ) );
104 config.setPublish( daoUtil.getBoolean( ++nPos ) );
105 }
106
107 daoUtil.free( );
108
109 return config;
110 }
111
112
113
114
115 @Override
116 public void delete( int nIdState )
117 {
118 DAOUtil daoUtil = new DAOUtil( SQL_QUERY_DELETE, AnnounceWorkflowPlugin.getPlugin( ) );
119
120 daoUtil.setInt( 1, nIdState );
121 daoUtil.executeUpdate( );
122 daoUtil.free( );
123 }
124 }