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