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