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