001    /**
002     * Copyright (c) 2000-2012 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.json.JSON;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.ProxyUtil;
022    import com.liferay.portal.kernel.util.StringBundler;
023    import com.liferay.portal.kernel.util.StringPool;
024    import com.liferay.portal.model.CacheModel;
025    import com.liferay.portal.model.impl.BaseModelImpl;
026    import com.liferay.portal.service.ServiceContext;
027    import com.liferay.portal.util.PortalUtil;
028    
029    import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
030    import com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel;
031    import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
032    import com.liferay.portlet.expando.model.ExpandoBridge;
033    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
034    
035    import java.io.Serializable;
036    
037    import java.sql.Types;
038    
039    import java.util.ArrayList;
040    import java.util.List;
041    
042    /**
043     * 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.
044     *
045     * <p>
046     * 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}.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see AnnouncementsDeliveryImpl
051     * @see com.liferay.portlet.announcements.model.AnnouncementsDelivery
052     * @see com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel
053     * @generated
054     */
055    @JSON(strict = true)
056    public class AnnouncementsDeliveryModelImpl extends BaseModelImpl<AnnouncementsDelivery>
057            implements AnnouncementsDeliveryModel {
058            /*
059             * NOTE FOR DEVELOPERS:
060             *
061             * 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.
062             */
063            public static final String TABLE_NAME = "AnnouncementsDelivery";
064            public static final Object[][] TABLE_COLUMNS = {
065                            { "deliveryId", Types.BIGINT },
066                            { "companyId", Types.BIGINT },
067                            { "userId", Types.BIGINT },
068                            { "type_", Types.VARCHAR },
069                            { "email", Types.BOOLEAN },
070                            { "sms", Types.BOOLEAN },
071                            { "website", Types.BOOLEAN }
072                    };
073            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)";
074            public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
075            public static final String DATA_SOURCE = "liferayDataSource";
076            public static final String SESSION_FACTORY = "liferaySessionFactory";
077            public static final String TX_MANAGER = "liferayTransactionManager";
078            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
080                            true);
081            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
083                            true);
084            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085                                    "value.object.column.bitmask.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
086                            true);
087            public static long TYPE_COLUMN_BITMASK = 1L;
088            public static long USERID_COLUMN_BITMASK = 2L;
089    
090            /**
091             * Converts the soap model instance into a normal model instance.
092             *
093             * @param soapModel the soap model instance to convert
094             * @return the normal model instance
095             */
096            public static AnnouncementsDelivery toModel(
097                    AnnouncementsDeliverySoap soapModel) {
098                    AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
099    
100                    model.setDeliveryId(soapModel.getDeliveryId());
101                    model.setCompanyId(soapModel.getCompanyId());
102                    model.setUserId(soapModel.getUserId());
103                    model.setType(soapModel.getType());
104                    model.setEmail(soapModel.getEmail());
105                    model.setSms(soapModel.getSms());
106                    model.setWebsite(soapModel.getWebsite());
107    
108                    return model;
109            }
110    
111            /**
112             * Converts the soap model instances into normal model instances.
113             *
114             * @param soapModels the soap model instances to convert
115             * @return the normal model instances
116             */
117            public static List<AnnouncementsDelivery> toModels(
118                    AnnouncementsDeliverySoap[] soapModels) {
119                    List<AnnouncementsDelivery> models = new ArrayList<AnnouncementsDelivery>(soapModels.length);
120    
121                    for (AnnouncementsDeliverySoap soapModel : soapModels) {
122                            models.add(toModel(soapModel));
123                    }
124    
125                    return models;
126            }
127    
128            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
129                                    "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsDelivery"));
130    
131            public AnnouncementsDeliveryModelImpl() {
132            }
133    
134            public long getPrimaryKey() {
135                    return _deliveryId;
136            }
137    
138            public void setPrimaryKey(long primaryKey) {
139                    setDeliveryId(primaryKey);
140            }
141    
142            public Serializable getPrimaryKeyObj() {
143                    return new Long(_deliveryId);
144            }
145    
146            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
147                    setPrimaryKey(((Long)primaryKeyObj).longValue());
148            }
149    
150            public Class<?> getModelClass() {
151                    return AnnouncementsDelivery.class;
152            }
153    
154            public String getModelClassName() {
155                    return AnnouncementsDelivery.class.getName();
156            }
157    
158            @JSON
159            public long getDeliveryId() {
160                    return _deliveryId;
161            }
162    
163            public void setDeliveryId(long deliveryId) {
164                    _deliveryId = deliveryId;
165            }
166    
167            @JSON
168            public long getCompanyId() {
169                    return _companyId;
170            }
171    
172            public void setCompanyId(long companyId) {
173                    _companyId = companyId;
174            }
175    
176            @JSON
177            public long getUserId() {
178                    return _userId;
179            }
180    
181            public void setUserId(long userId) {
182                    _columnBitmask |= USERID_COLUMN_BITMASK;
183    
184                    if (!_setOriginalUserId) {
185                            _setOriginalUserId = true;
186    
187                            _originalUserId = _userId;
188                    }
189    
190                    _userId = userId;
191            }
192    
193            public String getUserUuid() throws SystemException {
194                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
195            }
196    
197            public void setUserUuid(String userUuid) {
198                    _userUuid = userUuid;
199            }
200    
201            public long getOriginalUserId() {
202                    return _originalUserId;
203            }
204    
205            @JSON
206            public String getType() {
207                    if (_type == null) {
208                            return StringPool.BLANK;
209                    }
210                    else {
211                            return _type;
212                    }
213            }
214    
215            public void setType(String type) {
216                    _columnBitmask |= TYPE_COLUMN_BITMASK;
217    
218                    if (_originalType == null) {
219                            _originalType = _type;
220                    }
221    
222                    _type = type;
223            }
224    
225            public String getOriginalType() {
226                    return GetterUtil.getString(_originalType);
227            }
228    
229            @JSON
230            public boolean getEmail() {
231                    return _email;
232            }
233    
234            public boolean isEmail() {
235                    return _email;
236            }
237    
238            public void setEmail(boolean email) {
239                    _email = email;
240            }
241    
242            @JSON
243            public boolean getSms() {
244                    return _sms;
245            }
246    
247            public boolean isSms() {
248                    return _sms;
249            }
250    
251            public void setSms(boolean sms) {
252                    _sms = sms;
253            }
254    
255            @JSON
256            public boolean getWebsite() {
257                    return _website;
258            }
259    
260            public boolean isWebsite() {
261                    return _website;
262            }
263    
264            public void setWebsite(boolean website) {
265                    _website = website;
266            }
267    
268            public long getColumnBitmask() {
269                    return _columnBitmask;
270            }
271    
272            @Override
273            public AnnouncementsDelivery toEscapedModel() {
274                    if (_escapedModelProxy == null) {
275                            _escapedModelProxy = (AnnouncementsDelivery)ProxyUtil.newProxyInstance(_classLoader,
276                                            _escapedModelProxyInterfaces,
277                                            new AutoEscapeBeanHandler(this));
278                    }
279    
280                    return _escapedModelProxy;
281            }
282    
283            @Override
284            public ExpandoBridge getExpandoBridge() {
285                    if (_expandoBridge == null) {
286                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
287                                            AnnouncementsDelivery.class.getName(), getPrimaryKey());
288                    }
289    
290                    return _expandoBridge;
291            }
292    
293            @Override
294            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
295                    getExpandoBridge().setAttributes(serviceContext);
296            }
297    
298            @Override
299            public Object clone() {
300                    AnnouncementsDeliveryImpl announcementsDeliveryImpl = new AnnouncementsDeliveryImpl();
301    
302                    announcementsDeliveryImpl.setDeliveryId(getDeliveryId());
303                    announcementsDeliveryImpl.setCompanyId(getCompanyId());
304                    announcementsDeliveryImpl.setUserId(getUserId());
305                    announcementsDeliveryImpl.setType(getType());
306                    announcementsDeliveryImpl.setEmail(getEmail());
307                    announcementsDeliveryImpl.setSms(getSms());
308                    announcementsDeliveryImpl.setWebsite(getWebsite());
309    
310                    announcementsDeliveryImpl.resetOriginalValues();
311    
312                    return announcementsDeliveryImpl;
313            }
314    
315            public int compareTo(AnnouncementsDelivery announcementsDelivery) {
316                    long primaryKey = announcementsDelivery.getPrimaryKey();
317    
318                    if (getPrimaryKey() < primaryKey) {
319                            return -1;
320                    }
321                    else if (getPrimaryKey() > primaryKey) {
322                            return 1;
323                    }
324                    else {
325                            return 0;
326                    }
327            }
328    
329            @Override
330            public boolean equals(Object obj) {
331                    if (obj == null) {
332                            return false;
333                    }
334    
335                    AnnouncementsDelivery announcementsDelivery = null;
336    
337                    try {
338                            announcementsDelivery = (AnnouncementsDelivery)obj;
339                    }
340                    catch (ClassCastException cce) {
341                            return false;
342                    }
343    
344                    long primaryKey = announcementsDelivery.getPrimaryKey();
345    
346                    if (getPrimaryKey() == primaryKey) {
347                            return true;
348                    }
349                    else {
350                            return false;
351                    }
352            }
353    
354            @Override
355            public int hashCode() {
356                    return (int)getPrimaryKey();
357            }
358    
359            @Override
360            public void resetOriginalValues() {
361                    AnnouncementsDeliveryModelImpl announcementsDeliveryModelImpl = this;
362    
363                    announcementsDeliveryModelImpl._originalUserId = announcementsDeliveryModelImpl._userId;
364    
365                    announcementsDeliveryModelImpl._setOriginalUserId = false;
366    
367                    announcementsDeliveryModelImpl._originalType = announcementsDeliveryModelImpl._type;
368    
369                    announcementsDeliveryModelImpl._columnBitmask = 0;
370            }
371    
372            @Override
373            public CacheModel<AnnouncementsDelivery> toCacheModel() {
374                    AnnouncementsDeliveryCacheModel announcementsDeliveryCacheModel = new AnnouncementsDeliveryCacheModel();
375    
376                    announcementsDeliveryCacheModel.deliveryId = getDeliveryId();
377    
378                    announcementsDeliveryCacheModel.companyId = getCompanyId();
379    
380                    announcementsDeliveryCacheModel.userId = getUserId();
381    
382                    announcementsDeliveryCacheModel.type = getType();
383    
384                    String type = announcementsDeliveryCacheModel.type;
385    
386                    if ((type != null) && (type.length() == 0)) {
387                            announcementsDeliveryCacheModel.type = null;
388                    }
389    
390                    announcementsDeliveryCacheModel.email = getEmail();
391    
392                    announcementsDeliveryCacheModel.sms = getSms();
393    
394                    announcementsDeliveryCacheModel.website = getWebsite();
395    
396                    return announcementsDeliveryCacheModel;
397            }
398    
399            @Override
400            public String toString() {
401                    StringBundler sb = new StringBundler(15);
402    
403                    sb.append("{deliveryId=");
404                    sb.append(getDeliveryId());
405                    sb.append(", companyId=");
406                    sb.append(getCompanyId());
407                    sb.append(", userId=");
408                    sb.append(getUserId());
409                    sb.append(", type=");
410                    sb.append(getType());
411                    sb.append(", email=");
412                    sb.append(getEmail());
413                    sb.append(", sms=");
414                    sb.append(getSms());
415                    sb.append(", website=");
416                    sb.append(getWebsite());
417                    sb.append("}");
418    
419                    return sb.toString();
420            }
421    
422            public String toXmlString() {
423                    StringBundler sb = new StringBundler(25);
424    
425                    sb.append("<model><model-name>");
426                    sb.append(
427                            "com.liferay.portlet.announcements.model.AnnouncementsDelivery");
428                    sb.append("</model-name>");
429    
430                    sb.append(
431                            "<column><column-name>deliveryId</column-name><column-value><![CDATA[");
432                    sb.append(getDeliveryId());
433                    sb.append("]]></column-value></column>");
434                    sb.append(
435                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
436                    sb.append(getCompanyId());
437                    sb.append("]]></column-value></column>");
438                    sb.append(
439                            "<column><column-name>userId</column-name><column-value><![CDATA[");
440                    sb.append(getUserId());
441                    sb.append("]]></column-value></column>");
442                    sb.append(
443                            "<column><column-name>type</column-name><column-value><![CDATA[");
444                    sb.append(getType());
445                    sb.append("]]></column-value></column>");
446                    sb.append(
447                            "<column><column-name>email</column-name><column-value><![CDATA[");
448                    sb.append(getEmail());
449                    sb.append("]]></column-value></column>");
450                    sb.append(
451                            "<column><column-name>sms</column-name><column-value><![CDATA[");
452                    sb.append(getSms());
453                    sb.append("]]></column-value></column>");
454                    sb.append(
455                            "<column><column-name>website</column-name><column-value><![CDATA[");
456                    sb.append(getWebsite());
457                    sb.append("]]></column-value></column>");
458    
459                    sb.append("</model>");
460    
461                    return sb.toString();
462            }
463    
464            private static ClassLoader _classLoader = AnnouncementsDelivery.class.getClassLoader();
465            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
466                            AnnouncementsDelivery.class
467                    };
468            private long _deliveryId;
469            private long _companyId;
470            private long _userId;
471            private String _userUuid;
472            private long _originalUserId;
473            private boolean _setOriginalUserId;
474            private String _type;
475            private String _originalType;
476            private boolean _email;
477            private boolean _sms;
478            private boolean _website;
479            private transient ExpandoBridge _expandoBridge;
480            private long _columnBitmask;
481            private AnnouncementsDelivery _escapedModelProxy;
482    }