View Javadoc
1   /*
2    * Copyright (c) 2002-2021, 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.contact.business;
35  
36  import fr.paris.lutece.plugins.contact.service.ContactWorkgroupRemovalListener;
37  import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupResource;
38  import fr.paris.lutece.portal.service.workgroup.AdminWorkgroupService;
39  import fr.paris.lutece.portal.service.workgroup.WorkgroupRemovalListenerService;
40  
41  /**
42   * This class represents business object Contact
43   */
44  public class Contact implements AdminWorkgroupResource
45  {
46      public static final String RESOURCE_TYPE = "CONTACT";
47      private static final String EMPTY_STRING = "";
48      private static ContactWorkgroupRemovalListener _listenerWorkgroup;
49  
50      /////////////////////////////////////////////////////////////////////////////////
51      // Constants
52      private int _nId;
53      private int _nContactOrder;
54      private String _strName;
55      private String _strEmail;
56      private String _strAdminWorkgroup;
57      private int _nHits;
58  
59      /**
60       * Initialize the ContactList
61       */
62      public static void init( )
63      {
64          // Create removal listeners and register them
65          if ( _listenerWorkgroup == null )
66          {
67              _listenerWorkgroup = new ContactWorkgroupRemovalListener( );
68              WorkgroupRemovalListenerService.getService( ).registerListener( _listenerWorkgroup );
69          }
70      }
71  
72      /**
73       * Returns the identifier of this contact.
74       *
75       * @return the contact identifier
76       */
77      public int getId( )
78      {
79          return _nId;
80      }
81  
82      /**
83       * Sets the identifier of the contact to the specified integer.
84       *
85       * @param nId
86       *            the new identifier
87       */
88      public void setId( int nId )
89      {
90          _nId = nId;
91      }
92  
93      /**
94       * Returns the name of this contact.
95       *
96       * @return the contact name
97       */
98      public String getName( )
99      {
100         return _strName;
101     }
102 
103     /**
104      * Sets the name of the contact to the specified string.
105      *
106      * @param strName
107      *            the new name
108      */
109     public void setName( String strName )
110     {
111         _strName = ( strName == null ) ? EMPTY_STRING : strName;
112     }
113 
114     /**
115      * Returns the email of this contact.
116      *
117      * @return the contact email
118      */
119     public String getEmail( )
120     {
121         return _strEmail;
122     }
123 
124     /**
125      * Sets the email of the contact to the specified string.
126      *
127      * @param strEmail
128      *            the new email
129      */
130     public void setEmail( String strEmail )
131     {
132         _strEmail = ( strEmail == null ) ? EMPTY_STRING : strEmail;
133     }
134 
135     /**
136      * Returns the contact order of this contact.
137      *
138      * @return the contact order
139      */
140     public int getContactOrder( )
141     {
142         return _nContactOrder;
143     }
144 
145     /**
146      * Sets the contact order of the contact to the specified integer.
147      *
148      * @param nContactOrder
149      *            the new contact order
150      */
151     public void setContactOrder( int nContactOrder )
152     {
153         _nContactOrder = nContactOrder;
154     }
155 
156     /**
157      * Returns the workgroup
158      * 
159      * @return The workgroup
160      */
161     public String getWorkgroup( )
162     {
163         return _strAdminWorkgroup;
164     }
165 
166     /**
167      * Sets the workgroup
168      * 
169      * @param strAdminWorkgroup
170      *            The workgroup
171      */
172     public void setWorkgroup( String strAdminWorkgroup )
173     {
174         _strAdminWorkgroup = AdminWorkgroupService.normalizeWorkgroupKey( strAdminWorkgroup );
175     }
176 
177     /**
178      * gets the number of messages send to the contact
179      * 
180      * @return number of hists
181      */
182     public int getHits( )
183     {
184         return _nHits;
185     }
186 
187     /**
188      * Sets the number of messages send to the contact
189      * 
190      * @param nHits
191      *            the number of hits
192      */
193     public void setHits( int nHits )
194     {
195         _nHits = nHits;
196     }
197 }