1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.EmailAddress;
30  import com.liferay.portal.model.EmailAddressSoap;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="EmailAddressModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>EmailAddress</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.service.model.EmailAddress
59   * @see com.liferay.portal.service.model.EmailAddressModel
60   * @see com.liferay.portal.service.model.impl.EmailAddressImpl
61   *
62   */
63  public class EmailAddressModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "EmailAddress";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "emailAddressId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "userId", new Integer(Types.BIGINT) },
73              
74  
75              { "userName", new Integer(Types.VARCHAR) },
76              
77  
78              { "createDate", new Integer(Types.TIMESTAMP) },
79              
80  
81              { "modifiedDate", new Integer(Types.TIMESTAMP) },
82              
83  
84              { "classNameId", new Integer(Types.BIGINT) },
85              
86  
87              { "classPK", new Integer(Types.BIGINT) },
88              
89  
90              { "address", new Integer(Types.VARCHAR) },
91              
92  
93              { "typeId", new Integer(Types.INTEGER) },
94              
95  
96              { "primary_", new Integer(Types.BOOLEAN) }
97          };
98      public static final String TABLE_SQL_CREATE = "create table EmailAddress (emailAddressId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,address VARCHAR(75) null,typeId INTEGER,primary_ BOOLEAN)";
99      public static final String TABLE_SQL_DROP = "drop table EmailAddress";
100     public static final String DATA_SOURCE = "liferayDataSource";
101     public static final String SESSION_FACTORY = "liferaySessionFactory";
102     public static final String TX_MANAGER = "liferayTransactionManager";
103     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
104                 "value.object.finder.cache.enabled.com.liferay.portal.model.EmailAddress"),
105             true);
106 
107     public static EmailAddress toModel(EmailAddressSoap soapModel) {
108         EmailAddress model = new EmailAddressImpl();
109 
110         model.setEmailAddressId(soapModel.getEmailAddressId());
111         model.setCompanyId(soapModel.getCompanyId());
112         model.setUserId(soapModel.getUserId());
113         model.setUserName(soapModel.getUserName());
114         model.setCreateDate(soapModel.getCreateDate());
115         model.setModifiedDate(soapModel.getModifiedDate());
116         model.setClassNameId(soapModel.getClassNameId());
117         model.setClassPK(soapModel.getClassPK());
118         model.setAddress(soapModel.getAddress());
119         model.setTypeId(soapModel.getTypeId());
120         model.setPrimary(soapModel.getPrimary());
121 
122         return model;
123     }
124 
125     public static List<EmailAddress> toModels(EmailAddressSoap[] soapModels) {
126         List<EmailAddress> models = new ArrayList<EmailAddress>(soapModels.length);
127 
128         for (EmailAddressSoap soapModel : soapModels) {
129             models.add(toModel(soapModel));
130         }
131 
132         return models;
133     }
134 
135     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
136                 "lock.expiration.time.com.liferay.portal.model.EmailAddress"));
137 
138     public EmailAddressModelImpl() {
139     }
140 
141     public long getPrimaryKey() {
142         return _emailAddressId;
143     }
144 
145     public void setPrimaryKey(long pk) {
146         setEmailAddressId(pk);
147     }
148 
149     public Serializable getPrimaryKeyObj() {
150         return new Long(_emailAddressId);
151     }
152 
153     public long getEmailAddressId() {
154         return _emailAddressId;
155     }
156 
157     public void setEmailAddressId(long emailAddressId) {
158         if (emailAddressId != _emailAddressId) {
159             _emailAddressId = emailAddressId;
160         }
161     }
162 
163     public long getCompanyId() {
164         return _companyId;
165     }
166 
167     public void setCompanyId(long companyId) {
168         if (companyId != _companyId) {
169             _companyId = companyId;
170         }
171     }
172 
173     public long getUserId() {
174         return _userId;
175     }
176 
177     public void setUserId(long userId) {
178         if (userId != _userId) {
179             _userId = userId;
180         }
181     }
182 
183     public String getUserName() {
184         return GetterUtil.getString(_userName);
185     }
186 
187     public void setUserName(String userName) {
188         if (((userName == null) && (_userName != null)) ||
189                 ((userName != null) && (_userName == null)) ||
190                 ((userName != null) && (_userName != null) &&
191                 !userName.equals(_userName))) {
192             _userName = userName;
193         }
194     }
195 
196     public Date getCreateDate() {
197         return _createDate;
198     }
199 
200     public void setCreateDate(Date createDate) {
201         if (((createDate == null) && (_createDate != null)) ||
202                 ((createDate != null) && (_createDate == null)) ||
203                 ((createDate != null) && (_createDate != null) &&
204                 !createDate.equals(_createDate))) {
205             _createDate = createDate;
206         }
207     }
208 
209     public Date getModifiedDate() {
210         return _modifiedDate;
211     }
212 
213     public void setModifiedDate(Date modifiedDate) {
214         if (((modifiedDate == null) && (_modifiedDate != null)) ||
215                 ((modifiedDate != null) && (_modifiedDate == null)) ||
216                 ((modifiedDate != null) && (_modifiedDate != null) &&
217                 !modifiedDate.equals(_modifiedDate))) {
218             _modifiedDate = modifiedDate;
219         }
220     }
221 
222     public String getClassName() {
223         return PortalUtil.getClassName(getClassNameId());
224     }
225 
226     public long getClassNameId() {
227         return _classNameId;
228     }
229 
230     public void setClassNameId(long classNameId) {
231         if (classNameId != _classNameId) {
232             _classNameId = classNameId;
233         }
234     }
235 
236     public long getClassPK() {
237         return _classPK;
238     }
239 
240     public void setClassPK(long classPK) {
241         if (classPK != _classPK) {
242             _classPK = classPK;
243         }
244     }
245 
246     public String getAddress() {
247         return GetterUtil.getString(_address);
248     }
249 
250     public void setAddress(String address) {
251         if (((address == null) && (_address != null)) ||
252                 ((address != null) && (_address == null)) ||
253                 ((address != null) && (_address != null) &&
254                 !address.equals(_address))) {
255             _address = address;
256         }
257     }
258 
259     public int getTypeId() {
260         return _typeId;
261     }
262 
263     public void setTypeId(int typeId) {
264         if (typeId != _typeId) {
265             _typeId = typeId;
266         }
267     }
268 
269     public boolean getPrimary() {
270         return _primary;
271     }
272 
273     public boolean isPrimary() {
274         return _primary;
275     }
276 
277     public void setPrimary(boolean primary) {
278         if (primary != _primary) {
279             _primary = primary;
280         }
281     }
282 
283     public EmailAddress toEscapedModel() {
284         if (isEscapedModel()) {
285             return (EmailAddress)this;
286         }
287         else {
288             EmailAddress model = new EmailAddressImpl();
289 
290             model.setEscapedModel(true);
291 
292             model.setEmailAddressId(getEmailAddressId());
293             model.setCompanyId(getCompanyId());
294             model.setUserId(getUserId());
295             model.setUserName(HtmlUtil.escape(getUserName()));
296             model.setCreateDate(getCreateDate());
297             model.setModifiedDate(getModifiedDate());
298             model.setClassNameId(getClassNameId());
299             model.setClassPK(getClassPK());
300             model.setAddress(HtmlUtil.escape(getAddress()));
301             model.setTypeId(getTypeId());
302             model.setPrimary(getPrimary());
303 
304             model = (EmailAddress)Proxy.newProxyInstance(EmailAddress.class.getClassLoader(),
305                     new Class[] { EmailAddress.class },
306                     new ReadOnlyBeanHandler(model));
307 
308             return model;
309         }
310     }
311 
312     public Object clone() {
313         EmailAddressImpl clone = new EmailAddressImpl();
314 
315         clone.setEmailAddressId(getEmailAddressId());
316         clone.setCompanyId(getCompanyId());
317         clone.setUserId(getUserId());
318         clone.setUserName(getUserName());
319         clone.setCreateDate(getCreateDate());
320         clone.setModifiedDate(getModifiedDate());
321         clone.setClassNameId(getClassNameId());
322         clone.setClassPK(getClassPK());
323         clone.setAddress(getAddress());
324         clone.setTypeId(getTypeId());
325         clone.setPrimary(getPrimary());
326 
327         return clone;
328     }
329 
330     public int compareTo(Object obj) {
331         if (obj == null) {
332             return -1;
333         }
334 
335         EmailAddressImpl emailAddress = (EmailAddressImpl)obj;
336 
337         int value = 0;
338 
339         value = DateUtil.compareTo(getCreateDate(), emailAddress.getCreateDate());
340 
341         if (value != 0) {
342             return value;
343         }
344 
345         return 0;
346     }
347 
348     public boolean equals(Object obj) {
349         if (obj == null) {
350             return false;
351         }
352 
353         EmailAddressImpl emailAddress = null;
354 
355         try {
356             emailAddress = (EmailAddressImpl)obj;
357         }
358         catch (ClassCastException cce) {
359             return false;
360         }
361 
362         long pk = emailAddress.getPrimaryKey();
363 
364         if (getPrimaryKey() == pk) {
365             return true;
366         }
367         else {
368             return false;
369         }
370     }
371 
372     public int hashCode() {
373         return (int)getPrimaryKey();
374     }
375 
376     private long _emailAddressId;
377     private long _companyId;
378     private long _userId;
379     private String _userName;
380     private Date _createDate;
381     private Date _modifiedDate;
382     private long _classNameId;
383     private long _classPK;
384     private String _address;
385     private int _typeId;
386     private boolean _primary;
387 }