View Javadoc
1   /*
2    * Copyright (c) 2002-2023, City of 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.document.business.history;
35  
36  import fr.paris.lutece.portal.business.user.AdminUser;
37  import fr.paris.lutece.portal.business.user.AdminUserHome;
38  import fr.paris.lutece.portal.service.i18n.I18nService;
39  import fr.paris.lutece.portal.service.i18n.Localizable;
40  
41  import java.util.Locale;
42  
43  /**
44   * This class represents the business object HistoryEvent
45   */
46  public class HistoryEvent implements Localizable
47  {
48      private static final String USER_UNKNOWN = "unknown user";
49  
50      // Variables declarations
51      private int _nIdDocument;
52      private java.sql.Timestamp _eventDate;
53      private String _strEventUser;
54      private String _strEventMessageKey;
55      private String _strDocumentStateKey;
56      private String _strSpace;
57      private Locale _locale;
58  
59      /**
60       * Returns the IdDocument
61       *
62       * @return The IdDocument
63       */
64      public int getIdDocument( )
65      {
66          return _nIdDocument;
67      }
68  
69      /**
70       * Sets the IdDocument
71       *
72       * @param nIdDocument
73       *            The IdDocument
74       */
75      public void setIdDocument( int nIdDocument )
76      {
77          _nIdDocument = nIdDocument;
78      }
79  
80      /**
81       * Returns the Space
82       *
83       * @return The Space
84       */
85      public String getSpace( )
86      {
87          return _strSpace;
88      }
89  
90      /**
91       * Sets the Space
92       *
93       * @param strSpace
94       *            The Space
95       */
96      public void setSpace( String strSpace )
97      {
98          _strSpace = strSpace;
99      }
100 
101     /**
102      * Returns the EventDate
103      *
104      * @return The EventDate
105      */
106     public java.sql.Timestamp getDate( )
107     {
108         return _eventDate;
109     }
110 
111     /**
112      * Sets the EventDate
113      *
114      * @param eventDate
115      *            The EventDate
116      */
117     public void setDate( java.sql.Timestamp eventDate )
118     {
119         _eventDate = eventDate;
120     }
121 
122     /**
123      * Returns the EventUser
124      *
125      * @return The EventUser
126      */
127     public String getEventUser( )
128     {
129         return _strEventUser;
130     }
131 
132     /**
133      * Sets the EventUser
134      *
135      * @param strEventUser
136      *            The EventUser
137      */
138     public void setEventUser( String strEventUser )
139     {
140         _strEventUser = strEventUser;
141     }
142 
143     /**
144      * Returns the EventMessageKey
145      *
146      * @return The EventMessageKey
147      */
148     public String getEventMessageKey( )
149     {
150         return _strEventMessageKey;
151     }
152 
153     /**
154      * Sets the EventMessageKey
155      *
156      * @param strEventMessageKey
157      *            The EventMessageKey
158      */
159     public void setEventMessageKey( String strEventMessageKey )
160     {
161         _strEventMessageKey = strEventMessageKey;
162     }
163 
164     /**
165      * Returns the EventMessageKey
166      *
167      * @return The EventMessageKey
168      */
169     public String getDescription( )
170     {
171         String strUser = USER_UNKNOWN;
172         AdminUser user = AdminUserHome.findUserByLogin( _strEventUser );
173 
174         if ( user != null )
175         {
176             strUser = user.getFirstName( ) + " " + user.getLastName( );
177         }
178 
179         String [ ] args = {
180                 strUser, I18nService.getLocalizedString( _strDocumentStateKey, _locale ), _strSpace
181         };
182 
183         return I18nService.getLocalizedString( _strEventMessageKey, args, _locale );
184     }
185 
186     /**
187      * Sets the locale
188      *
189      * @param locale
190      *            The locale
191      */
192     public void setLocale( Locale locale )
193     {
194         _locale = locale;
195     }
196 
197     /**
198      * Returns the DocumentStateKey
199      *
200      * @return The DocumentStateKey
201      */
202     public String getDocumentStateKey( )
203     {
204         return _strDocumentStateKey;
205     }
206 
207     /**
208      * Sets the DocumentStateKey
209      *
210      * @param strDocumentStateKey
211      *            The DocumentStateKey
212      */
213     public void setDocumentStateKey( String strDocumentStateKey )
214     {
215         _strDocumentStateKey = strDocumentStateKey;
216     }
217 }