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