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.portlet.announcements.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.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
027    import com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel;
028    import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
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.List;
040    
041    /**
042     * The base model implementation for the AnnouncementsDelivery service. Represents a row in the "AnnouncementsDelivery" database table, with each column mapped to a property of this class.
043     *
044     * <p>
045     * This implementation and its corresponding interface {@link com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AnnouncementsDeliveryImpl}.
046     * </p>
047     *
048     * <p>
049     * Never modify or reference this class directly. All methods that expect a announcements delivery model instance should use the {@link com.liferay.portlet.announcements.model.AnnouncementsDelivery} interface instead.
050     * </p>
051     *
052     * @author Brian Wing Shun Chan
053     * @see AnnouncementsDeliveryImpl
054     * @see com.liferay.portlet.announcements.model.AnnouncementsDelivery
055     * @see com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel
056     * @generated
057     */
058    public class AnnouncementsDeliveryModelImpl extends BaseModelImpl<AnnouncementsDelivery>
059            implements AnnouncementsDeliveryModel {
060            public static final String TABLE_NAME = "AnnouncementsDelivery";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "deliveryId", new Integer(Types.BIGINT) },
063                            { "companyId", new Integer(Types.BIGINT) },
064                            { "userId", new Integer(Types.BIGINT) },
065                            { "type_", new Integer(Types.VARCHAR) },
066                            { "email", new Integer(Types.BOOLEAN) },
067                            { "sms", new Integer(Types.BOOLEAN) },
068                            { "website", new Integer(Types.BOOLEAN) }
069                    };
070            public static final String TABLE_SQL_CREATE = "create table AnnouncementsDelivery (deliveryId LONG not null primary key,companyId LONG,userId LONG,type_ VARCHAR(75) null,email BOOLEAN,sms BOOLEAN,website BOOLEAN)";
071            public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
072            public static final String DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
080                            true);
081    
082            /**
083             * Converts the soap model instance into a normal model instance.
084             *
085             * @param soapModel the soap model instance to convert
086             * @return the normal model instance
087             */
088            public static AnnouncementsDelivery toModel(
089                    AnnouncementsDeliverySoap soapModel) {
090                    AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
091    
092                    model.setDeliveryId(soapModel.getDeliveryId());
093                    model.setCompanyId(soapModel.getCompanyId());
094                    model.setUserId(soapModel.getUserId());
095                    model.setType(soapModel.getType());
096                    model.setEmail(soapModel.getEmail());
097                    model.setSms(soapModel.getSms());
098                    model.setWebsite(soapModel.getWebsite());
099    
100                    return model;
101            }
102    
103            /**
104             * Converts the soap model instances into normal model instances.
105             *
106             * @param soapModels the soap model instances to convert
107             * @return the normal model instances
108             */
109            public static List<AnnouncementsDelivery> toModels(
110                    AnnouncementsDeliverySoap[] soapModels) {
111                    List<AnnouncementsDelivery> models = new ArrayList<AnnouncementsDelivery>(soapModels.length);
112    
113                    for (AnnouncementsDeliverySoap soapModel : soapModels) {
114                            models.add(toModel(soapModel));
115                    }
116    
117                    return models;
118            }
119    
120            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
121                                    "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsDelivery"));
122    
123            public AnnouncementsDeliveryModelImpl() {
124            }
125    
126            public long getPrimaryKey() {
127                    return _deliveryId;
128            }
129    
130            public void setPrimaryKey(long pk) {
131                    setDeliveryId(pk);
132            }
133    
134            public Serializable getPrimaryKeyObj() {
135                    return new Long(_deliveryId);
136            }
137    
138            public long getDeliveryId() {
139                    return _deliveryId;
140            }
141    
142            public void setDeliveryId(long deliveryId) {
143                    _deliveryId = deliveryId;
144            }
145    
146            public long getCompanyId() {
147                    return _companyId;
148            }
149    
150            public void setCompanyId(long companyId) {
151                    _companyId = companyId;
152            }
153    
154            public long getUserId() {
155                    return _userId;
156            }
157    
158            public void setUserId(long userId) {
159                    if (!_setOriginalUserId) {
160                            _setOriginalUserId = true;
161    
162                            _originalUserId = _userId;
163                    }
164    
165                    _userId = userId;
166            }
167    
168            public String getUserUuid() throws SystemException {
169                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
170            }
171    
172            public void setUserUuid(String userUuid) {
173                    _userUuid = userUuid;
174            }
175    
176            public long getOriginalUserId() {
177                    return _originalUserId;
178            }
179    
180            public String getType() {
181                    if (_type == null) {
182                            return StringPool.BLANK;
183                    }
184                    else {
185                            return _type;
186                    }
187            }
188    
189            public void setType(String type) {
190                    if (_originalType == null) {
191                            _originalType = _type;
192                    }
193    
194                    _type = type;
195            }
196    
197            public String getOriginalType() {
198                    return GetterUtil.getString(_originalType);
199            }
200    
201            public boolean getEmail() {
202                    return _email;
203            }
204    
205            public boolean isEmail() {
206                    return _email;
207            }
208    
209            public void setEmail(boolean email) {
210                    _email = email;
211            }
212    
213            public boolean getSms() {
214                    return _sms;
215            }
216    
217            public boolean isSms() {
218                    return _sms;
219            }
220    
221            public void setSms(boolean sms) {
222                    _sms = sms;
223            }
224    
225            public boolean getWebsite() {
226                    return _website;
227            }
228    
229            public boolean isWebsite() {
230                    return _website;
231            }
232    
233            public void setWebsite(boolean website) {
234                    _website = website;
235            }
236    
237            public AnnouncementsDelivery toEscapedModel() {
238                    if (isEscapedModel()) {
239                            return (AnnouncementsDelivery)this;
240                    }
241                    else {
242                            return (AnnouncementsDelivery)Proxy.newProxyInstance(AnnouncementsDelivery.class.getClassLoader(),
243                                    new Class[] { AnnouncementsDelivery.class },
244                                    new AutoEscapeBeanHandler(this));
245                    }
246            }
247    
248            public ExpandoBridge getExpandoBridge() {
249                    if (_expandoBridge == null) {
250                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
251                                            AnnouncementsDelivery.class.getName(), getPrimaryKey());
252                    }
253    
254                    return _expandoBridge;
255            }
256    
257            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
258                    getExpandoBridge().setAttributes(serviceContext);
259            }
260    
261            public Object clone() {
262                    AnnouncementsDeliveryImpl announcementsDeliveryImpl = new AnnouncementsDeliveryImpl();
263    
264                    announcementsDeliveryImpl.setDeliveryId(getDeliveryId());
265    
266                    announcementsDeliveryImpl.setCompanyId(getCompanyId());
267    
268                    announcementsDeliveryImpl.setUserId(getUserId());
269    
270                    AnnouncementsDeliveryModelImpl announcementsDeliveryModelImpl = announcementsDeliveryImpl;
271    
272                    announcementsDeliveryModelImpl._originalUserId = announcementsDeliveryModelImpl._userId;
273    
274                    announcementsDeliveryModelImpl._setOriginalUserId = false;
275                    announcementsDeliveryImpl.setType(getType());
276    
277                    announcementsDeliveryModelImpl._originalType = announcementsDeliveryModelImpl._type;
278    
279                    announcementsDeliveryImpl.setEmail(getEmail());
280    
281                    announcementsDeliveryImpl.setSms(getSms());
282    
283                    announcementsDeliveryImpl.setWebsite(getWebsite());
284    
285                    return announcementsDeliveryImpl;
286            }
287    
288            public int compareTo(AnnouncementsDelivery announcementsDelivery) {
289                    long pk = announcementsDelivery.getPrimaryKey();
290    
291                    if (getPrimaryKey() < pk) {
292                            return -1;
293                    }
294                    else if (getPrimaryKey() > pk) {
295                            return 1;
296                    }
297                    else {
298                            return 0;
299                    }
300            }
301    
302            public boolean equals(Object obj) {
303                    if (obj == null) {
304                            return false;
305                    }
306    
307                    AnnouncementsDelivery announcementsDelivery = null;
308    
309                    try {
310                            announcementsDelivery = (AnnouncementsDelivery)obj;
311                    }
312                    catch (ClassCastException cce) {
313                            return false;
314                    }
315    
316                    long pk = announcementsDelivery.getPrimaryKey();
317    
318                    if (getPrimaryKey() == pk) {
319                            return true;
320                    }
321                    else {
322                            return false;
323                    }
324            }
325    
326            public int hashCode() {
327                    return (int)getPrimaryKey();
328            }
329    
330            public String toString() {
331                    StringBundler sb = new StringBundler(15);
332    
333                    sb.append("{deliveryId=");
334                    sb.append(getDeliveryId());
335                    sb.append(", companyId=");
336                    sb.append(getCompanyId());
337                    sb.append(", userId=");
338                    sb.append(getUserId());
339                    sb.append(", type=");
340                    sb.append(getType());
341                    sb.append(", email=");
342                    sb.append(getEmail());
343                    sb.append(", sms=");
344                    sb.append(getSms());
345                    sb.append(", website=");
346                    sb.append(getWebsite());
347                    sb.append("}");
348    
349                    return sb.toString();
350            }
351    
352            public String toXmlString() {
353                    StringBundler sb = new StringBundler(25);
354    
355                    sb.append("<model><model-name>");
356                    sb.append(
357                            "com.liferay.portlet.announcements.model.AnnouncementsDelivery");
358                    sb.append("</model-name>");
359    
360                    sb.append(
361                            "<column><column-name>deliveryId</column-name><column-value><![CDATA[");
362                    sb.append(getDeliveryId());
363                    sb.append("]]></column-value></column>");
364                    sb.append(
365                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
366                    sb.append(getCompanyId());
367                    sb.append("]]></column-value></column>");
368                    sb.append(
369                            "<column><column-name>userId</column-name><column-value><![CDATA[");
370                    sb.append(getUserId());
371                    sb.append("]]></column-value></column>");
372                    sb.append(
373                            "<column><column-name>type</column-name><column-value><![CDATA[");
374                    sb.append(getType());
375                    sb.append("]]></column-value></column>");
376                    sb.append(
377                            "<column><column-name>email</column-name><column-value><![CDATA[");
378                    sb.append(getEmail());
379                    sb.append("]]></column-value></column>");
380                    sb.append(
381                            "<column><column-name>sms</column-name><column-value><![CDATA[");
382                    sb.append(getSms());
383                    sb.append("]]></column-value></column>");
384                    sb.append(
385                            "<column><column-name>website</column-name><column-value><![CDATA[");
386                    sb.append(getWebsite());
387                    sb.append("]]></column-value></column>");
388    
389                    sb.append("</model>");
390    
391                    return sb.toString();
392            }
393    
394            private long _deliveryId;
395            private long _companyId;
396            private long _userId;
397            private String _userUuid;
398            private long _originalUserId;
399            private boolean _setOriginalUserId;
400            private String _type;
401            private String _originalType;
402            private boolean _email;
403            private boolean _sms;
404            private boolean _website;
405            private transient ExpandoBridge _expandoBridge;
406    }