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.appointment.business.comment;
35
36 import java.util.ArrayList;
37 import java.util.List;
38
39 import fr.paris.lutece.portal.service.plugin.Plugin;
40 import fr.paris.lutece.util.sql.DAOUtil;
41
42
43
44
45
46
47 public class CommentNotificationConfigDAO implements ICommentNotificationConfigDAO
48 {
49 private static final String SQL_QUERY_FIND = "SELECT notify_type, sender_name,subject,message FROM appointment_comment_notification_cf";
50 private static final String SQL_QUERY_FIND_BY_TYPE = "SELECT notify_type, sender_name,subject,message FROM appointment_comment_notification_cf WHERE notify_type= ? ";
51
52 private static final String SQL_QUERY_UPDATE = "UPDATE appointment_comment_notification_cf SET sender_name=?,subject=?,message=? WHERE notify_type= ? ";
53
54
55
56
57 @Override
58 public void store( CommentNotificationConfig config, Plugin plugin )
59 {
60 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_UPDATE, plugin ) )
61 {
62 int nPos = 0;
63
64 daoUtil.setString( ++nPos, config.getSenderName( ) );
65 daoUtil.setString( ++nPos, config.getSubject( ) );
66 daoUtil.setString( ++nPos, config.getMessage( ) );
67
68 daoUtil.setString( ++nPos, config.getType( ).name( ) );
69 daoUtil.executeUpdate( );
70 }
71 }
72
73
74
75
76 @Override
77 public CommentNotificationConfig loadByType( String strType, Plugin plugin )
78 {
79 CommentNotificationConfig config = null;
80 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND_BY_TYPE, plugin ) )
81 {
82 daoUtil.setString( 1, strType );
83 daoUtil.executeQuery( );
84
85 if ( daoUtil.next( ) )
86 {
87 int nPos = 0;
88 config = new CommentNotificationConfig( );
89 config.setType( CommentNotificationConfig.NotificationType.valueOf( ( daoUtil.getString( ++nPos ) ) ) );
90 config.setSenderName( daoUtil.getString( ++nPos ) );
91 config.setSubject( daoUtil.getString( ++nPos ) );
92 config.setMessage( daoUtil.getString( ++nPos ) );
93 }
94 }
95 return config;
96 }
97
98
99
100
101 @Override
102 public List<CommentNotificationConfig> load( Plugin plugin )
103 {
104 List<CommentNotificationConfig> listCommentNotificationConfig = new ArrayList<>( );
105 try ( DAOUtil daoUtil = new DAOUtil( SQL_QUERY_FIND, plugin ) )
106 {
107 daoUtil.executeQuery( );
108
109 while ( daoUtil.next( ) )
110 {
111 int nPos = 0;
112 CommentNotificationConfigsiness/comment/CommentNotificationConfig.html#CommentNotificationConfig">CommentNotificationConfig config = new CommentNotificationConfig( );
113 config.setType( CommentNotificationConfig.NotificationType.valueOf( ( daoUtil.getString( ++nPos ) ) ) );
114 config.setSenderName( daoUtil.getString( ++nPos ) );
115 config.setSubject( daoUtil.getString( ++nPos ) );
116 config.setMessage( daoUtil.getString( ++nPos ) );
117 listCommentNotificationConfig.add( config );
118 }
119 }
120 return listCommentNotificationConfig;
121 }
122
123 }