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