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