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