001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.ProxyUtil;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.kernel.util.StringPool;
023 import com.liferay.portal.model.CacheModel;
024 import com.liferay.portal.model.Lock;
025 import com.liferay.portal.model.LockModel;
026 import com.liferay.portal.service.ServiceContext;
027 import com.liferay.portal.util.PortalUtil;
028
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031
032 import java.io.Serializable;
033
034 import java.sql.Types;
035
036 import java.util.Date;
037 import java.util.HashMap;
038 import java.util.Map;
039
040
053 public class LockModelImpl extends BaseModelImpl<Lock> implements LockModel {
054
059 public static final String TABLE_NAME = "Lock_";
060 public static final Object[][] TABLE_COLUMNS = {
061 { "uuid_", Types.VARCHAR },
062 { "lockId", Types.BIGINT },
063 { "companyId", Types.BIGINT },
064 { "userId", Types.BIGINT },
065 { "userName", Types.VARCHAR },
066 { "createDate", Types.TIMESTAMP },
067 { "className", Types.VARCHAR },
068 { "key_", Types.VARCHAR },
069 { "owner", Types.VARCHAR },
070 { "inheritable", Types.BOOLEAN },
071 { "expirationDate", Types.TIMESTAMP }
072 };
073 public static final String TABLE_SQL_CREATE = "create table Lock_ (uuid_ VARCHAR(75) null,lockId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,className VARCHAR(75) null,key_ VARCHAR(200) null,owner VARCHAR(255) null,inheritable BOOLEAN,expirationDate DATE null)";
074 public static final String TABLE_SQL_DROP = "drop table Lock_";
075 public static final String ORDER_BY_JPQL = " ORDER BY lock.lockId ASC";
076 public static final String ORDER_BY_SQL = " ORDER BY Lock_.lockId ASC";
077 public static final String DATA_SOURCE = "liferayDataSource";
078 public static final String SESSION_FACTORY = "liferaySessionFactory";
079 public static final String TX_MANAGER = "liferayTransactionManager";
080 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081 "value.object.entity.cache.enabled.com.liferay.portal.model.Lock"),
082 true);
083 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084 "value.object.finder.cache.enabled.com.liferay.portal.model.Lock"),
085 true);
086 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087 "value.object.column.bitmask.enabled.com.liferay.portal.model.Lock"),
088 true);
089 public static long CLASSNAME_COLUMN_BITMASK = 1L;
090 public static long COMPANYID_COLUMN_BITMASK = 2L;
091 public static long EXPIRATIONDATE_COLUMN_BITMASK = 4L;
092 public static long KEY_COLUMN_BITMASK = 8L;
093 public static long UUID_COLUMN_BITMASK = 16L;
094 public static long LOCKID_COLUMN_BITMASK = 32L;
095 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
096 "lock.expiration.time.com.liferay.portal.model.Lock"));
097
098 public LockModelImpl() {
099 }
100
101 @Override
102 public long getPrimaryKey() {
103 return _lockId;
104 }
105
106 @Override
107 public void setPrimaryKey(long primaryKey) {
108 setLockId(primaryKey);
109 }
110
111 @Override
112 public Serializable getPrimaryKeyObj() {
113 return _lockId;
114 }
115
116 @Override
117 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
118 setPrimaryKey(((Long)primaryKeyObj).longValue());
119 }
120
121 @Override
122 public Class<?> getModelClass() {
123 return Lock.class;
124 }
125
126 @Override
127 public String getModelClassName() {
128 return Lock.class.getName();
129 }
130
131 @Override
132 public Map<String, Object> getModelAttributes() {
133 Map<String, Object> attributes = new HashMap<String, Object>();
134
135 attributes.put("uuid", getUuid());
136 attributes.put("lockId", getLockId());
137 attributes.put("companyId", getCompanyId());
138 attributes.put("userId", getUserId());
139 attributes.put("userName", getUserName());
140 attributes.put("createDate", getCreateDate());
141 attributes.put("className", getClassName());
142 attributes.put("key", getKey());
143 attributes.put("owner", getOwner());
144 attributes.put("inheritable", getInheritable());
145 attributes.put("expirationDate", getExpirationDate());
146
147 return attributes;
148 }
149
150 @Override
151 public void setModelAttributes(Map<String, Object> attributes) {
152 String uuid = (String)attributes.get("uuid");
153
154 if (uuid != null) {
155 setUuid(uuid);
156 }
157
158 Long lockId = (Long)attributes.get("lockId");
159
160 if (lockId != null) {
161 setLockId(lockId);
162 }
163
164 Long companyId = (Long)attributes.get("companyId");
165
166 if (companyId != null) {
167 setCompanyId(companyId);
168 }
169
170 Long userId = (Long)attributes.get("userId");
171
172 if (userId != null) {
173 setUserId(userId);
174 }
175
176 String userName = (String)attributes.get("userName");
177
178 if (userName != null) {
179 setUserName(userName);
180 }
181
182 Date createDate = (Date)attributes.get("createDate");
183
184 if (createDate != null) {
185 setCreateDate(createDate);
186 }
187
188 String className = (String)attributes.get("className");
189
190 if (className != null) {
191 setClassName(className);
192 }
193
194 String key = (String)attributes.get("key");
195
196 if (key != null) {
197 setKey(key);
198 }
199
200 String owner = (String)attributes.get("owner");
201
202 if (owner != null) {
203 setOwner(owner);
204 }
205
206 Boolean inheritable = (Boolean)attributes.get("inheritable");
207
208 if (inheritable != null) {
209 setInheritable(inheritable);
210 }
211
212 Date expirationDate = (Date)attributes.get("expirationDate");
213
214 if (expirationDate != null) {
215 setExpirationDate(expirationDate);
216 }
217 }
218
219 @Override
220 public String getUuid() {
221 if (_uuid == null) {
222 return StringPool.BLANK;
223 }
224 else {
225 return _uuid;
226 }
227 }
228
229 @Override
230 public void setUuid(String uuid) {
231 if (_originalUuid == null) {
232 _originalUuid = _uuid;
233 }
234
235 _uuid = uuid;
236 }
237
238 public String getOriginalUuid() {
239 return GetterUtil.getString(_originalUuid);
240 }
241
242 @Override
243 public long getLockId() {
244 return _lockId;
245 }
246
247 @Override
248 public void setLockId(long lockId) {
249 _lockId = lockId;
250 }
251
252 @Override
253 public long getCompanyId() {
254 return _companyId;
255 }
256
257 @Override
258 public void setCompanyId(long companyId) {
259 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
260
261 if (!_setOriginalCompanyId) {
262 _setOriginalCompanyId = true;
263
264 _originalCompanyId = _companyId;
265 }
266
267 _companyId = companyId;
268 }
269
270 public long getOriginalCompanyId() {
271 return _originalCompanyId;
272 }
273
274 @Override
275 public long getUserId() {
276 return _userId;
277 }
278
279 @Override
280 public void setUserId(long userId) {
281 _userId = userId;
282 }
283
284 @Override
285 public String getUserUuid() throws SystemException {
286 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
287 }
288
289 @Override
290 public void setUserUuid(String userUuid) {
291 _userUuid = userUuid;
292 }
293
294 @Override
295 public String getUserName() {
296 if (_userName == null) {
297 return StringPool.BLANK;
298 }
299 else {
300 return _userName;
301 }
302 }
303
304 @Override
305 public void setUserName(String userName) {
306 _userName = userName;
307 }
308
309 @Override
310 public Date getCreateDate() {
311 return _createDate;
312 }
313
314 @Override
315 public void setCreateDate(Date createDate) {
316 _createDate = createDate;
317 }
318
319 @Override
320 public String getClassName() {
321 if (_className == null) {
322 return StringPool.BLANK;
323 }
324 else {
325 return _className;
326 }
327 }
328
329 @Override
330 public void setClassName(String className) {
331 _columnBitmask |= CLASSNAME_COLUMN_BITMASK;
332
333 if (_originalClassName == null) {
334 _originalClassName = _className;
335 }
336
337 _className = className;
338 }
339
340 public String getOriginalClassName() {
341 return GetterUtil.getString(_originalClassName);
342 }
343
344 @Override
345 public String getKey() {
346 if (_key == null) {
347 return StringPool.BLANK;
348 }
349 else {
350 return _key;
351 }
352 }
353
354 @Override
355 public void setKey(String key) {
356 _columnBitmask |= KEY_COLUMN_BITMASK;
357
358 if (_originalKey == null) {
359 _originalKey = _key;
360 }
361
362 _key = key;
363 }
364
365 public String getOriginalKey() {
366 return GetterUtil.getString(_originalKey);
367 }
368
369 @Override
370 public String getOwner() {
371 if (_owner == null) {
372 return StringPool.BLANK;
373 }
374 else {
375 return _owner;
376 }
377 }
378
379 @Override
380 public void setOwner(String owner) {
381 _owner = owner;
382 }
383
384 @Override
385 public boolean getInheritable() {
386 return _inheritable;
387 }
388
389 @Override
390 public boolean isInheritable() {
391 return _inheritable;
392 }
393
394 @Override
395 public void setInheritable(boolean inheritable) {
396 _inheritable = inheritable;
397 }
398
399 @Override
400 public Date getExpirationDate() {
401 return _expirationDate;
402 }
403
404 @Override
405 public void setExpirationDate(Date expirationDate) {
406 _columnBitmask |= EXPIRATIONDATE_COLUMN_BITMASK;
407
408 if (_originalExpirationDate == null) {
409 _originalExpirationDate = _expirationDate;
410 }
411
412 _expirationDate = expirationDate;
413 }
414
415 public Date getOriginalExpirationDate() {
416 return _originalExpirationDate;
417 }
418
419 public long getColumnBitmask() {
420 return _columnBitmask;
421 }
422
423 @Override
424 public ExpandoBridge getExpandoBridge() {
425 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
426 Lock.class.getName(), getPrimaryKey());
427 }
428
429 @Override
430 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
431 ExpandoBridge expandoBridge = getExpandoBridge();
432
433 expandoBridge.setAttributes(serviceContext);
434 }
435
436 @Override
437 public Lock toEscapedModel() {
438 if (_escapedModel == null) {
439 _escapedModel = (Lock)ProxyUtil.newProxyInstance(_classLoader,
440 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
441 }
442
443 return _escapedModel;
444 }
445
446 @Override
447 public Object clone() {
448 LockImpl lockImpl = new LockImpl();
449
450 lockImpl.setUuid(getUuid());
451 lockImpl.setLockId(getLockId());
452 lockImpl.setCompanyId(getCompanyId());
453 lockImpl.setUserId(getUserId());
454 lockImpl.setUserName(getUserName());
455 lockImpl.setCreateDate(getCreateDate());
456 lockImpl.setClassName(getClassName());
457 lockImpl.setKey(getKey());
458 lockImpl.setOwner(getOwner());
459 lockImpl.setInheritable(getInheritable());
460 lockImpl.setExpirationDate(getExpirationDate());
461
462 lockImpl.resetOriginalValues();
463
464 return lockImpl;
465 }
466
467 @Override
468 public int compareTo(Lock lock) {
469 long primaryKey = lock.getPrimaryKey();
470
471 if (getPrimaryKey() < primaryKey) {
472 return -1;
473 }
474 else if (getPrimaryKey() > primaryKey) {
475 return 1;
476 }
477 else {
478 return 0;
479 }
480 }
481
482 @Override
483 public boolean equals(Object obj) {
484 if (this == obj) {
485 return true;
486 }
487
488 if (!(obj instanceof Lock)) {
489 return false;
490 }
491
492 Lock lock = (Lock)obj;
493
494 long primaryKey = lock.getPrimaryKey();
495
496 if (getPrimaryKey() == primaryKey) {
497 return true;
498 }
499 else {
500 return false;
501 }
502 }
503
504 @Override
505 public int hashCode() {
506 return (int)getPrimaryKey();
507 }
508
509 @Override
510 public void resetOriginalValues() {
511 LockModelImpl lockModelImpl = this;
512
513 lockModelImpl._originalUuid = lockModelImpl._uuid;
514
515 lockModelImpl._originalCompanyId = lockModelImpl._companyId;
516
517 lockModelImpl._setOriginalCompanyId = false;
518
519 lockModelImpl._originalClassName = lockModelImpl._className;
520
521 lockModelImpl._originalKey = lockModelImpl._key;
522
523 lockModelImpl._originalExpirationDate = lockModelImpl._expirationDate;
524
525 lockModelImpl._columnBitmask = 0;
526 }
527
528 @Override
529 public CacheModel<Lock> toCacheModel() {
530 LockCacheModel lockCacheModel = new LockCacheModel();
531
532 lockCacheModel.uuid = getUuid();
533
534 String uuid = lockCacheModel.uuid;
535
536 if ((uuid != null) && (uuid.length() == 0)) {
537 lockCacheModel.uuid = null;
538 }
539
540 lockCacheModel.lockId = getLockId();
541
542 lockCacheModel.companyId = getCompanyId();
543
544 lockCacheModel.userId = getUserId();
545
546 lockCacheModel.userName = getUserName();
547
548 String userName = lockCacheModel.userName;
549
550 if ((userName != null) && (userName.length() == 0)) {
551 lockCacheModel.userName = null;
552 }
553
554 Date createDate = getCreateDate();
555
556 if (createDate != null) {
557 lockCacheModel.createDate = createDate.getTime();
558 }
559 else {
560 lockCacheModel.createDate = Long.MIN_VALUE;
561 }
562
563 lockCacheModel.className = getClassName();
564
565 String className = lockCacheModel.className;
566
567 if ((className != null) && (className.length() == 0)) {
568 lockCacheModel.className = null;
569 }
570
571 lockCacheModel.key = getKey();
572
573 String key = lockCacheModel.key;
574
575 if ((key != null) && (key.length() == 0)) {
576 lockCacheModel.key = null;
577 }
578
579 lockCacheModel.owner = getOwner();
580
581 String owner = lockCacheModel.owner;
582
583 if ((owner != null) && (owner.length() == 0)) {
584 lockCacheModel.owner = null;
585 }
586
587 lockCacheModel.inheritable = getInheritable();
588
589 Date expirationDate = getExpirationDate();
590
591 if (expirationDate != null) {
592 lockCacheModel.expirationDate = expirationDate.getTime();
593 }
594 else {
595 lockCacheModel.expirationDate = Long.MIN_VALUE;
596 }
597
598 return lockCacheModel;
599 }
600
601 @Override
602 public String toString() {
603 StringBundler sb = new StringBundler(23);
604
605 sb.append("{uuid=");
606 sb.append(getUuid());
607 sb.append(", lockId=");
608 sb.append(getLockId());
609 sb.append(", companyId=");
610 sb.append(getCompanyId());
611 sb.append(", userId=");
612 sb.append(getUserId());
613 sb.append(", userName=");
614 sb.append(getUserName());
615 sb.append(", createDate=");
616 sb.append(getCreateDate());
617 sb.append(", className=");
618 sb.append(getClassName());
619 sb.append(", key=");
620 sb.append(getKey());
621 sb.append(", owner=");
622 sb.append(getOwner());
623 sb.append(", inheritable=");
624 sb.append(getInheritable());
625 sb.append(", expirationDate=");
626 sb.append(getExpirationDate());
627 sb.append("}");
628
629 return sb.toString();
630 }
631
632 @Override
633 public String toXmlString() {
634 StringBundler sb = new StringBundler(37);
635
636 sb.append("<model><model-name>");
637 sb.append("com.liferay.portal.model.Lock");
638 sb.append("</model-name>");
639
640 sb.append(
641 "<column><column-name>uuid</column-name><column-value><![CDATA[");
642 sb.append(getUuid());
643 sb.append("]]></column-value></column>");
644 sb.append(
645 "<column><column-name>lockId</column-name><column-value><![CDATA[");
646 sb.append(getLockId());
647 sb.append("]]></column-value></column>");
648 sb.append(
649 "<column><column-name>companyId</column-name><column-value><![CDATA[");
650 sb.append(getCompanyId());
651 sb.append("]]></column-value></column>");
652 sb.append(
653 "<column><column-name>userId</column-name><column-value><![CDATA[");
654 sb.append(getUserId());
655 sb.append("]]></column-value></column>");
656 sb.append(
657 "<column><column-name>userName</column-name><column-value><![CDATA[");
658 sb.append(getUserName());
659 sb.append("]]></column-value></column>");
660 sb.append(
661 "<column><column-name>createDate</column-name><column-value><![CDATA[");
662 sb.append(getCreateDate());
663 sb.append("]]></column-value></column>");
664 sb.append(
665 "<column><column-name>className</column-name><column-value><![CDATA[");
666 sb.append(getClassName());
667 sb.append("]]></column-value></column>");
668 sb.append(
669 "<column><column-name>key</column-name><column-value><![CDATA[");
670 sb.append(getKey());
671 sb.append("]]></column-value></column>");
672 sb.append(
673 "<column><column-name>owner</column-name><column-value><![CDATA[");
674 sb.append(getOwner());
675 sb.append("]]></column-value></column>");
676 sb.append(
677 "<column><column-name>inheritable</column-name><column-value><![CDATA[");
678 sb.append(getInheritable());
679 sb.append("]]></column-value></column>");
680 sb.append(
681 "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
682 sb.append(getExpirationDate());
683 sb.append("]]></column-value></column>");
684
685 sb.append("</model>");
686
687 return sb.toString();
688 }
689
690 private static ClassLoader _classLoader = Lock.class.getClassLoader();
691 private static Class<?>[] _escapedModelInterfaces = new Class[] { Lock.class };
692 private String _uuid;
693 private String _originalUuid;
694 private long _lockId;
695 private long _companyId;
696 private long _originalCompanyId;
697 private boolean _setOriginalCompanyId;
698 private long _userId;
699 private String _userUuid;
700 private String _userName;
701 private Date _createDate;
702 private String _className;
703 private String _originalClassName;
704 private String _key;
705 private String _originalKey;
706 private String _owner;
707 private boolean _inheritable;
708 private Date _expirationDate;
709 private Date _originalExpirationDate;
710 private long _columnBitmask;
711 private Lock _escapedModel;
712 }