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