1   /**
2    * Copyright (c) 2000-2009 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.kernel.util.StringPool;
30  import com.liferay.portal.model.EmailAddress;
31  import com.liferay.portal.model.EmailAddressSoap;
32  import com.liferay.portal.util.PortalUtil;
33  
34  import com.liferay.portlet.expando.model.ExpandoBridge;
35  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
36  
37  import java.io.Serializable;
38  
39  import java.lang.reflect.Proxy;
40  
41  import java.sql.Types;
42  
43  import java.util.ArrayList;
44  import java.util.Date;
45  import java.util.List;
46  
47  /**
48   * <a href="EmailAddressModelImpl.java.html"><b><i>View Source</i></b></a>
49   *
50   * <p>
51   * ServiceBuilder generated this class. Modifications in this class will be
52   * overwritten the next time is generated.
53   * </p>
54   *
55   * <p>
56   * This class is a model that represents the <code>EmailAddress</code> table
57   * in the database.
58   * </p>
59   *
60   * @author Brian Wing Shun Chan
61   *
62   * @see com.liferay.portal.model.EmailAddress
63   * @see com.liferay.portal.model.EmailAddressModel
64   * @see com.liferay.portal.model.impl.EmailAddressImpl
65   *
66   */
67  public class EmailAddressModelImpl extends BaseModelImpl {
68      public static final String TABLE_NAME = "EmailAddress";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "emailAddressId", new Integer(Types.BIGINT) },
71              
72  
73              { "companyId", new Integer(Types.BIGINT) },
74              
75  
76              { "userId", new Integer(Types.BIGINT) },
77              
78  
79              { "userName", new Integer(Types.VARCHAR) },
80              
81  
82              { "createDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "modifiedDate", new Integer(Types.TIMESTAMP) },
86              
87  
88              { "classNameId", new Integer(Types.BIGINT) },
89              
90  
91              { "classPK", new Integer(Types.BIGINT) },
92              
93  
94              { "address", new Integer(Types.VARCHAR) },
95              
96  
97              { "typeId", new Integer(Types.INTEGER) },
98              
99  
100             { "primary_", new Integer(Types.BOOLEAN) }
101         };
102     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)";
103     public static final String TABLE_SQL_DROP = "drop table EmailAddress";
104     public static final String DATA_SOURCE = "liferayDataSource";
105     public static final String SESSION_FACTORY = "liferaySessionFactory";
106     public static final String TX_MANAGER = "liferayTransactionManager";
107     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
108                 "value.object.finder.cache.enabled.com.liferay.portal.model.EmailAddress"),
109             true);
110 
111     public static EmailAddress toModel(EmailAddressSoap soapModel) {
112         EmailAddress model = new EmailAddressImpl();
113 
114         model.setEmailAddressId(soapModel.getEmailAddressId());
115         model.setCompanyId(soapModel.getCompanyId());
116         model.setUserId(soapModel.getUserId());
117         model.setUserName(soapModel.getUserName());
118         model.setCreateDate(soapModel.getCreateDate());
119         model.setModifiedDate(soapModel.getModifiedDate());
120         model.setClassNameId(soapModel.getClassNameId());
121         model.setClassPK(soapModel.getClassPK());
122         model.setAddress(soapModel.getAddress());
123         model.setTypeId(soapModel.getTypeId());
124         model.setPrimary(soapModel.getPrimary());
125 
126         return model;
127     }
128 
129     public static List<EmailAddress> toModels(EmailAddressSoap[] soapModels) {
130         List<EmailAddress> models = new ArrayList<EmailAddress>(soapModels.length);
131 
132         for (EmailAddressSoap soapModel : soapModels) {
133             models.add(toModel(soapModel));
134         }
135 
136         return models;
137     }
138 
139     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
140                 "lock.expiration.time.com.liferay.portal.model.EmailAddress"));
141 
142     public EmailAddressModelImpl() {
143     }
144 
145     public long getPrimaryKey() {
146         return _emailAddressId;
147     }
148 
149     public void setPrimaryKey(long pk) {
150         setEmailAddressId(pk);
151     }
152 
153     public Serializable getPrimaryKeyObj() {
154         return new Long(_emailAddressId);
155     }
156 
157     public long getEmailAddressId() {
158         return _emailAddressId;
159     }
160 
161     public void setEmailAddressId(long emailAddressId) {
162         if (emailAddressId != _emailAddressId) {
163             _emailAddressId = emailAddressId;
164         }
165     }
166 
167     public long getCompanyId() {
168         return _companyId;
169     }
170 
171     public void setCompanyId(long companyId) {
172         if (companyId != _companyId) {
173             _companyId = companyId;
174         }
175     }
176 
177     public long getUserId() {
178         return _userId;
179     }
180 
181     public void setUserId(long userId) {
182         if (userId != _userId) {
183             _userId = userId;
184         }
185     }
186 
187     public String getUserName() {
188         return GetterUtil.getString(_userName);
189     }
190 
191     public void setUserName(String userName) {
192         if (((userName == null) && (_userName != null)) ||
193                 ((userName != null) && (_userName == null)) ||
194                 ((userName != null) && (_userName != null) &&
195                 !userName.equals(_userName))) {
196             _userName = userName;
197         }
198     }
199 
200     public Date getCreateDate() {
201         return _createDate;
202     }
203 
204     public void setCreateDate(Date createDate) {
205         if (((createDate == null) && (_createDate != null)) ||
206                 ((createDate != null) && (_createDate == null)) ||
207                 ((createDate != null) && (_createDate != null) &&
208                 !createDate.equals(_createDate))) {
209             _createDate = createDate;
210         }
211     }
212 
213     public Date getModifiedDate() {
214         return _modifiedDate;
215     }
216 
217     public void setModifiedDate(Date modifiedDate) {
218         if (((modifiedDate == null) && (_modifiedDate != null)) ||
219                 ((modifiedDate != null) && (_modifiedDate == null)) ||
220                 ((modifiedDate != null) && (_modifiedDate != null) &&
221                 !modifiedDate.equals(_modifiedDate))) {
222             _modifiedDate = modifiedDate;
223         }
224     }
225 
226     public String getClassName() {
227         if (getClassNameId() <= 0) {
228             return StringPool.BLANK;
229         }
230 
231         return PortalUtil.getClassName(getClassNameId());
232     }
233 
234     public long getClassNameId() {
235         return _classNameId;
236     }
237 
238     public void setClassNameId(long classNameId) {
239         if (classNameId != _classNameId) {
240             _classNameId = classNameId;
241         }
242     }
243 
244     public long getClassPK() {
245         return _classPK;
246     }
247 
248     public void setClassPK(long classPK) {
249         if (classPK != _classPK) {
250             _classPK = classPK;
251         }
252     }
253 
254     public String getAddress() {
255         return GetterUtil.getString(_address);
256     }
257 
258     public void setAddress(String address) {
259         if (((address == null) && (_address != null)) ||
260                 ((address != null) && (_address == null)) ||
261                 ((address != null) && (_address != null) &&
262                 !address.equals(_address))) {
263             _address = address;
264         }
265     }
266 
267     public int getTypeId() {
268         return _typeId;
269     }
270 
271     public void setTypeId(int typeId) {
272         if (typeId != _typeId) {
273             _typeId = typeId;
274         }
275     }
276 
277     public boolean getPrimary() {
278         return _primary;
279     }
280 
281     public boolean isPrimary() {
282         return _primary;
283     }
284 
285     public void setPrimary(boolean primary) {
286         if (primary != _primary) {
287             _primary = primary;
288         }
289     }
290 
291     public EmailAddress toEscapedModel() {
292         if (isEscapedModel()) {
293             return (EmailAddress)this;
294         }
295         else {
296             EmailAddress model = new EmailAddressImpl();
297 
298             model.setNew(isNew());
299             model.setEscapedModel(true);
300 
301             model.setEmailAddressId(getEmailAddressId());
302             model.setCompanyId(getCompanyId());
303             model.setUserId(getUserId());
304             model.setUserName(HtmlUtil.escape(getUserName()));
305             model.setCreateDate(getCreateDate());
306             model.setModifiedDate(getModifiedDate());
307             model.setClassNameId(getClassNameId());
308             model.setClassPK(getClassPK());
309             model.setAddress(HtmlUtil.escape(getAddress()));
310             model.setTypeId(getTypeId());
311             model.setPrimary(getPrimary());
312 
313             model = (EmailAddress)Proxy.newProxyInstance(EmailAddress.class.getClassLoader(),
314                     new Class[] { EmailAddress.class },
315                     new ReadOnlyBeanHandler(model));
316 
317             return model;
318         }
319     }
320 
321     public ExpandoBridge getExpandoBridge() {
322         if (_expandoBridge == null) {
323             _expandoBridge = new ExpandoBridgeImpl(EmailAddress.class.getName(),
324                     getPrimaryKey());
325         }
326 
327         return _expandoBridge;
328     }
329 
330     public Object clone() {
331         EmailAddressImpl clone = new EmailAddressImpl();
332 
333         clone.setEmailAddressId(getEmailAddressId());
334         clone.setCompanyId(getCompanyId());
335         clone.setUserId(getUserId());
336         clone.setUserName(getUserName());
337         clone.setCreateDate(getCreateDate());
338         clone.setModifiedDate(getModifiedDate());
339         clone.setClassNameId(getClassNameId());
340         clone.setClassPK(getClassPK());
341         clone.setAddress(getAddress());
342         clone.setTypeId(getTypeId());
343         clone.setPrimary(getPrimary());
344 
345         return clone;
346     }
347 
348     public int compareTo(Object obj) {
349         if (obj == null) {
350             return -1;
351         }
352 
353         EmailAddressImpl emailAddress = (EmailAddressImpl)obj;
354 
355         int value = 0;
356 
357         value = DateUtil.compareTo(getCreateDate(), emailAddress.getCreateDate());
358 
359         if (value != 0) {
360             return value;
361         }
362 
363         return 0;
364     }
365 
366     public boolean equals(Object obj) {
367         if (obj == null) {
368             return false;
369         }
370 
371         EmailAddressImpl emailAddress = null;
372 
373         try {
374             emailAddress = (EmailAddressImpl)obj;
375         }
376         catch (ClassCastException cce) {
377             return false;
378         }
379 
380         long pk = emailAddress.getPrimaryKey();
381 
382         if (getPrimaryKey() == pk) {
383             return true;
384         }
385         else {
386             return false;
387         }
388     }
389 
390     public int hashCode() {
391         return (int)getPrimaryKey();
392     }
393 
394     private long _emailAddressId;
395     private long _companyId;
396     private long _userId;
397     private String _userName;
398     private Date _createDate;
399     private Date _modifiedDate;
400     private long _classNameId;
401     private long _classPK;
402     private String _address;
403     private int _typeId;
404     private boolean _primary;
405     private transient ExpandoBridge _expandoBridge;
406 }