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.social.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.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.model.CacheModel;
024    import com.liferay.portal.model.impl.BaseModelImpl;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.util.PortalUtil;
027    
028    import com.liferay.portlet.expando.model.ExpandoBridge;
029    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030    import com.liferay.portlet.social.model.SocialActivityAchievement;
031    import com.liferay.portlet.social.model.SocialActivityAchievementModel;
032    
033    import java.io.Serializable;
034    
035    import java.sql.Types;
036    
037    import java.util.HashMap;
038    import java.util.Map;
039    
040    /**
041     * The base model implementation for the SocialActivityAchievement service. Represents a row in the "SocialActivityAchievement" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link com.liferay.portlet.social.model.SocialActivityAchievementModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SocialActivityAchievementImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see SocialActivityAchievementImpl
049     * @see com.liferay.portlet.social.model.SocialActivityAchievement
050     * @see com.liferay.portlet.social.model.SocialActivityAchievementModel
051     * @generated
052     */
053    public class SocialActivityAchievementModelImpl extends BaseModelImpl<SocialActivityAchievement>
054            implements SocialActivityAchievementModel {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * Never modify or reference this class directly. All methods that expect a social activity achievement model instance should use the {@link com.liferay.portlet.social.model.SocialActivityAchievement} interface instead.
059             */
060            public static final String TABLE_NAME = "SocialActivityAchievement";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "activityAchievementId", Types.BIGINT },
063                            { "groupId", Types.BIGINT },
064                            { "companyId", Types.BIGINT },
065                            { "userId", Types.BIGINT },
066                            { "createDate", Types.BIGINT },
067                            { "name", Types.VARCHAR },
068                            { "firstInGroup", Types.BOOLEAN }
069                    };
070            public static final String TABLE_SQL_CREATE = "create table SocialActivityAchievement (activityAchievementId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate LONG,name VARCHAR(75) null,firstInGroup BOOLEAN)";
071            public static final String TABLE_SQL_DROP = "drop table SocialActivityAchievement";
072            public static final String DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialActivityAchievement"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialActivityAchievement"),
080                            true);
081            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.column.bitmask.enabled.com.liferay.portlet.social.model.SocialActivityAchievement"),
083                            true);
084            public static long FIRSTINGROUP_COLUMN_BITMASK = 1L;
085            public static long GROUPID_COLUMN_BITMASK = 2L;
086            public static long NAME_COLUMN_BITMASK = 4L;
087            public static long USERID_COLUMN_BITMASK = 8L;
088            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
089                                    "lock.expiration.time.com.liferay.portlet.social.model.SocialActivityAchievement"));
090    
091            public SocialActivityAchievementModelImpl() {
092            }
093    
094            public long getPrimaryKey() {
095                    return _activityAchievementId;
096            }
097    
098            public void setPrimaryKey(long primaryKey) {
099                    setActivityAchievementId(primaryKey);
100            }
101    
102            public Serializable getPrimaryKeyObj() {
103                    return new Long(_activityAchievementId);
104            }
105    
106            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
107                    setPrimaryKey(((Long)primaryKeyObj).longValue());
108            }
109    
110            public Class<?> getModelClass() {
111                    return SocialActivityAchievement.class;
112            }
113    
114            public String getModelClassName() {
115                    return SocialActivityAchievement.class.getName();
116            }
117    
118            @Override
119            public Map<String, Object> getModelAttributes() {
120                    Map<String, Object> attributes = new HashMap<String, Object>();
121    
122                    attributes.put("activityAchievementId", getActivityAchievementId());
123                    attributes.put("groupId", getGroupId());
124                    attributes.put("companyId", getCompanyId());
125                    attributes.put("userId", getUserId());
126                    attributes.put("createDate", getCreateDate());
127                    attributes.put("name", getName());
128                    attributes.put("firstInGroup", getFirstInGroup());
129    
130                    return attributes;
131            }
132    
133            @Override
134            public void setModelAttributes(Map<String, Object> attributes) {
135                    Long activityAchievementId = (Long)attributes.get(
136                                    "activityAchievementId");
137    
138                    if (activityAchievementId != null) {
139                            setActivityAchievementId(activityAchievementId);
140                    }
141    
142                    Long groupId = (Long)attributes.get("groupId");
143    
144                    if (groupId != null) {
145                            setGroupId(groupId);
146                    }
147    
148                    Long companyId = (Long)attributes.get("companyId");
149    
150                    if (companyId != null) {
151                            setCompanyId(companyId);
152                    }
153    
154                    Long userId = (Long)attributes.get("userId");
155    
156                    if (userId != null) {
157                            setUserId(userId);
158                    }
159    
160                    Long createDate = (Long)attributes.get("createDate");
161    
162                    if (createDate != null) {
163                            setCreateDate(createDate);
164                    }
165    
166                    String name = (String)attributes.get("name");
167    
168                    if (name != null) {
169                            setName(name);
170                    }
171    
172                    Boolean firstInGroup = (Boolean)attributes.get("firstInGroup");
173    
174                    if (firstInGroup != null) {
175                            setFirstInGroup(firstInGroup);
176                    }
177            }
178    
179            public long getActivityAchievementId() {
180                    return _activityAchievementId;
181            }
182    
183            public void setActivityAchievementId(long activityAchievementId) {
184                    _activityAchievementId = activityAchievementId;
185            }
186    
187            public long getGroupId() {
188                    return _groupId;
189            }
190    
191            public void setGroupId(long groupId) {
192                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
193    
194                    if (!_setOriginalGroupId) {
195                            _setOriginalGroupId = true;
196    
197                            _originalGroupId = _groupId;
198                    }
199    
200                    _groupId = groupId;
201            }
202    
203            public long getOriginalGroupId() {
204                    return _originalGroupId;
205            }
206    
207            public long getCompanyId() {
208                    return _companyId;
209            }
210    
211            public void setCompanyId(long companyId) {
212                    _companyId = companyId;
213            }
214    
215            public long getUserId() {
216                    return _userId;
217            }
218    
219            public void setUserId(long userId) {
220                    _columnBitmask |= USERID_COLUMN_BITMASK;
221    
222                    if (!_setOriginalUserId) {
223                            _setOriginalUserId = true;
224    
225                            _originalUserId = _userId;
226                    }
227    
228                    _userId = userId;
229            }
230    
231            public String getUserUuid() throws SystemException {
232                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
233            }
234    
235            public void setUserUuid(String userUuid) {
236                    _userUuid = userUuid;
237            }
238    
239            public long getOriginalUserId() {
240                    return _originalUserId;
241            }
242    
243            public long getCreateDate() {
244                    return _createDate;
245            }
246    
247            public void setCreateDate(long createDate) {
248                    _createDate = createDate;
249            }
250    
251            public String getName() {
252                    if (_name == null) {
253                            return StringPool.BLANK;
254                    }
255                    else {
256                            return _name;
257                    }
258            }
259    
260            public void setName(String name) {
261                    _columnBitmask |= NAME_COLUMN_BITMASK;
262    
263                    if (_originalName == null) {
264                            _originalName = _name;
265                    }
266    
267                    _name = name;
268            }
269    
270            public String getOriginalName() {
271                    return GetterUtil.getString(_originalName);
272            }
273    
274            public boolean getFirstInGroup() {
275                    return _firstInGroup;
276            }
277    
278            public boolean isFirstInGroup() {
279                    return _firstInGroup;
280            }
281    
282            public void setFirstInGroup(boolean firstInGroup) {
283                    _columnBitmask |= FIRSTINGROUP_COLUMN_BITMASK;
284    
285                    if (!_setOriginalFirstInGroup) {
286                            _setOriginalFirstInGroup = true;
287    
288                            _originalFirstInGroup = _firstInGroup;
289                    }
290    
291                    _firstInGroup = firstInGroup;
292            }
293    
294            public boolean getOriginalFirstInGroup() {
295                    return _originalFirstInGroup;
296            }
297    
298            public long getColumnBitmask() {
299                    return _columnBitmask;
300            }
301    
302            @Override
303            public ExpandoBridge getExpandoBridge() {
304                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
305                            SocialActivityAchievement.class.getName(), getPrimaryKey());
306            }
307    
308            @Override
309            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
310                    ExpandoBridge expandoBridge = getExpandoBridge();
311    
312                    expandoBridge.setAttributes(serviceContext);
313            }
314    
315            @Override
316            public SocialActivityAchievement toEscapedModel() {
317                    if (_escapedModel == null) {
318                            _escapedModel = (SocialActivityAchievement)ProxyUtil.newProxyInstance(_classLoader,
319                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
320                    }
321    
322                    return _escapedModel;
323            }
324    
325            public SocialActivityAchievement toUnescapedModel() {
326                    return (SocialActivityAchievement)this;
327            }
328    
329            @Override
330            public Object clone() {
331                    SocialActivityAchievementImpl socialActivityAchievementImpl = new SocialActivityAchievementImpl();
332    
333                    socialActivityAchievementImpl.setActivityAchievementId(getActivityAchievementId());
334                    socialActivityAchievementImpl.setGroupId(getGroupId());
335                    socialActivityAchievementImpl.setCompanyId(getCompanyId());
336                    socialActivityAchievementImpl.setUserId(getUserId());
337                    socialActivityAchievementImpl.setCreateDate(getCreateDate());
338                    socialActivityAchievementImpl.setName(getName());
339                    socialActivityAchievementImpl.setFirstInGroup(getFirstInGroup());
340    
341                    socialActivityAchievementImpl.resetOriginalValues();
342    
343                    return socialActivityAchievementImpl;
344            }
345    
346            public int compareTo(SocialActivityAchievement socialActivityAchievement) {
347                    long primaryKey = socialActivityAchievement.getPrimaryKey();
348    
349                    if (getPrimaryKey() < primaryKey) {
350                            return -1;
351                    }
352                    else if (getPrimaryKey() > primaryKey) {
353                            return 1;
354                    }
355                    else {
356                            return 0;
357                    }
358            }
359    
360            @Override
361            public boolean equals(Object obj) {
362                    if (this == obj) {
363                            return true;
364                    }
365    
366                    if (!(obj instanceof SocialActivityAchievement)) {
367                            return false;
368                    }
369    
370                    SocialActivityAchievement socialActivityAchievement = (SocialActivityAchievement)obj;
371    
372                    long primaryKey = socialActivityAchievement.getPrimaryKey();
373    
374                    if (getPrimaryKey() == primaryKey) {
375                            return true;
376                    }
377                    else {
378                            return false;
379                    }
380            }
381    
382            @Override
383            public int hashCode() {
384                    return (int)getPrimaryKey();
385            }
386    
387            @Override
388            public void resetOriginalValues() {
389                    SocialActivityAchievementModelImpl socialActivityAchievementModelImpl = this;
390    
391                    socialActivityAchievementModelImpl._originalGroupId = socialActivityAchievementModelImpl._groupId;
392    
393                    socialActivityAchievementModelImpl._setOriginalGroupId = false;
394    
395                    socialActivityAchievementModelImpl._originalUserId = socialActivityAchievementModelImpl._userId;
396    
397                    socialActivityAchievementModelImpl._setOriginalUserId = false;
398    
399                    socialActivityAchievementModelImpl._originalName = socialActivityAchievementModelImpl._name;
400    
401                    socialActivityAchievementModelImpl._originalFirstInGroup = socialActivityAchievementModelImpl._firstInGroup;
402    
403                    socialActivityAchievementModelImpl._setOriginalFirstInGroup = false;
404    
405                    socialActivityAchievementModelImpl._columnBitmask = 0;
406            }
407    
408            @Override
409            public CacheModel<SocialActivityAchievement> toCacheModel() {
410                    SocialActivityAchievementCacheModel socialActivityAchievementCacheModel = new SocialActivityAchievementCacheModel();
411    
412                    socialActivityAchievementCacheModel.activityAchievementId = getActivityAchievementId();
413    
414                    socialActivityAchievementCacheModel.groupId = getGroupId();
415    
416                    socialActivityAchievementCacheModel.companyId = getCompanyId();
417    
418                    socialActivityAchievementCacheModel.userId = getUserId();
419    
420                    socialActivityAchievementCacheModel.createDate = getCreateDate();
421    
422                    socialActivityAchievementCacheModel.name = getName();
423    
424                    String name = socialActivityAchievementCacheModel.name;
425    
426                    if ((name != null) && (name.length() == 0)) {
427                            socialActivityAchievementCacheModel.name = null;
428                    }
429    
430                    socialActivityAchievementCacheModel.firstInGroup = getFirstInGroup();
431    
432                    return socialActivityAchievementCacheModel;
433            }
434    
435            @Override
436            public String toString() {
437                    StringBundler sb = new StringBundler(15);
438    
439                    sb.append("{activityAchievementId=");
440                    sb.append(getActivityAchievementId());
441                    sb.append(", groupId=");
442                    sb.append(getGroupId());
443                    sb.append(", companyId=");
444                    sb.append(getCompanyId());
445                    sb.append(", userId=");
446                    sb.append(getUserId());
447                    sb.append(", createDate=");
448                    sb.append(getCreateDate());
449                    sb.append(", name=");
450                    sb.append(getName());
451                    sb.append(", firstInGroup=");
452                    sb.append(getFirstInGroup());
453                    sb.append("}");
454    
455                    return sb.toString();
456            }
457    
458            public String toXmlString() {
459                    StringBundler sb = new StringBundler(25);
460    
461                    sb.append("<model><model-name>");
462                    sb.append("com.liferay.portlet.social.model.SocialActivityAchievement");
463                    sb.append("</model-name>");
464    
465                    sb.append(
466                            "<column><column-name>activityAchievementId</column-name><column-value><![CDATA[");
467                    sb.append(getActivityAchievementId());
468                    sb.append("]]></column-value></column>");
469                    sb.append(
470                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
471                    sb.append(getGroupId());
472                    sb.append("]]></column-value></column>");
473                    sb.append(
474                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
475                    sb.append(getCompanyId());
476                    sb.append("]]></column-value></column>");
477                    sb.append(
478                            "<column><column-name>userId</column-name><column-value><![CDATA[");
479                    sb.append(getUserId());
480                    sb.append("]]></column-value></column>");
481                    sb.append(
482                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
483                    sb.append(getCreateDate());
484                    sb.append("]]></column-value></column>");
485                    sb.append(
486                            "<column><column-name>name</column-name><column-value><![CDATA[");
487                    sb.append(getName());
488                    sb.append("]]></column-value></column>");
489                    sb.append(
490                            "<column><column-name>firstInGroup</column-name><column-value><![CDATA[");
491                    sb.append(getFirstInGroup());
492                    sb.append("]]></column-value></column>");
493    
494                    sb.append("</model>");
495    
496                    return sb.toString();
497            }
498    
499            private static ClassLoader _classLoader = SocialActivityAchievement.class.getClassLoader();
500            private static Class<?>[] _escapedModelInterfaces = new Class[] {
501                            SocialActivityAchievement.class
502                    };
503            private long _activityAchievementId;
504            private long _groupId;
505            private long _originalGroupId;
506            private boolean _setOriginalGroupId;
507            private long _companyId;
508            private long _userId;
509            private String _userUuid;
510            private long _originalUserId;
511            private boolean _setOriginalUserId;
512            private long _createDate;
513            private String _name;
514            private String _originalName;
515            private boolean _firstInGroup;
516            private boolean _originalFirstInGroup;
517            private boolean _setOriginalFirstInGroup;
518            private long _columnBitmask;
519            private SocialActivityAchievement _escapedModel;
520    }