View Javadoc

1   /*
2    * Copyright (c) 2002-2014, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.digglike.business;
35  
36  import fr.paris.lutece.util.date.DateUtil;
37  import fr.paris.lutece.util.xml.XmlUtil;
38  
39  import java.sql.Timestamp;
40  
41  import java.util.List;
42  import java.util.Locale;
43  
44  import javax.servlet.http.HttpServletRequest;
45  
46  
47  /**
48   *
49   * class comment
50   *
51   */
52  public class CommentSubmit
53  {
54      public static final int STATE_DISABLE = 0;
55      public static final int STATE_ENABLE = 1;
56      private static final String TAG_DIGG_SUBMIT_COMMENT = "digg-submit-comment";
57      private static final String TAG_DIGG_SUBMIT_COMMENT_DATE = "digg-submit-comment-date";
58      private static final String TAG_DIGG_SUBMIT_COMMENT_VALUE = "digg-submit-comment-value";
59      private static final String TAG_DIGGS_SUBMIT_COMMENTS = "digg-submit-comments";
60      private int _nIdCommentSubmit;
61      private DiggSubmit _diggSubmit;
62      private Timestamp _tDateComment;
63      private String _strValue;
64      private boolean _nActive;
65      private String _strLuteceUserKey;
66      private boolean _bOfficialAnswer;
67      private List<CommentSubmit> _listComments;
68      private int _nIdParent;
69      private Timestamp _tDateModify;
70  
71      /**
72       * return the id of the comment submit
73       * @return the id of the comment submit
74       */
75      public int getIdCommentSubmit(  )
76      {
77          return _nIdCommentSubmit;
78      }
79  
80      /**
81       * set the id of the comment submit
82       * @param idCommentSubmit the id of the comment submit
83       */
84      public void setIdCommentSubmit( int idCommentSubmit )
85      {
86          _nIdCommentSubmit = idCommentSubmit;
87      }
88  
89      /**
90      *
91      * @return the digg submit of the comment
92      */
93      public DiggSubmit getDiggSubmit(  )
94      {
95          return _diggSubmit;
96      }
97  
98      /**
99       * set the digg submit of the comment
100      * @param diggSubmit the digg submit of the comment
101      */
102     public void setDiggSubmit( DiggSubmit diggSubmit )
103     {
104         _diggSubmit = diggSubmit;
105     }
106 
107     /**
108      *  return the comment date
109      * @return the comment date
110      */
111     public Timestamp getDateComment(  )
112     {
113         return _tDateComment;
114     }
115 
116     /**
117      * set the comment date
118      * @param commentDate the comment date
119      */
120     public void setDateComment( Timestamp commentDate )
121     {
122         _tDateComment = commentDate;
123     }
124 
125     /**
126     *
127     * @return the value of the comment
128     */
129     public String getValue(  )
130     {
131         return _strValue;
132     }
133 
134     /**
135      * set the value of the comment
136      * @param value the value of the comment
137      */
138     public void setValue( String value )
139     {
140         _strValue = value;
141     }
142 
143     /**
144     *
145     * @return true if the comment is active
146     */
147     public boolean isActive(  )
148     {
149         return _nActive;
150     }
151 
152     /**
153      * set true if the comment is active
154      * @param active true if the comment is active
155      */
156     public void setActive( boolean active )
157     {
158         _nActive = active;
159     }
160 
161     /**
162     *
163     * @return the lutece user key associate to the digg submit
164     */
165     public String getLuteceUserKey(  )
166     {
167         return _strLuteceUserKey;
168     }
169 
170     /**
171      *
172      * set  the lutece user key associate to the digg submit
173      * @param luteceUserKey the lutece user key
174      */
175     public void setLuteceUserKey( String luteceUserKey )
176     {
177         _strLuteceUserKey = luteceUserKey;
178     }
179 
180     /**
181      * @param bOfficialAnswer the _bOfficialAnswer to set
182      */
183     public void setOfficialAnswer( Boolean bOfficialAnswer )
184     {
185         this._bOfficialAnswer = bOfficialAnswer;
186     }
187 
188     /**
189      * @return the _bOfficialAnswer
190      */
191     public Boolean isOfficialAnswer(  )
192     {
193         return _bOfficialAnswer;
194     }
195 
196     /**
197      * @param listComments the _listComments to set
198      */
199     public void setComments( List<CommentSubmit> listComments )
200     {
201         this._listComments = listComments;
202     }
203 
204     /**
205      * @return the _listComments
206      */
207     public List<CommentSubmit> getComments(  )
208     {
209         return _listComments;
210     }
211 
212     /**
213      * @param nIdParent the _nIdParent to set
214      */
215     public void setIdParent( int nIdParent )
216     {
217         this._nIdParent = nIdParent;
218     }
219 
220     /**
221      * @return the _nIdParent
222      */
223     public int getIdParent(  )
224     {
225         return _nIdParent;
226     }
227 
228     /**
229      *  return the last comment date
230      * @return the last comment date
231      */
232     public Timestamp getDateModify(  )
233     {
234         return _tDateModify;
235     }
236 
237     /**
238      * set the last comment date
239      * @param lastCommentDate the last comment date
240      */
241     public void setDateModify( Timestamp lastCommentDate )
242     {
243         _tDateModify = lastCommentDate;
244     }
245 
246     /**
247      * Returns the xml of this digg submit
248      *
249      * @param request The HTTP Servlet request
250      * @param locale the Locale
251      * @return the xml of this digg submit
252      */
253     public String getXml( HttpServletRequest request, Locale locale )
254     {
255         StringBuffer strXml = new StringBuffer(  );
256         XmlUtil.beginElement( strXml, TAG_DIGG_SUBMIT_COMMENT );
257 
258         XmlUtil.addElementHtml( strXml, TAG_DIGG_SUBMIT_COMMENT_DATE,
259             DateUtil.getDateString( getDateComment(  ), locale ) );
260         XmlUtil.addElementHtml( strXml, TAG_DIGG_SUBMIT_COMMENT_VALUE, getValue(  ) );
261 
262         XmlUtil.beginElement( strXml, TAG_DIGGS_SUBMIT_COMMENTS );
263 
264         if ( ( getComments(  ) != null ) && ( getComments(  ).size(  ) != 0 ) )
265         {
266             for ( CommentSubmit commentSubmit : getComments(  ) )
267             {
268                 strXml.append( commentSubmit.getXml( request, locale ) );
269             }
270         }
271 
272         XmlUtil.endElement( strXml, TAG_DIGGS_SUBMIT_COMMENTS );
273 
274         XmlUtil.endElement( strXml, TAG_DIGG_SUBMIT_COMMENT );
275 
276         return strXml.toString(  );
277     }
278 }