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