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