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