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