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<EmailAddress> {
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
108                 "value.object.entity.cache.enabled.com.liferay.portal.model.EmailAddress"),
109             true);
110     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
111                 "value.object.finder.cache.enabled.com.liferay.portal.model.EmailAddress"),
112             true);
113 
114     public static EmailAddress toModel(EmailAddressSoap soapModel) {
115         EmailAddress model = new EmailAddressImpl();
116 
117         model.setEmailAddressId(soapModel.getEmailAddressId());
118         model.setCompanyId(soapModel.getCompanyId());
119         model.setUserId(soapModel.getUserId());
120         model.setUserName(soapModel.getUserName());
121         model.setCreateDate(soapModel.getCreateDate());
122         model.setModifiedDate(soapModel.getModifiedDate());
123         model.setClassNameId(soapModel.getClassNameId());
124         model.setClassPK(soapModel.getClassPK());
125         model.setAddress(soapModel.getAddress());
126         model.setTypeId(soapModel.getTypeId());
127         model.setPrimary(soapModel.getPrimary());
128 
129         return model;
130     }
131 
132     public static List<EmailAddress> toModels(EmailAddressSoap[] soapModels) {
133         List<EmailAddress> models = new ArrayList<EmailAddress>(soapModels.length);
134 
135         for (EmailAddressSoap soapModel : soapModels) {
136             models.add(toModel(soapModel));
137         }
138 
139         return models;
140     }
141 
142     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
143                 "lock.expiration.time.com.liferay.portal.model.EmailAddress"));
144 
145     public EmailAddressModelImpl() {
146     }
147 
148     public long getPrimaryKey() {
149         return _emailAddressId;
150     }
151 
152     public void setPrimaryKey(long pk) {
153         setEmailAddressId(pk);
154     }
155 
156     public Serializable getPrimaryKeyObj() {
157         return new Long(_emailAddressId);
158     }
159 
160     public long getEmailAddressId() {
161         return _emailAddressId;
162     }
163 
164     public void setEmailAddressId(long emailAddressId) {
165         _emailAddressId = emailAddressId;
166     }
167 
168     public long getCompanyId() {
169         return _companyId;
170     }
171 
172     public void setCompanyId(long companyId) {
173         _companyId = companyId;
174     }
175 
176     public long getUserId() {
177         return _userId;
178     }
179 
180     public void setUserId(long userId) {
181         _userId = userId;
182     }
183 
184     public String getUserName() {
185         return GetterUtil.getString(_userName);
186     }
187 
188     public void setUserName(String userName) {
189         _userName = userName;
190     }
191 
192     public Date getCreateDate() {
193         return _createDate;
194     }
195 
196     public void setCreateDate(Date createDate) {
197         _createDate = createDate;
198     }
199 
200     public Date getModifiedDate() {
201         return _modifiedDate;
202     }
203 
204     public void setModifiedDate(Date modifiedDate) {
205         _modifiedDate = modifiedDate;
206     }
207 
208     public String getClassName() {
209         if (getClassNameId() <= 0) {
210             return StringPool.BLANK;
211         }
212 
213         return PortalUtil.getClassName(getClassNameId());
214     }
215 
216     public long getClassNameId() {
217         return _classNameId;
218     }
219 
220     public void setClassNameId(long classNameId) {
221         _classNameId = classNameId;
222     }
223 
224     public long getClassPK() {
225         return _classPK;
226     }
227 
228     public void setClassPK(long classPK) {
229         _classPK = classPK;
230     }
231 
232     public String getAddress() {
233         return GetterUtil.getString(_address);
234     }
235 
236     public void setAddress(String address) {
237         _address = address;
238     }
239 
240     public int getTypeId() {
241         return _typeId;
242     }
243 
244     public void setTypeId(int typeId) {
245         _typeId = typeId;
246     }
247 
248     public boolean getPrimary() {
249         return _primary;
250     }
251 
252     public boolean isPrimary() {
253         return _primary;
254     }
255 
256     public void setPrimary(boolean primary) {
257         _primary = primary;
258     }
259 
260     public EmailAddress toEscapedModel() {
261         if (isEscapedModel()) {
262             return (EmailAddress)this;
263         }
264         else {
265             EmailAddress model = new EmailAddressImpl();
266 
267             model.setNew(isNew());
268             model.setEscapedModel(true);
269 
270             model.setEmailAddressId(getEmailAddressId());
271             model.setCompanyId(getCompanyId());
272             model.setUserId(getUserId());
273             model.setUserName(HtmlUtil.escape(getUserName()));
274             model.setCreateDate(getCreateDate());
275             model.setModifiedDate(getModifiedDate());
276             model.setClassNameId(getClassNameId());
277             model.setClassPK(getClassPK());
278             model.setAddress(HtmlUtil.escape(getAddress()));
279             model.setTypeId(getTypeId());
280             model.setPrimary(getPrimary());
281 
282             model = (EmailAddress)Proxy.newProxyInstance(EmailAddress.class.getClassLoader(),
283                     new Class[] { EmailAddress.class },
284                     new ReadOnlyBeanHandler(model));
285 
286             return model;
287         }
288     }
289 
290     public ExpandoBridge getExpandoBridge() {
291         if (_expandoBridge == null) {
292             _expandoBridge = new ExpandoBridgeImpl(EmailAddress.class.getName(),
293                     getPrimaryKey());
294         }
295 
296         return _expandoBridge;
297     }
298 
299     public Object clone() {
300         EmailAddressImpl clone = new EmailAddressImpl();
301 
302         clone.setEmailAddressId(getEmailAddressId());
303         clone.setCompanyId(getCompanyId());
304         clone.setUserId(getUserId());
305         clone.setUserName(getUserName());
306         clone.setCreateDate(getCreateDate());
307         clone.setModifiedDate(getModifiedDate());
308         clone.setClassNameId(getClassNameId());
309         clone.setClassPK(getClassPK());
310         clone.setAddress(getAddress());
311         clone.setTypeId(getTypeId());
312         clone.setPrimary(getPrimary());
313 
314         return clone;
315     }
316 
317     public int compareTo(EmailAddress emailAddress) {
318         int value = 0;
319 
320         value = DateUtil.compareTo(getCreateDate(), emailAddress.getCreateDate());
321 
322         if (value != 0) {
323             return value;
324         }
325 
326         return 0;
327     }
328 
329     public boolean equals(Object obj) {
330         if (obj == null) {
331             return false;
332         }
333 
334         EmailAddress emailAddress = null;
335 
336         try {
337             emailAddress = (EmailAddress)obj;
338         }
339         catch (ClassCastException cce) {
340             return false;
341         }
342 
343         long pk = emailAddress.getPrimaryKey();
344 
345         if (getPrimaryKey() == pk) {
346             return true;
347         }
348         else {
349             return false;
350         }
351     }
352 
353     public int hashCode() {
354         return (int)getPrimaryKey();
355     }
356 
357     public String toString() {
358         StringBuilder sb = new StringBuilder();
359 
360         sb.append("{emailAddressId=");
361         sb.append(getEmailAddressId());
362         sb.append(", companyId=");
363         sb.append(getCompanyId());
364         sb.append(", userId=");
365         sb.append(getUserId());
366         sb.append(", userName=");
367         sb.append(getUserName());
368         sb.append(", createDate=");
369         sb.append(getCreateDate());
370         sb.append(", modifiedDate=");
371         sb.append(getModifiedDate());
372         sb.append(", classNameId=");
373         sb.append(getClassNameId());
374         sb.append(", classPK=");
375         sb.append(getClassPK());
376         sb.append(", address=");
377         sb.append(getAddress());
378         sb.append(", typeId=");
379         sb.append(getTypeId());
380         sb.append(", primary=");
381         sb.append(getPrimary());
382         sb.append("}");
383 
384         return sb.toString();
385     }
386 
387     public String toXmlString() {
388         StringBuilder sb = new StringBuilder();
389 
390         sb.append("<model><model-name>");
391         sb.append("com.liferay.portal.model.EmailAddress");
392         sb.append("</model-name>");
393 
394         sb.append(
395             "<column><column-name>emailAddressId</column-name><column-value><![CDATA[");
396         sb.append(getEmailAddressId());
397         sb.append("]]></column-value></column>");
398         sb.append(
399             "<column><column-name>companyId</column-name><column-value><![CDATA[");
400         sb.append(getCompanyId());
401         sb.append("]]></column-value></column>");
402         sb.append(
403             "<column><column-name>userId</column-name><column-value><![CDATA[");
404         sb.append(getUserId());
405         sb.append("]]></column-value></column>");
406         sb.append(
407             "<column><column-name>userName</column-name><column-value><![CDATA[");
408         sb.append(getUserName());
409         sb.append("]]></column-value></column>");
410         sb.append(
411             "<column><column-name>createDate</column-name><column-value><![CDATA[");
412         sb.append(getCreateDate());
413         sb.append("]]></column-value></column>");
414         sb.append(
415             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
416         sb.append(getModifiedDate());
417         sb.append("]]></column-value></column>");
418         sb.append(
419             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
420         sb.append(getClassNameId());
421         sb.append("]]></column-value></column>");
422         sb.append(
423             "<column><column-name>classPK</column-name><column-value><![CDATA[");
424         sb.append(getClassPK());
425         sb.append("]]></column-value></column>");
426         sb.append(
427             "<column><column-name>address</column-name><column-value><![CDATA[");
428         sb.append(getAddress());
429         sb.append("]]></column-value></column>");
430         sb.append(
431             "<column><column-name>typeId</column-name><column-value><![CDATA[");
432         sb.append(getTypeId());
433         sb.append("]]></column-value></column>");
434         sb.append(
435             "<column><column-name>primary</column-name><column-value><![CDATA[");
436         sb.append(getPrimary());
437         sb.append("]]></column-value></column>");
438 
439         sb.append("</model>");
440 
441         return sb.toString();
442     }
443 
444     private long _emailAddressId;
445     private long _companyId;
446     private long _userId;
447     private String _userName;
448     private Date _createDate;
449     private Date _modifiedDate;
450     private long _classNameId;
451     private long _classPK;
452     private String _address;
453     private int _typeId;
454     private boolean _primary;
455     private transient ExpandoBridge _expandoBridge;
456 }