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