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