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.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    
028    import com.liferay.portlet.expando.model.ExpandoBridge;
029    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030    import com.liferay.portlet.social.model.SocialRelation;
031    import com.liferay.portlet.social.model.SocialRelationModel;
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 SocialRelation service. Represents a row in the "SocialRelation" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link SocialRelationModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SocialRelationImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see SocialRelationImpl
049     * @see SocialRelation
050     * @see SocialRelationModel
051     * @generated
052     */
053    @ProviderType
054    public class SocialRelationModelImpl extends BaseModelImpl<SocialRelation>
055            implements SocialRelationModel {
056            /*
057             * NOTE FOR DEVELOPERS:
058             *
059             * Never modify or reference this class directly. All methods that expect a social relation model instance should use the {@link SocialRelation} interface instead.
060             */
061            public static final String TABLE_NAME = "SocialRelation";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "uuid_", Types.VARCHAR },
064                            { "relationId", Types.BIGINT },
065                            { "companyId", Types.BIGINT },
066                            { "createDate", Types.BIGINT },
067                            { "userId1", Types.BIGINT },
068                            { "userId2", Types.BIGINT },
069                            { "type_", Types.INTEGER }
070                    };
071            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
072    
073            static {
074                    TABLE_COLUMNS_MAP.put("uuid_", Types.VARCHAR);
075                    TABLE_COLUMNS_MAP.put("relationId", Types.BIGINT);
076                    TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT);
077                    TABLE_COLUMNS_MAP.put("createDate", Types.BIGINT);
078                    TABLE_COLUMNS_MAP.put("userId1", Types.BIGINT);
079                    TABLE_COLUMNS_MAP.put("userId2", Types.BIGINT);
080                    TABLE_COLUMNS_MAP.put("type_", Types.INTEGER);
081            }
082    
083            public static final String TABLE_SQL_CREATE = "create table SocialRelation (uuid_ VARCHAR(75) null,relationId LONG not null primary key,companyId LONG,createDate LONG,userId1 LONG,userId2 LONG,type_ INTEGER)";
084            public static final String TABLE_SQL_DROP = "drop table SocialRelation";
085            public static final String ORDER_BY_JPQL = " ORDER BY socialRelation.relationId ASC";
086            public static final String ORDER_BY_SQL = " ORDER BY SocialRelation.relationId ASC";
087            public static final String DATA_SOURCE = "liferayDataSource";
088            public static final String SESSION_FACTORY = "liferaySessionFactory";
089            public static final String TX_MANAGER = "liferayTransactionManager";
090            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091                                    "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
092                            true);
093            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
094                                    "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
095                            true);
096            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
097                                    "value.object.column.bitmask.enabled.com.liferay.portlet.social.model.SocialRelation"),
098                            true);
099            public static final long COMPANYID_COLUMN_BITMASK = 1L;
100            public static final long TYPE_COLUMN_BITMASK = 2L;
101            public static final long USERID1_COLUMN_BITMASK = 4L;
102            public static final long USERID2_COLUMN_BITMASK = 8L;
103            public static final long UUID_COLUMN_BITMASK = 16L;
104            public static final long RELATIONID_COLUMN_BITMASK = 32L;
105            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                                    "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
107    
108            public SocialRelationModelImpl() {
109            }
110    
111            @Override
112            public long getPrimaryKey() {
113                    return _relationId;
114            }
115    
116            @Override
117            public void setPrimaryKey(long primaryKey) {
118                    setRelationId(primaryKey);
119            }
120    
121            @Override
122            public Serializable getPrimaryKeyObj() {
123                    return _relationId;
124            }
125    
126            @Override
127            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
128                    setPrimaryKey(((Long)primaryKeyObj).longValue());
129            }
130    
131            @Override
132            public Class<?> getModelClass() {
133                    return SocialRelation.class;
134            }
135    
136            @Override
137            public String getModelClassName() {
138                    return SocialRelation.class.getName();
139            }
140    
141            @Override
142            public Map<String, Object> getModelAttributes() {
143                    Map<String, Object> attributes = new HashMap<String, Object>();
144    
145                    attributes.put("uuid", getUuid());
146                    attributes.put("relationId", getRelationId());
147                    attributes.put("companyId", getCompanyId());
148                    attributes.put("createDate", getCreateDate());
149                    attributes.put("userId1", getUserId1());
150                    attributes.put("userId2", getUserId2());
151                    attributes.put("type", getType());
152    
153                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
154                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
155    
156                    return attributes;
157            }
158    
159            @Override
160            public void setModelAttributes(Map<String, Object> attributes) {
161                    String uuid = (String)attributes.get("uuid");
162    
163                    if (uuid != null) {
164                            setUuid(uuid);
165                    }
166    
167                    Long relationId = (Long)attributes.get("relationId");
168    
169                    if (relationId != null) {
170                            setRelationId(relationId);
171                    }
172    
173                    Long companyId = (Long)attributes.get("companyId");
174    
175                    if (companyId != null) {
176                            setCompanyId(companyId);
177                    }
178    
179                    Long createDate = (Long)attributes.get("createDate");
180    
181                    if (createDate != null) {
182                            setCreateDate(createDate);
183                    }
184    
185                    Long userId1 = (Long)attributes.get("userId1");
186    
187                    if (userId1 != null) {
188                            setUserId1(userId1);
189                    }
190    
191                    Long userId2 = (Long)attributes.get("userId2");
192    
193                    if (userId2 != null) {
194                            setUserId2(userId2);
195                    }
196    
197                    Integer type = (Integer)attributes.get("type");
198    
199                    if (type != null) {
200                            setType(type);
201                    }
202            }
203    
204            @Override
205            public String getUuid() {
206                    if (_uuid == null) {
207                            return StringPool.BLANK;
208                    }
209                    else {
210                            return _uuid;
211                    }
212            }
213    
214            @Override
215            public void setUuid(String uuid) {
216                    if (_originalUuid == null) {
217                            _originalUuid = _uuid;
218                    }
219    
220                    _uuid = uuid;
221            }
222    
223            public String getOriginalUuid() {
224                    return GetterUtil.getString(_originalUuid);
225            }
226    
227            @Override
228            public long getRelationId() {
229                    return _relationId;
230            }
231    
232            @Override
233            public void setRelationId(long relationId) {
234                    _relationId = relationId;
235            }
236    
237            @Override
238            public long getCompanyId() {
239                    return _companyId;
240            }
241    
242            @Override
243            public void setCompanyId(long companyId) {
244                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
245    
246                    if (!_setOriginalCompanyId) {
247                            _setOriginalCompanyId = true;
248    
249                            _originalCompanyId = _companyId;
250                    }
251    
252                    _companyId = companyId;
253            }
254    
255            public long getOriginalCompanyId() {
256                    return _originalCompanyId;
257            }
258    
259            @Override
260            public long getCreateDate() {
261                    return _createDate;
262            }
263    
264            @Override
265            public void setCreateDate(long createDate) {
266                    _createDate = createDate;
267            }
268    
269            @Override
270            public long getUserId1() {
271                    return _userId1;
272            }
273    
274            @Override
275            public void setUserId1(long userId1) {
276                    _columnBitmask |= USERID1_COLUMN_BITMASK;
277    
278                    if (!_setOriginalUserId1) {
279                            _setOriginalUserId1 = true;
280    
281                            _originalUserId1 = _userId1;
282                    }
283    
284                    _userId1 = userId1;
285            }
286    
287            public long getOriginalUserId1() {
288                    return _originalUserId1;
289            }
290    
291            @Override
292            public long getUserId2() {
293                    return _userId2;
294            }
295    
296            @Override
297            public void setUserId2(long userId2) {
298                    _columnBitmask |= USERID2_COLUMN_BITMASK;
299    
300                    if (!_setOriginalUserId2) {
301                            _setOriginalUserId2 = true;
302    
303                            _originalUserId2 = _userId2;
304                    }
305    
306                    _userId2 = userId2;
307            }
308    
309            public long getOriginalUserId2() {
310                    return _originalUserId2;
311            }
312    
313            @Override
314            public int getType() {
315                    return _type;
316            }
317    
318            @Override
319            public void setType(int type) {
320                    _columnBitmask |= TYPE_COLUMN_BITMASK;
321    
322                    if (!_setOriginalType) {
323                            _setOriginalType = true;
324    
325                            _originalType = _type;
326                    }
327    
328                    _type = type;
329            }
330    
331            public int getOriginalType() {
332                    return _originalType;
333            }
334    
335            public long getColumnBitmask() {
336                    return _columnBitmask;
337            }
338    
339            @Override
340            public ExpandoBridge getExpandoBridge() {
341                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
342                            SocialRelation.class.getName(), getPrimaryKey());
343            }
344    
345            @Override
346            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
347                    ExpandoBridge expandoBridge = getExpandoBridge();
348    
349                    expandoBridge.setAttributes(serviceContext);
350            }
351    
352            @Override
353            public SocialRelation toEscapedModel() {
354                    if (_escapedModel == null) {
355                            _escapedModel = (SocialRelation)ProxyUtil.newProxyInstance(_classLoader,
356                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
357                    }
358    
359                    return _escapedModel;
360            }
361    
362            @Override
363            public Object clone() {
364                    SocialRelationImpl socialRelationImpl = new SocialRelationImpl();
365    
366                    socialRelationImpl.setUuid(getUuid());
367                    socialRelationImpl.setRelationId(getRelationId());
368                    socialRelationImpl.setCompanyId(getCompanyId());
369                    socialRelationImpl.setCreateDate(getCreateDate());
370                    socialRelationImpl.setUserId1(getUserId1());
371                    socialRelationImpl.setUserId2(getUserId2());
372                    socialRelationImpl.setType(getType());
373    
374                    socialRelationImpl.resetOriginalValues();
375    
376                    return socialRelationImpl;
377            }
378    
379            @Override
380            public int compareTo(SocialRelation socialRelation) {
381                    long primaryKey = socialRelation.getPrimaryKey();
382    
383                    if (getPrimaryKey() < primaryKey) {
384                            return -1;
385                    }
386                    else if (getPrimaryKey() > primaryKey) {
387                            return 1;
388                    }
389                    else {
390                            return 0;
391                    }
392            }
393    
394            @Override
395            public boolean equals(Object obj) {
396                    if (this == obj) {
397                            return true;
398                    }
399    
400                    if (!(obj instanceof SocialRelation)) {
401                            return false;
402                    }
403    
404                    SocialRelation socialRelation = (SocialRelation)obj;
405    
406                    long primaryKey = socialRelation.getPrimaryKey();
407    
408                    if (getPrimaryKey() == primaryKey) {
409                            return true;
410                    }
411                    else {
412                            return false;
413                    }
414            }
415    
416            @Override
417            public int hashCode() {
418                    return (int)getPrimaryKey();
419            }
420    
421            @Override
422            public boolean isEntityCacheEnabled() {
423                    return ENTITY_CACHE_ENABLED;
424            }
425    
426            @Override
427            public boolean isFinderCacheEnabled() {
428                    return FINDER_CACHE_ENABLED;
429            }
430    
431            @Override
432            public void resetOriginalValues() {
433                    SocialRelationModelImpl socialRelationModelImpl = this;
434    
435                    socialRelationModelImpl._originalUuid = socialRelationModelImpl._uuid;
436    
437                    socialRelationModelImpl._originalCompanyId = socialRelationModelImpl._companyId;
438    
439                    socialRelationModelImpl._setOriginalCompanyId = false;
440    
441                    socialRelationModelImpl._originalUserId1 = socialRelationModelImpl._userId1;
442    
443                    socialRelationModelImpl._setOriginalUserId1 = false;
444    
445                    socialRelationModelImpl._originalUserId2 = socialRelationModelImpl._userId2;
446    
447                    socialRelationModelImpl._setOriginalUserId2 = false;
448    
449                    socialRelationModelImpl._originalType = socialRelationModelImpl._type;
450    
451                    socialRelationModelImpl._setOriginalType = false;
452    
453                    socialRelationModelImpl._columnBitmask = 0;
454            }
455    
456            @Override
457            public CacheModel<SocialRelation> toCacheModel() {
458                    SocialRelationCacheModel socialRelationCacheModel = new SocialRelationCacheModel();
459    
460                    socialRelationCacheModel.uuid = getUuid();
461    
462                    String uuid = socialRelationCacheModel.uuid;
463    
464                    if ((uuid != null) && (uuid.length() == 0)) {
465                            socialRelationCacheModel.uuid = null;
466                    }
467    
468                    socialRelationCacheModel.relationId = getRelationId();
469    
470                    socialRelationCacheModel.companyId = getCompanyId();
471    
472                    socialRelationCacheModel.createDate = getCreateDate();
473    
474                    socialRelationCacheModel.userId1 = getUserId1();
475    
476                    socialRelationCacheModel.userId2 = getUserId2();
477    
478                    socialRelationCacheModel.type = getType();
479    
480                    return socialRelationCacheModel;
481            }
482    
483            @Override
484            public String toString() {
485                    StringBundler sb = new StringBundler(15);
486    
487                    sb.append("{uuid=");
488                    sb.append(getUuid());
489                    sb.append(", relationId=");
490                    sb.append(getRelationId());
491                    sb.append(", companyId=");
492                    sb.append(getCompanyId());
493                    sb.append(", createDate=");
494                    sb.append(getCreateDate());
495                    sb.append(", userId1=");
496                    sb.append(getUserId1());
497                    sb.append(", userId2=");
498                    sb.append(getUserId2());
499                    sb.append(", type=");
500                    sb.append(getType());
501                    sb.append("}");
502    
503                    return sb.toString();
504            }
505    
506            @Override
507            public String toXmlString() {
508                    StringBundler sb = new StringBundler(25);
509    
510                    sb.append("<model><model-name>");
511                    sb.append("com.liferay.portlet.social.model.SocialRelation");
512                    sb.append("</model-name>");
513    
514                    sb.append(
515                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
516                    sb.append(getUuid());
517                    sb.append("]]></column-value></column>");
518                    sb.append(
519                            "<column><column-name>relationId</column-name><column-value><![CDATA[");
520                    sb.append(getRelationId());
521                    sb.append("]]></column-value></column>");
522                    sb.append(
523                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
524                    sb.append(getCompanyId());
525                    sb.append("]]></column-value></column>");
526                    sb.append(
527                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
528                    sb.append(getCreateDate());
529                    sb.append("]]></column-value></column>");
530                    sb.append(
531                            "<column><column-name>userId1</column-name><column-value><![CDATA[");
532                    sb.append(getUserId1());
533                    sb.append("]]></column-value></column>");
534                    sb.append(
535                            "<column><column-name>userId2</column-name><column-value><![CDATA[");
536                    sb.append(getUserId2());
537                    sb.append("]]></column-value></column>");
538                    sb.append(
539                            "<column><column-name>type</column-name><column-value><![CDATA[");
540                    sb.append(getType());
541                    sb.append("]]></column-value></column>");
542    
543                    sb.append("</model>");
544    
545                    return sb.toString();
546            }
547    
548            private static final ClassLoader _classLoader = SocialRelation.class.getClassLoader();
549            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
550                            SocialRelation.class
551                    };
552            private String _uuid;
553            private String _originalUuid;
554            private long _relationId;
555            private long _companyId;
556            private long _originalCompanyId;
557            private boolean _setOriginalCompanyId;
558            private long _createDate;
559            private long _userId1;
560            private long _originalUserId1;
561            private boolean _setOriginalUserId1;
562            private long _userId2;
563            private long _originalUserId2;
564            private boolean _setOriginalUserId2;
565            private int _type;
566            private int _originalType;
567            private boolean _setOriginalType;
568            private long _columnBitmask;
569            private SocialRelation _escapedModel;
570    }