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 DATA_SOURCE = "liferayDataSource";
071            public static final String SESSION_FACTORY = "liferaySessionFactory";
072            public static final String TX_MANAGER = "liferayTransactionManager";
073            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074                                    "value.object.entity.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
075                            true);
076            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.finder.cache.enabled.com.liferay.portlet.social.model.SocialRelation"),
078                            true);
079            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.column.bitmask.enabled.com.liferay.portlet.social.model.SocialRelation"),
081                            true);
082            public static long COMPANYID_COLUMN_BITMASK = 1L;
083            public static long TYPE_COLUMN_BITMASK = 2L;
084            public static long USERID1_COLUMN_BITMASK = 4L;
085            public static long USERID2_COLUMN_BITMASK = 8L;
086            public static long UUID_COLUMN_BITMASK = 16L;
087            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
088                                    "lock.expiration.time.com.liferay.portlet.social.model.SocialRelation"));
089    
090            public SocialRelationModelImpl() {
091            }
092    
093            public long getPrimaryKey() {
094                    return _relationId;
095            }
096    
097            public void setPrimaryKey(long primaryKey) {
098                    setRelationId(primaryKey);
099            }
100    
101            public Serializable getPrimaryKeyObj() {
102                    return new Long(_relationId);
103            }
104    
105            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
106                    setPrimaryKey(((Long)primaryKeyObj).longValue());
107            }
108    
109            public Class<?> getModelClass() {
110                    return SocialRelation.class;
111            }
112    
113            public String getModelClassName() {
114                    return SocialRelation.class.getName();
115            }
116    
117            @Override
118            public Map<String, Object> getModelAttributes() {
119                    Map<String, Object> attributes = new HashMap<String, Object>();
120    
121                    attributes.put("uuid", getUuid());
122                    attributes.put("relationId", getRelationId());
123                    attributes.put("companyId", getCompanyId());
124                    attributes.put("createDate", getCreateDate());
125                    attributes.put("userId1", getUserId1());
126                    attributes.put("userId2", getUserId2());
127                    attributes.put("type", getType());
128    
129                    return attributes;
130            }
131    
132            @Override
133            public void setModelAttributes(Map<String, Object> attributes) {
134                    String uuid = (String)attributes.get("uuid");
135    
136                    if (uuid != null) {
137                            setUuid(uuid);
138                    }
139    
140                    Long relationId = (Long)attributes.get("relationId");
141    
142                    if (relationId != null) {
143                            setRelationId(relationId);
144                    }
145    
146                    Long companyId = (Long)attributes.get("companyId");
147    
148                    if (companyId != null) {
149                            setCompanyId(companyId);
150                    }
151    
152                    Long createDate = (Long)attributes.get("createDate");
153    
154                    if (createDate != null) {
155                            setCreateDate(createDate);
156                    }
157    
158                    Long userId1 = (Long)attributes.get("userId1");
159    
160                    if (userId1 != null) {
161                            setUserId1(userId1);
162                    }
163    
164                    Long userId2 = (Long)attributes.get("userId2");
165    
166                    if (userId2 != null) {
167                            setUserId2(userId2);
168                    }
169    
170                    Integer type = (Integer)attributes.get("type");
171    
172                    if (type != null) {
173                            setType(type);
174                    }
175            }
176    
177            public String getUuid() {
178                    if (_uuid == null) {
179                            return StringPool.BLANK;
180                    }
181                    else {
182                            return _uuid;
183                    }
184            }
185    
186            public void setUuid(String uuid) {
187                    if (_originalUuid == null) {
188                            _originalUuid = _uuid;
189                    }
190    
191                    _uuid = uuid;
192            }
193    
194            public String getOriginalUuid() {
195                    return GetterUtil.getString(_originalUuid);
196            }
197    
198            public long getRelationId() {
199                    return _relationId;
200            }
201    
202            public void setRelationId(long relationId) {
203                    _relationId = relationId;
204            }
205    
206            public long getCompanyId() {
207                    return _companyId;
208            }
209    
210            public void setCompanyId(long companyId) {
211                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
212    
213                    if (!_setOriginalCompanyId) {
214                            _setOriginalCompanyId = true;
215    
216                            _originalCompanyId = _companyId;
217                    }
218    
219                    _companyId = companyId;
220            }
221    
222            public long getOriginalCompanyId() {
223                    return _originalCompanyId;
224            }
225    
226            public long getCreateDate() {
227                    return _createDate;
228            }
229    
230            public void setCreateDate(long createDate) {
231                    _createDate = createDate;
232            }
233    
234            public long getUserId1() {
235                    return _userId1;
236            }
237    
238            public void setUserId1(long userId1) {
239                    _columnBitmask |= USERID1_COLUMN_BITMASK;
240    
241                    if (!_setOriginalUserId1) {
242                            _setOriginalUserId1 = true;
243    
244                            _originalUserId1 = _userId1;
245                    }
246    
247                    _userId1 = userId1;
248            }
249    
250            public long getOriginalUserId1() {
251                    return _originalUserId1;
252            }
253    
254            public long getUserId2() {
255                    return _userId2;
256            }
257    
258            public void setUserId2(long userId2) {
259                    _columnBitmask |= USERID2_COLUMN_BITMASK;
260    
261                    if (!_setOriginalUserId2) {
262                            _setOriginalUserId2 = true;
263    
264                            _originalUserId2 = _userId2;
265                    }
266    
267                    _userId2 = userId2;
268            }
269    
270            public long getOriginalUserId2() {
271                    return _originalUserId2;
272            }
273    
274            public int getType() {
275                    return _type;
276            }
277    
278            public void setType(int type) {
279                    _columnBitmask |= TYPE_COLUMN_BITMASK;
280    
281                    if (!_setOriginalType) {
282                            _setOriginalType = true;
283    
284                            _originalType = _type;
285                    }
286    
287                    _type = type;
288            }
289    
290            public int getOriginalType() {
291                    return _originalType;
292            }
293    
294            public long getColumnBitmask() {
295                    return _columnBitmask;
296            }
297    
298            @Override
299            public ExpandoBridge getExpandoBridge() {
300                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
301                            SocialRelation.class.getName(), getPrimaryKey());
302            }
303    
304            @Override
305            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
306                    ExpandoBridge expandoBridge = getExpandoBridge();
307    
308                    expandoBridge.setAttributes(serviceContext);
309            }
310    
311            @Override
312            public SocialRelation toEscapedModel() {
313                    if (_escapedModel == null) {
314                            _escapedModel = (SocialRelation)ProxyUtil.newProxyInstance(_classLoader,
315                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
316                    }
317    
318                    return _escapedModel;
319            }
320    
321            public SocialRelation toUnescapedModel() {
322                    return (SocialRelation)this;
323            }
324    
325            @Override
326            public Object clone() {
327                    SocialRelationImpl socialRelationImpl = new SocialRelationImpl();
328    
329                    socialRelationImpl.setUuid(getUuid());
330                    socialRelationImpl.setRelationId(getRelationId());
331                    socialRelationImpl.setCompanyId(getCompanyId());
332                    socialRelationImpl.setCreateDate(getCreateDate());
333                    socialRelationImpl.setUserId1(getUserId1());
334                    socialRelationImpl.setUserId2(getUserId2());
335                    socialRelationImpl.setType(getType());
336    
337                    socialRelationImpl.resetOriginalValues();
338    
339                    return socialRelationImpl;
340            }
341    
342            public int compareTo(SocialRelation socialRelation) {
343                    long primaryKey = socialRelation.getPrimaryKey();
344    
345                    if (getPrimaryKey() < primaryKey) {
346                            return -1;
347                    }
348                    else if (getPrimaryKey() > primaryKey) {
349                            return 1;
350                    }
351                    else {
352                            return 0;
353                    }
354            }
355    
356            @Override
357            public boolean equals(Object obj) {
358                    if (this == obj) {
359                            return true;
360                    }
361    
362                    if (!(obj instanceof SocialRelation)) {
363                            return false;
364                    }
365    
366                    SocialRelation socialRelation = (SocialRelation)obj;
367    
368                    long primaryKey = socialRelation.getPrimaryKey();
369    
370                    if (getPrimaryKey() == primaryKey) {
371                            return true;
372                    }
373                    else {
374                            return false;
375                    }
376            }
377    
378            @Override
379            public int hashCode() {
380                    return (int)getPrimaryKey();
381            }
382    
383            @Override
384            public void resetOriginalValues() {
385                    SocialRelationModelImpl socialRelationModelImpl = this;
386    
387                    socialRelationModelImpl._originalUuid = socialRelationModelImpl._uuid;
388    
389                    socialRelationModelImpl._originalCompanyId = socialRelationModelImpl._companyId;
390    
391                    socialRelationModelImpl._setOriginalCompanyId = false;
392    
393                    socialRelationModelImpl._originalUserId1 = socialRelationModelImpl._userId1;
394    
395                    socialRelationModelImpl._setOriginalUserId1 = false;
396    
397                    socialRelationModelImpl._originalUserId2 = socialRelationModelImpl._userId2;
398    
399                    socialRelationModelImpl._setOriginalUserId2 = false;
400    
401                    socialRelationModelImpl._originalType = socialRelationModelImpl._type;
402    
403                    socialRelationModelImpl._setOriginalType = false;
404    
405                    socialRelationModelImpl._columnBitmask = 0;
406            }
407    
408            @Override
409            public CacheModel<SocialRelation> toCacheModel() {
410                    SocialRelationCacheModel socialRelationCacheModel = new SocialRelationCacheModel();
411    
412                    socialRelationCacheModel.uuid = getUuid();
413    
414                    String uuid = socialRelationCacheModel.uuid;
415    
416                    if ((uuid != null) && (uuid.length() == 0)) {
417                            socialRelationCacheModel.uuid = null;
418                    }
419    
420                    socialRelationCacheModel.relationId = getRelationId();
421    
422                    socialRelationCacheModel.companyId = getCompanyId();
423    
424                    socialRelationCacheModel.createDate = getCreateDate();
425    
426                    socialRelationCacheModel.userId1 = getUserId1();
427    
428                    socialRelationCacheModel.userId2 = getUserId2();
429    
430                    socialRelationCacheModel.type = getType();
431    
432                    return socialRelationCacheModel;
433            }
434    
435            @Override
436            public String toString() {
437                    StringBundler sb = new StringBundler(15);
438    
439                    sb.append("{uuid=");
440                    sb.append(getUuid());
441                    sb.append(", relationId=");
442                    sb.append(getRelationId());
443                    sb.append(", companyId=");
444                    sb.append(getCompanyId());
445                    sb.append(", createDate=");
446                    sb.append(getCreateDate());
447                    sb.append(", userId1=");
448                    sb.append(getUserId1());
449                    sb.append(", userId2=");
450                    sb.append(getUserId2());
451                    sb.append(", type=");
452                    sb.append(getType());
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.SocialRelation");
463                    sb.append("</model-name>");
464    
465                    sb.append(
466                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
467                    sb.append(getUuid());
468                    sb.append("]]></column-value></column>");
469                    sb.append(
470                            "<column><column-name>relationId</column-name><column-value><![CDATA[");
471                    sb.append(getRelationId());
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>createDate</column-name><column-value><![CDATA[");
479                    sb.append(getCreateDate());
480                    sb.append("]]></column-value></column>");
481                    sb.append(
482                            "<column><column-name>userId1</column-name><column-value><![CDATA[");
483                    sb.append(getUserId1());
484                    sb.append("]]></column-value></column>");
485                    sb.append(
486                            "<column><column-name>userId2</column-name><column-value><![CDATA[");
487                    sb.append(getUserId2());
488                    sb.append("]]></column-value></column>");
489                    sb.append(
490                            "<column><column-name>type</column-name><column-value><![CDATA[");
491                    sb.append(getType());
492                    sb.append("]]></column-value></column>");
493    
494                    sb.append("</model>");
495    
496                    return sb.toString();
497            }
498    
499            private static ClassLoader _classLoader = SocialRelation.class.getClassLoader();
500            private static Class<?>[] _escapedModelInterfaces = new Class[] {
501                            SocialRelation.class
502                    };
503            private String _uuid;
504            private String _originalUuid;
505            private long _relationId;
506            private long _companyId;
507            private long _originalCompanyId;
508            private boolean _setOriginalCompanyId;
509            private long _createDate;
510            private long _userId1;
511            private long _originalUserId1;
512            private boolean _setOriginalUserId1;
513            private long _userId2;
514            private long _originalUserId2;
515            private boolean _setOriginalUserId2;
516            private int _type;
517            private int _originalType;
518            private boolean _setOriginalType;
519            private long _columnBitmask;
520            private SocialRelation _escapedModel;
521    }