View Javadoc
1   /*
2    * Copyright (c) 2002-2024, 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.identitystore.business.identity;
35  
36  import fr.paris.lutece.portal.service.util.AppPropertiesService;
37  import org.apache.commons.lang3.StringUtils;
38  
39  import javax.validation.constraints.Size;
40  import java.io.Serializable;
41  import java.sql.Timestamp;
42  import java.util.HashMap;
43  import java.util.Map;
44  
45  /**
46   * This is the business class for the object Identity
47   */
48  public class Identity implements Serializable
49  {
50      private static final long serialVersionUID = 1L;
51  
52      // Variables declarations
53      private int _nId;
54      @Size( max = 50, message = "#i18n{identitystore.validation.identity.ConnectionId.size}" )
55      private String _strConnectionId;
56      @Size( max = 50, message = "#i18n{identitystore.validation.identity.CustomerId.size}" )
57      private String _strCustomerId;
58      private Map<String, IdentityAttribute> _mapAttributes = new HashMap<>( );
59      private boolean _bIsDeleted;
60      private Timestamp _dateCreationDate;
61  
62      private Timestamp _dateLastUpdateDate;
63      private boolean _bIsMerged;
64      private Timestamp _dateMergeDate;
65      private Integer _nMasterIdentityId;
66      private boolean _bIsMonParisActive;
67      private Timestamp _dateExpirationDate;
68      private Timestamp _dateDeleteDate;
69  
70      /**
71       * Returns the Id
72       *
73       * @return The Id
74       */
75      public int getId( )
76      {
77          return _nId;
78      }
79  
80      /**
81       * Sets the Id
82       *
83       * @param nId
84       *            The Id
85       */
86      public void setId( int nId )
87      {
88          _nId = nId;
89      }
90  
91      /**
92       * Returns the ConnectionId
93       *
94       * @return The ConnectionId
95       */
96      public String getConnectionId( )
97      {
98          return _strConnectionId;
99      }
100 
101     /**
102      * Sets the ConnectionId
103      *
104      * @param strConnectionId
105      *            The ConnectionId
106      */
107     public void setConnectionId( String strConnectionId )
108     {
109         _strConnectionId = strConnectionId;
110     }
111 
112     /**
113      * Returns the CustomerId
114      *
115      * @return The CustomerId
116      */
117     public String getCustomerId( )
118     {
119         return _strCustomerId;
120     }
121 
122     /**
123      * Sets the CustomerId
124      *
125      * @param strCustomerId
126      *            The CustomerId
127      */
128     public void setCustomerId( String strCustomerId )
129     {
130         _strCustomerId = strCustomerId;
131     }
132 
133     /**
134      * @return the _mapAttributes
135      */
136     public Map<String, IdentityAttribute> getAttributes( )
137     {
138         return _mapAttributes;
139     }
140 
141     /**
142      * @param mapAttributes
143      *            the mapAttributes to set
144      */
145     public void setAttributes( Map<String, IdentityAttribute> mapAttributes )
146     {
147         this._mapAttributes = mapAttributes;
148     }
149 
150     /**
151      * returns family name retrieve from attributes
152      *
153      * @return familyName
154      */
155     public String getFamilyName( )
156     {
157         String strFamilyName = StringUtils.EMPTY;
158 
159         if ( ( _mapAttributes != null )
160                 && ( _mapAttributes.get( AppPropertiesService.getProperty( IdentityConstants.PROPERTY_ATTRIBUTE_USER_PREFERRED_NAME ) ) != null ) )
161         {
162             strFamilyName = _mapAttributes.get( AppPropertiesService.getProperty( IdentityConstants.PROPERTY_ATTRIBUTE_USER_PREFERRED_NAME ) ).getValue( );
163         }
164 
165         return strFamilyName;
166     }
167 
168     /**
169      * returns first name retrieve from attributes
170      *
171      * @return first name
172      */
173     public String getFirstName( )
174     {
175         String strFirstName = StringUtils.EMPTY;
176 
177         if ( ( _mapAttributes != null )
178                 && ( _mapAttributes.get( AppPropertiesService.getProperty( IdentityConstants.PROPERTY_ATTRIBUTE_USER_NAME_GIVEN ) ) != null ) )
179         {
180             strFirstName = _mapAttributes.get( AppPropertiesService.getProperty( IdentityConstants.PROPERTY_ATTRIBUTE_USER_NAME_GIVEN ) ).getValue( );
181         }
182 
183         return strFirstName;
184     }
185 
186     /**
187      * check if the identity is connected
188      *
189      * @return true if connected
190      */
191     public boolean isConnected( )
192     {
193         return _bIsMonParisActive;
194     }
195 
196     /**
197      *
198      * @return the _bIsDeleted
199      */
200     public boolean isDeleted( )
201     {
202         return _bIsDeleted;
203     }
204 
205     /**
206      * set true if all the attibutes of identity are deleted
207      *
208      * @param bIsDeleted
209      *            if identity removed (softDelete)
210      */
211     public void setDeleted( boolean bIsDeleted )
212     {
213         _bIsDeleted = bIsDeleted;
214     }
215 
216     public Timestamp getCreationDate( )
217     {
218         return _dateCreationDate;
219     }
220 
221     public void setCreationDate( Timestamp creationDate )
222     {
223         this._dateCreationDate = creationDate;
224     }
225 
226     public boolean isMerged( )
227     {
228         return _bIsMerged;
229     }
230 
231     public void setMerged( boolean merged )
232     {
233         this._bIsMerged = merged;
234     }
235 
236     public Timestamp getMergeDate( )
237     {
238         return _dateMergeDate;
239     }
240 
241     public void setMergeDate( Timestamp mergeDate )
242     {
243         this._dateMergeDate = mergeDate;
244     }
245 
246     public Integer getMasterIdentityId( )
247     {
248         return _nMasterIdentityId;
249     }
250 
251     public void setMasterIdentityId( Integer _nMasterIdentityId )
252     {
253         this._nMasterIdentityId = _nMasterIdentityId;
254     }
255 
256     public Timestamp getLastUpdateDate( )
257     {
258         return _dateLastUpdateDate;
259     }
260 
261     public void setLastUpdateDate( Timestamp lastUpdateDate )
262     {
263         this._dateLastUpdateDate = lastUpdateDate;
264     }
265 
266     public boolean isMonParisActive( )
267     {
268         return _bIsMonParisActive;
269     }
270 
271     public void setMonParisActive( boolean _bIsMonParisActive )
272     {
273         this._bIsMonParisActive = _bIsMonParisActive;
274     }
275 
276     public Timestamp getExpirationDate( )
277     {
278         return _dateExpirationDate;
279     }
280 
281     public void setExpirationDate( Timestamp _dateExpirationDate )
282     {
283         this._dateExpirationDate = _dateExpirationDate;
284     }
285 
286     public Timestamp getDeleteDate( )
287     {
288         return _dateDeleteDate;
289     }
290 
291     public void setDeleteDate( Timestamp _dateDeleteDate )
292     {
293         this._dateDeleteDate = _dateDeleteDate;
294     }
295 }