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