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