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