001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.social.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.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    /**
036     * 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.
037     *
038     * <p>
039     * 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}.
040     * </p>
041     *
042     * @author Brian Wing Shun Chan
043     * @see SocialRelationImpl
044     * @see com.liferay.portlet.social.model.SocialRelation
045     * @see com.liferay.portlet.social.model.SocialRelationModel
046     * @generated
047     */
048    public class SocialRelationModelImpl extends BaseModelImpl<SocialRelation>
049            implements SocialRelationModel {
050            /*
051             * NOTE FOR DEVELOPERS:
052             *
053             * 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.
054             */
055            public static final String TABLE_NAME = "SocialRelation";
056            public static final Object[][] TABLE_COLUMNS = {
057                            { "uuid_", Types.VARCHAR },
058                            { "relationId", Types.BIGINT },
059                            { "companyId", Types.BIGINT },
060                            { "createDate", Types.BIGINT },
061                            { "userId1", Types.BIGINT },
062                            { "userId2", Types.BIGINT },
063                            { "type_", Types.INTEGER }
064                    };
065            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)";
066            public static final String TABLE_SQL_DROP = "drop table SocialRelation";
067            public static final String DATA_SOURCE = "liferayDataSource";
068            public static final String SESSION_FACTORY = "liferaySessionFactory";
069            public static final String TX_MANAGER = "liferayTransactionManager";
070            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
071                                    "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
072                            true);
073            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
075                            true);
076            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.column.bitmask.enabled.com.liferay.portlet.social.model.SocialRelation"),
078                            true);
079            public static long COMPANYID_COLUMN_BITMASK = 1L;
080            public static long TYPE_COLUMN_BITMASK = 2L;
081            public static long USERID1_COLUMN_BITMASK = 4L;
082            public static long USERID2_COLUMN_BITMASK = 8L;
083            public static long UUID_COLUMN_BITMASK = 16L;
084            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
085                                    "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
086    
087            public SocialRelationModelImpl() {
088            }
089    
090            public long getPrimaryKey() {
091                    return _relationId;
092            }
093    
094            public void setPrimaryKey(long primaryKey) {
095                    setRelationId(primaryKey);
096            }
097    
098            public Serializable getPrimaryKeyObj() {
099                    return new Long(_relationId);
100            }
101    
102            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
103                    setPrimaryKey(((Long)primaryKeyObj).longValue());
104            }
105    
106            public Class<?> getModelClass() {
107                    return SocialRelation.class;
108            }
109    
110            public String getModelClassName() {
111                    return SocialRelation.class.getName();
112            }
113    
114            public String getUuid() {
115                    if (_uuid == null) {
116                            return StringPool.BLANK;
117                    }
118                    else {
119                            return _uuid;
120                    }
121            }
122    
123            public void setUuid(String uuid) {
124                    if (_originalUuid == null) {
125                            _originalUuid = _uuid;
126                    }
127    
128                    _uuid = uuid;
129            }
130    
131            public String getOriginalUuid() {
132                    return GetterUtil.getString(_originalUuid);
133            }
134    
135            public long getRelationId() {
136                    return _relationId;
137            }
138    
139            public void setRelationId(long relationId) {
140                    _relationId = relationId;
141            }
142    
143            public long getCompanyId() {
144                    return _companyId;
145            }
146    
147            public void setCompanyId(long companyId) {
148                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
149    
150                    if (!_setOriginalCompanyId) {
151                            _setOriginalCompanyId = true;
152    
153                            _originalCompanyId = _companyId;
154                    }
155    
156                    _companyId = companyId;
157            }
158    
159            public long getOriginalCompanyId() {
160                    return _originalCompanyId;
161            }
162    
163            public long getCreateDate() {
164                    return _createDate;
165            }
166    
167            public void setCreateDate(long createDate) {
168                    _createDate = createDate;
169            }
170    
171            public long getUserId1() {
172                    return _userId1;
173            }
174    
175            public void setUserId1(long userId1) {
176                    _columnBitmask |= USERID1_COLUMN_BITMASK;
177    
178                    if (!_setOriginalUserId1) {
179                            _setOriginalUserId1 = true;
180    
181                            _originalUserId1 = _userId1;
182                    }
183    
184                    _userId1 = userId1;
185            }
186    
187            public long getOriginalUserId1() {
188                    return _originalUserId1;
189            }
190    
191            public long getUserId2() {
192                    return _userId2;
193            }
194    
195            public void setUserId2(long userId2) {
196                    _columnBitmask |= USERID2_COLUMN_BITMASK;
197    
198                    if (!_setOriginalUserId2) {
199                            _setOriginalUserId2 = true;
200    
201                            _originalUserId2 = _userId2;
202                    }
203    
204                    _userId2 = userId2;
205            }
206    
207            public long getOriginalUserId2() {
208                    return _originalUserId2;
209            }
210    
211            public int getType() {
212                    return _type;
213            }
214    
215            public void setType(int type) {
216                    _columnBitmask |= TYPE_COLUMN_BITMASK;
217    
218                    if (!_setOriginalType) {
219                            _setOriginalType = true;
220    
221                            _originalType = _type;
222                    }
223    
224                    _type = type;
225            }
226    
227            public int getOriginalType() {
228                    return _originalType;
229            }
230    
231            public long getColumnBitmask() {
232                    return _columnBitmask;
233            }
234    
235            @Override
236            public SocialRelation toEscapedModel() {
237                    if (_escapedModelProxy == null) {
238                            _escapedModelProxy = (SocialRelation)ProxyUtil.newProxyInstance(_classLoader,
239                                            _escapedModelProxyInterfaces,
240                                            new AutoEscapeBeanHandler(this));
241                    }
242    
243                    return _escapedModelProxy;
244            }
245    
246            @Override
247            public ExpandoBridge getExpandoBridge() {
248                    if (_expandoBridge == null) {
249                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
250                                            SocialRelation.class.getName(), getPrimaryKey());
251                    }
252    
253                    return _expandoBridge;
254            }
255    
256            @Override
257            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
258                    getExpandoBridge().setAttributes(serviceContext);
259            }
260    
261            @Override
262            public Object clone() {
263                    SocialRelationImpl socialRelationImpl = new SocialRelationImpl();
264    
265                    socialRelationImpl.setUuid(getUuid());
266                    socialRelationImpl.setRelationId(getRelationId());
267                    socialRelationImpl.setCompanyId(getCompanyId());
268                    socialRelationImpl.setCreateDate(getCreateDate());
269                    socialRelationImpl.setUserId1(getUserId1());
270                    socialRelationImpl.setUserId2(getUserId2());
271                    socialRelationImpl.setType(getType());
272    
273                    socialRelationImpl.resetOriginalValues();
274    
275                    return socialRelationImpl;
276            }
277    
278            public int compareTo(SocialRelation socialRelation) {
279                    long primaryKey = socialRelation.getPrimaryKey();
280    
281                    if (getPrimaryKey() < primaryKey) {
282                            return -1;
283                    }
284                    else if (getPrimaryKey() > primaryKey) {
285                            return 1;
286                    }
287                    else {
288                            return 0;
289                    }
290            }
291    
292            @Override
293            public boolean equals(Object obj) {
294                    if (obj == null) {
295                            return false;
296                    }
297    
298                    SocialRelation socialRelation = null;
299    
300                    try {
301                            socialRelation = (SocialRelation)obj;
302                    }
303                    catch (ClassCastException cce) {
304                            return false;
305                    }
306    
307                    long primaryKey = socialRelation.getPrimaryKey();
308    
309                    if (getPrimaryKey() == primaryKey) {
310                            return true;
311                    }
312                    else {
313                            return false;
314                    }
315            }
316    
317            @Override
318            public int hashCode() {
319                    return (int)getPrimaryKey();
320            }
321    
322            @Override
323            public void resetOriginalValues() {
324                    SocialRelationModelImpl socialRelationModelImpl = this;
325    
326                    socialRelationModelImpl._originalUuid = socialRelationModelImpl._uuid;
327    
328                    socialRelationModelImpl._originalCompanyId = socialRelationModelImpl._companyId;
329    
330                    socialRelationModelImpl._setOriginalCompanyId = false;
331    
332                    socialRelationModelImpl._originalUserId1 = socialRelationModelImpl._userId1;
333    
334                    socialRelationModelImpl._setOriginalUserId1 = false;
335    
336                    socialRelationModelImpl._originalUserId2 = socialRelationModelImpl._userId2;
337    
338                    socialRelationModelImpl._setOriginalUserId2 = false;
339    
340                    socialRelationModelImpl._originalType = socialRelationModelImpl._type;
341    
342                    socialRelationModelImpl._setOriginalType = false;
343    
344                    socialRelationModelImpl._columnBitmask = 0;
345            }
346    
347            @Override
348            public CacheModel<SocialRelation> toCacheModel() {
349                    SocialRelationCacheModel socialRelationCacheModel = new SocialRelationCacheModel();
350    
351                    socialRelationCacheModel.uuid = getUuid();
352    
353                    String uuid = socialRelationCacheModel.uuid;
354    
355                    if ((uuid != null) && (uuid.length() == 0)) {
356                            socialRelationCacheModel.uuid = null;
357                    }
358    
359                    socialRelationCacheModel.relationId = getRelationId();
360    
361                    socialRelationCacheModel.companyId = getCompanyId();
362    
363                    socialRelationCacheModel.createDate = getCreateDate();
364    
365                    socialRelationCacheModel.userId1 = getUserId1();
366    
367                    socialRelationCacheModel.userId2 = getUserId2();
368    
369                    socialRelationCacheModel.type = getType();
370    
371                    return socialRelationCacheModel;
372            }
373    
374            @Override
375            public String toString() {
376                    StringBundler sb = new StringBundler(15);
377    
378                    sb.append("{uuid=");
379                    sb.append(getUuid());
380                    sb.append(", relationId=");
381                    sb.append(getRelationId());
382                    sb.append(", companyId=");
383                    sb.append(getCompanyId());
384                    sb.append(", createDate=");
385                    sb.append(getCreateDate());
386                    sb.append(", userId1=");
387                    sb.append(getUserId1());
388                    sb.append(", userId2=");
389                    sb.append(getUserId2());
390                    sb.append(", type=");
391                    sb.append(getType());
392                    sb.append("}");
393    
394                    return sb.toString();
395            }
396    
397            public String toXmlString() {
398                    StringBundler sb = new StringBundler(25);
399    
400                    sb.append("<model><model-name>");
401                    sb.append("com.liferay.portlet.social.model.SocialRelation");
402                    sb.append("</model-name>");
403    
404                    sb.append(
405                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
406                    sb.append(getUuid());
407                    sb.append("]]></column-value></column>");
408                    sb.append(
409                            "<column><column-name>relationId</column-name><column-value><![CDATA[");
410                    sb.append(getRelationId());
411                    sb.append("]]></column-value></column>");
412                    sb.append(
413                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
414                    sb.append(getCompanyId());
415                    sb.append("]]></column-value></column>");
416                    sb.append(
417                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
418                    sb.append(getCreateDate());
419                    sb.append("]]></column-value></column>");
420                    sb.append(
421                            "<column><column-name>userId1</column-name><column-value><![CDATA[");
422                    sb.append(getUserId1());
423                    sb.append("]]></column-value></column>");
424                    sb.append(
425                            "<column><column-name>userId2</column-name><column-value><![CDATA[");
426                    sb.append(getUserId2());
427                    sb.append("]]></column-value></column>");
428                    sb.append(
429                            "<column><column-name>type</column-name><column-value><![CDATA[");
430                    sb.append(getType());
431                    sb.append("]]></column-value></column>");
432    
433                    sb.append("</model>");
434    
435                    return sb.toString();
436            }
437    
438            private static ClassLoader _classLoader = SocialRelation.class.getClassLoader();
439            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
440                            SocialRelation.class
441                    };
442            private String _uuid;
443            private String _originalUuid;
444            private long _relationId;
445            private long _companyId;
446            private long _originalCompanyId;
447            private boolean _setOriginalCompanyId;
448            private long _createDate;
449            private long _userId1;
450            private long _originalUserId1;
451            private boolean _setOriginalUserId1;
452            private long _userId2;
453            private long _originalUserId2;
454            private boolean _setOriginalUserId2;
455            private int _type;
456            private int _originalType;
457            private boolean _setOriginalType;
458            private transient ExpandoBridge _expandoBridge;
459            private long _columnBitmask;
460            private SocialRelation _escapedModelProxy;
461    }