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