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