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.chatbot.service.bot;
35
36 import fr.paris.lutece.portal.service.i18n.I18nService;
37
38 import java.io.Serializable;
39 import java.util.List;
40 import java.util.Locale;
41
42
43
44
45 public abstract class AbstractChatBot implements ChatBot, Serializable
46 {
47 private static final String URL_DEFAULT_BOT_AVATAR = "images/skin/plugins/chatbot/bot-avatar.png";
48 private static final long serialVersionUID = 1L;
49 private String _strKey;
50 private String _strName;
51 private String _strDescription;
52 private String _strNameI18nKey;
53 private String _strDescriptionI18nKey;
54 private String _strBotAvatarUrl;
55 private List<String> _listAvailableLanguages;
56 private boolean _bStandalone;
57 private String _strWelcomeMessage;
58
59
60
61
62
63
64 @Override
65 public String getKey( )
66 {
67 return _strKey;
68 }
69
70
71
72
73
74
75
76 public void setKey( String strKey )
77 {
78 _strKey = strKey;
79 }
80
81
82
83
84
85
86
87
88 @Override
89 public String getName( Locale locale )
90 {
91 String strName;
92
93 if ( _strNameI18nKey != null )
94 {
95 strName = I18nService.getLocalizedString( _strNameI18nKey, locale );
96 }
97 else
98 {
99 strName = _strName;
100 }
101
102 return strName;
103 }
104
105
106
107
108
109
110
111 public void setName( String strName )
112 {
113 _strName = strName;
114 }
115
116
117
118
119
120
121
122
123 @Override
124 public String getDescription( Locale locale )
125 {
126 String strDescription;
127
128 if ( _strDescriptionI18nKey != null )
129 {
130 strDescription = I18nService.getLocalizedString( _strDescriptionI18nKey, locale );
131 }
132 else
133 {
134 strDescription = _strDescription;
135 }
136
137 return strDescription;
138 }
139
140
141
142
143
144
145
146 public void setDescription( String strDescription )
147 {
148 _strDescription = strDescription;
149 }
150
151
152
153
154
155
156 public String getNameI18nKey( )
157 {
158 return _strNameI18nKey;
159 }
160
161
162
163
164
165
166
167 public void setNameI18nKey( String strNameI18nKey )
168 {
169 _strNameI18nKey = strNameI18nKey;
170 }
171
172
173
174
175
176
177 public String getDescriptionI18nKey( )
178 {
179 return _strDescriptionI18nKey;
180 }
181
182
183
184
185
186
187
188 public void setDescriptionI18nKey( String strDescriptionI18nKey )
189 {
190 _strDescriptionI18nKey = strDescriptionI18nKey;
191 }
192
193
194
195
196
197
198 @Override
199 public String getAvatarUrl( )
200 {
201 if ( _strBotAvatarUrl == null || _strBotAvatarUrl.equals( "" ) )
202 {
203 _strBotAvatarUrl = URL_DEFAULT_BOT_AVATAR;
204 }
205
206 return _strBotAvatarUrl;
207 }
208
209
210
211
212
213
214
215 public void setAvatarUrl( String strBotAvatarUrl )
216 {
217 _strBotAvatarUrl = strBotAvatarUrl;
218 }
219
220
221
222
223
224
225
226 public void setListAvailableLanguages( List<String> listAvailableLanguages )
227 {
228 _listAvailableLanguages = listAvailableLanguages;
229 }
230
231
232
233
234 @Override
235 public List<String> getAvailableLanguages( )
236 {
237 return _listAvailableLanguages;
238 }
239
240
241
242
243 @Override
244 public boolean isStandalone( )
245 {
246 return _bStandalone;
247 }
248
249
250
251
252
253
254
255 public void setStandalone( boolean bStandalone )
256 {
257 _bStandalone = bStandalone;
258 }
259
260
261
262
263
264
265 @Override
266 public String getWelcomeMessage( )
267 {
268 return _strWelcomeMessage;
269 }
270
271
272
273
274
275
276
277 public void setWelcomeMessage( String strWelcomeMessage )
278 {
279 _strWelcomeMessage = strWelcomeMessage;
280 }
281
282
283
284
285
286 @Override
287 public void reset( String strConversationId )
288 {
289
290 }
291 }