001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.model.EmailAddress;
024    import com.liferay.portal.model.EmailAddressModel;
025    import com.liferay.portal.model.EmailAddressSoap;
026    import com.liferay.portal.service.ServiceContext;
027    import com.liferay.portal.util.PortalUtil;
028    
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the EmailAddress service. Represents a row in the "EmailAddress" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portal.model.EmailAddressModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link EmailAddressImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a email address model instance should use the {@link com.liferay.portal.model.EmailAddress} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see EmailAddressImpl
055     * @see com.liferay.portal.model.EmailAddress
056     * @see com.liferay.portal.model.EmailAddressModel
057     * @generated
058     */
059    public class EmailAddressModelImpl extends BaseModelImpl<EmailAddress>
060            implements EmailAddressModel {
061            public static final String TABLE_NAME = "EmailAddress";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "emailAddressId", new Integer(Types.BIGINT) },
064                            { "companyId", new Integer(Types.BIGINT) },
065                            { "userId", new Integer(Types.BIGINT) },
066                            { "userName", new Integer(Types.VARCHAR) },
067                            { "createDate", new Integer(Types.TIMESTAMP) },
068                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
069                            { "classNameId", new Integer(Types.BIGINT) },
070                            { "classPK", new Integer(Types.BIGINT) },
071                            { "address", new Integer(Types.VARCHAR) },
072                            { "typeId", new Integer(Types.INTEGER) },
073                            { "primary_", new Integer(Types.BOOLEAN) }
074                    };
075            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)";
076            public static final String TABLE_SQL_DROP = "drop table EmailAddress";
077            public static final String ORDER_BY_JPQL = " ORDER BY emailAddress.createDate ASC";
078            public static final String ORDER_BY_SQL = " ORDER BY EmailAddress.createDate ASC";
079            public static final String DATA_SOURCE = "liferayDataSource";
080            public static final String SESSION_FACTORY = "liferaySessionFactory";
081            public static final String TX_MANAGER = "liferayTransactionManager";
082            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.entity.cache.enabled.com.liferay.portal.model.EmailAddress"),
084                            true);
085            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.finder.cache.enabled.com.liferay.portal.model.EmailAddress"),
087                            true);
088    
089            /**
090             * Converts the soap model instance into a normal model instance.
091             *
092             * @param soapModel the soap model instance to convert
093             * @return the normal model instance
094             */
095            public static EmailAddress toModel(EmailAddressSoap soapModel) {
096                    EmailAddress model = new EmailAddressImpl();
097    
098                    model.setEmailAddressId(soapModel.getEmailAddressId());
099                    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            /**
114             * Converts the soap model instances into normal model instances.
115             *
116             * @param soapModels the soap model instances to convert
117             * @return the normal model instances
118             */
119            public static List<EmailAddress> toModels(EmailAddressSoap[] soapModels) {
120                    List<EmailAddress> models = new ArrayList<EmailAddress>(soapModels.length);
121    
122                    for (EmailAddressSoap soapModel : soapModels) {
123                            models.add(toModel(soapModel));
124                    }
125    
126                    return models;
127            }
128    
129            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
130                                    "lock.expiration.time.com.liferay.portal.model.EmailAddress"));
131    
132            public EmailAddressModelImpl() {
133            }
134    
135            public long getPrimaryKey() {
136                    return _emailAddressId;
137            }
138    
139            public void setPrimaryKey(long pk) {
140                    setEmailAddressId(pk);
141            }
142    
143            public Serializable getPrimaryKeyObj() {
144                    return new Long(_emailAddressId);
145            }
146    
147            public long getEmailAddressId() {
148                    return _emailAddressId;
149            }
150    
151            public void setEmailAddressId(long emailAddressId) {
152                    _emailAddressId = emailAddressId;
153            }
154    
155            public long getCompanyId() {
156                    return _companyId;
157            }
158    
159            public void setCompanyId(long companyId) {
160                    _companyId = companyId;
161            }
162    
163            public long getUserId() {
164                    return _userId;
165            }
166    
167            public void setUserId(long userId) {
168                    _userId = userId;
169            }
170    
171            public String getUserUuid() throws SystemException {
172                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
173            }
174    
175            public void setUserUuid(String userUuid) {
176                    _userUuid = userUuid;
177            }
178    
179            public String getUserName() {
180                    if (_userName == null) {
181                            return StringPool.BLANK;
182                    }
183                    else {
184                            return _userName;
185                    }
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                    if (_address == null) {
234                            return StringPool.BLANK;
235                    }
236                    else {
237                            return _address;
238                    }
239            }
240    
241            public void setAddress(String address) {
242                    _address = address;
243            }
244    
245            public int getTypeId() {
246                    return _typeId;
247            }
248    
249            public void setTypeId(int typeId) {
250                    _typeId = typeId;
251            }
252    
253            public boolean getPrimary() {
254                    return _primary;
255            }
256    
257            public boolean isPrimary() {
258                    return _primary;
259            }
260    
261            public void setPrimary(boolean primary) {
262                    _primary = primary;
263            }
264    
265            public EmailAddress toEscapedModel() {
266                    if (isEscapedModel()) {
267                            return (EmailAddress)this;
268                    }
269                    else {
270                            return (EmailAddress)Proxy.newProxyInstance(EmailAddress.class.getClassLoader(),
271                                    new Class[] { EmailAddress.class },
272                                    new AutoEscapeBeanHandler(this));
273                    }
274            }
275    
276            public ExpandoBridge getExpandoBridge() {
277                    if (_expandoBridge == null) {
278                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
279                                            EmailAddress.class.getName(), getPrimaryKey());
280                    }
281    
282                    return _expandoBridge;
283            }
284    
285            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
286                    getExpandoBridge().setAttributes(serviceContext);
287            }
288    
289            public Object clone() {
290                    EmailAddressImpl emailAddressImpl = new EmailAddressImpl();
291    
292                    emailAddressImpl.setEmailAddressId(getEmailAddressId());
293    
294                    emailAddressImpl.setCompanyId(getCompanyId());
295    
296                    emailAddressImpl.setUserId(getUserId());
297    
298                    emailAddressImpl.setUserName(getUserName());
299    
300                    emailAddressImpl.setCreateDate(getCreateDate());
301    
302                    emailAddressImpl.setModifiedDate(getModifiedDate());
303    
304                    emailAddressImpl.setClassNameId(getClassNameId());
305    
306                    emailAddressImpl.setClassPK(getClassPK());
307    
308                    emailAddressImpl.setAddress(getAddress());
309    
310                    emailAddressImpl.setTypeId(getTypeId());
311    
312                    emailAddressImpl.setPrimary(getPrimary());
313    
314                    return emailAddressImpl;
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                    StringBundler sb = new StringBundler(23);
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                    StringBundler sb = new StringBundler(37);
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 _userUuid;
448            private String _userName;
449            private Date _createDate;
450            private Date _modifiedDate;
451            private long _classNameId;
452            private long _classPK;
453            private String _address;
454            private int _typeId;
455            private boolean _primary;
456            private transient ExpandoBridge _expandoBridge;
457    }