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