001    /**
002     * Copyright (c) 2000-2011 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.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.Lock;
023    import com.liferay.portal.model.LockModel;
024    import com.liferay.portal.service.ServiceContext;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029    
030    import java.io.Serializable;
031    
032    import java.lang.reflect.Proxy;
033    
034    import java.sql.Types;
035    
036    import java.util.Date;
037    
038    /**
039     * 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.
040     *
041     * <p>
042     * 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}.
043     * </p>
044     *
045     * <p>
046     * 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.
047     * </p>
048     *
049     * @author Brian Wing Shun Chan
050     * @see LockImpl
051     * @see com.liferay.portal.model.Lock
052     * @see com.liferay.portal.model.LockModel
053     * @generated
054     */
055    public class LockModelImpl extends BaseModelImpl<Lock> implements LockModel {
056            public static final String TABLE_NAME = "Lock_";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "uuid_", new Integer(Types.VARCHAR) },
059                            { "lockId", new Integer(Types.BIGINT) },
060                            { "companyId", new Integer(Types.BIGINT) },
061                            { "userId", new Integer(Types.BIGINT) },
062                            { "userName", new Integer(Types.VARCHAR) },
063                            { "createDate", new Integer(Types.TIMESTAMP) },
064                            { "className", new Integer(Types.VARCHAR) },
065                            { "key_", new Integer(Types.VARCHAR) },
066                            { "owner", new Integer(Types.VARCHAR) },
067                            { "inheritable", new Integer(Types.BOOLEAN) },
068                            { "expirationDate", new Integer(Types.TIMESTAMP) }
069                    };
070            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(75) null,inheritable BOOLEAN,expirationDate DATE null)";
071            public static final String TABLE_SQL_DROP = "drop table Lock_";
072            public static final String DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Lock"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Lock"),
080                            true);
081            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
082                                    "lock.expiration.time.com.liferay.portal.model.Lock"));
083    
084            public LockModelImpl() {
085            }
086    
087            public long getPrimaryKey() {
088                    return _lockId;
089            }
090    
091            public void setPrimaryKey(long pk) {
092                    setLockId(pk);
093            }
094    
095            public Serializable getPrimaryKeyObj() {
096                    return new Long(_lockId);
097            }
098    
099            public String getUuid() {
100                    if (_uuid == null) {
101                            return StringPool.BLANK;
102                    }
103                    else {
104                            return _uuid;
105                    }
106            }
107    
108            public void setUuid(String uuid) {
109                    _uuid = uuid;
110            }
111    
112            public long getLockId() {
113                    return _lockId;
114            }
115    
116            public void setLockId(long lockId) {
117                    _lockId = lockId;
118            }
119    
120            public long getCompanyId() {
121                    return _companyId;
122            }
123    
124            public void setCompanyId(long companyId) {
125                    _companyId = companyId;
126            }
127    
128            public long getUserId() {
129                    return _userId;
130            }
131    
132            public void setUserId(long userId) {
133                    _userId = userId;
134            }
135    
136            public String getUserUuid() throws SystemException {
137                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
138            }
139    
140            public void setUserUuid(String userUuid) {
141                    _userUuid = userUuid;
142            }
143    
144            public String getUserName() {
145                    if (_userName == null) {
146                            return StringPool.BLANK;
147                    }
148                    else {
149                            return _userName;
150                    }
151            }
152    
153            public void setUserName(String userName) {
154                    _userName = userName;
155            }
156    
157            public Date getCreateDate() {
158                    return _createDate;
159            }
160    
161            public void setCreateDate(Date createDate) {
162                    _createDate = createDate;
163            }
164    
165            public String getClassName() {
166                    if (_className == null) {
167                            return StringPool.BLANK;
168                    }
169                    else {
170                            return _className;
171                    }
172            }
173    
174            public void setClassName(String className) {
175                    if (_originalClassName == null) {
176                            _originalClassName = _className;
177                    }
178    
179                    _className = className;
180            }
181    
182            public String getOriginalClassName() {
183                    return GetterUtil.getString(_originalClassName);
184            }
185    
186            public String getKey() {
187                    if (_key == null) {
188                            return StringPool.BLANK;
189                    }
190                    else {
191                            return _key;
192                    }
193            }
194    
195            public void setKey(String key) {
196                    if (_originalKey == null) {
197                            _originalKey = _key;
198                    }
199    
200                    _key = key;
201            }
202    
203            public String getOriginalKey() {
204                    return GetterUtil.getString(_originalKey);
205            }
206    
207            public String getOwner() {
208                    if (_owner == null) {
209                            return StringPool.BLANK;
210                    }
211                    else {
212                            return _owner;
213                    }
214            }
215    
216            public void setOwner(String owner) {
217                    _owner = owner;
218            }
219    
220            public boolean getInheritable() {
221                    return _inheritable;
222            }
223    
224            public boolean isInheritable() {
225                    return _inheritable;
226            }
227    
228            public void setInheritable(boolean inheritable) {
229                    _inheritable = inheritable;
230            }
231    
232            public Date getExpirationDate() {
233                    return _expirationDate;
234            }
235    
236            public void setExpirationDate(Date expirationDate) {
237                    _expirationDate = expirationDate;
238            }
239    
240            public Lock toEscapedModel() {
241                    if (isEscapedModel()) {
242                            return (Lock)this;
243                    }
244                    else {
245                            return (Lock)Proxy.newProxyInstance(Lock.class.getClassLoader(),
246                                    new Class[] { Lock.class }, new AutoEscapeBeanHandler(this));
247                    }
248            }
249    
250            public ExpandoBridge getExpandoBridge() {
251                    if (_expandoBridge == null) {
252                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
253                                            Lock.class.getName(), getPrimaryKey());
254                    }
255    
256                    return _expandoBridge;
257            }
258    
259            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
260                    getExpandoBridge().setAttributes(serviceContext);
261            }
262    
263            public Object clone() {
264                    LockImpl lockImpl = new LockImpl();
265    
266                    lockImpl.setUuid(getUuid());
267    
268                    lockImpl.setLockId(getLockId());
269    
270                    lockImpl.setCompanyId(getCompanyId());
271    
272                    lockImpl.setUserId(getUserId());
273    
274                    lockImpl.setUserName(getUserName());
275    
276                    lockImpl.setCreateDate(getCreateDate());
277    
278                    lockImpl.setClassName(getClassName());
279    
280                    LockModelImpl lockModelImpl = lockImpl;
281    
282                    lockModelImpl._originalClassName = lockModelImpl._className;
283    
284                    lockImpl.setKey(getKey());
285    
286                    lockModelImpl._originalKey = lockModelImpl._key;
287    
288                    lockImpl.setOwner(getOwner());
289    
290                    lockImpl.setInheritable(getInheritable());
291    
292                    lockImpl.setExpirationDate(getExpirationDate());
293    
294                    return lockImpl;
295            }
296    
297            public int compareTo(Lock lock) {
298                    long pk = lock.getPrimaryKey();
299    
300                    if (getPrimaryKey() < pk) {
301                            return -1;
302                    }
303                    else if (getPrimaryKey() > pk) {
304                            return 1;
305                    }
306                    else {
307                            return 0;
308                    }
309            }
310    
311            public boolean equals(Object obj) {
312                    if (obj == null) {
313                            return false;
314                    }
315    
316                    Lock lock = null;
317    
318                    try {
319                            lock = (Lock)obj;
320                    }
321                    catch (ClassCastException cce) {
322                            return false;
323                    }
324    
325                    long pk = lock.getPrimaryKey();
326    
327                    if (getPrimaryKey() == pk) {
328                            return true;
329                    }
330                    else {
331                            return false;
332                    }
333            }
334    
335            public int hashCode() {
336                    return (int)getPrimaryKey();
337            }
338    
339            public String toString() {
340                    StringBundler sb = new StringBundler(23);
341    
342                    sb.append("{uuid=");
343                    sb.append(getUuid());
344                    sb.append(", lockId=");
345                    sb.append(getLockId());
346                    sb.append(", companyId=");
347                    sb.append(getCompanyId());
348                    sb.append(", userId=");
349                    sb.append(getUserId());
350                    sb.append(", userName=");
351                    sb.append(getUserName());
352                    sb.append(", createDate=");
353                    sb.append(getCreateDate());
354                    sb.append(", className=");
355                    sb.append(getClassName());
356                    sb.append(", key=");
357                    sb.append(getKey());
358                    sb.append(", owner=");
359                    sb.append(getOwner());
360                    sb.append(", inheritable=");
361                    sb.append(getInheritable());
362                    sb.append(", expirationDate=");
363                    sb.append(getExpirationDate());
364                    sb.append("}");
365    
366                    return sb.toString();
367            }
368    
369            public String toXmlString() {
370                    StringBundler sb = new StringBundler(37);
371    
372                    sb.append("<model><model-name>");
373                    sb.append("com.liferay.portal.model.Lock");
374                    sb.append("</model-name>");
375    
376                    sb.append(
377                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
378                    sb.append(getUuid());
379                    sb.append("]]></column-value></column>");
380                    sb.append(
381                            "<column><column-name>lockId</column-name><column-value><![CDATA[");
382                    sb.append(getLockId());
383                    sb.append("]]></column-value></column>");
384                    sb.append(
385                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
386                    sb.append(getCompanyId());
387                    sb.append("]]></column-value></column>");
388                    sb.append(
389                            "<column><column-name>userId</column-name><column-value><![CDATA[");
390                    sb.append(getUserId());
391                    sb.append("]]></column-value></column>");
392                    sb.append(
393                            "<column><column-name>userName</column-name><column-value><![CDATA[");
394                    sb.append(getUserName());
395                    sb.append("]]></column-value></column>");
396                    sb.append(
397                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
398                    sb.append(getCreateDate());
399                    sb.append("]]></column-value></column>");
400                    sb.append(
401                            "<column><column-name>className</column-name><column-value><![CDATA[");
402                    sb.append(getClassName());
403                    sb.append("]]></column-value></column>");
404                    sb.append(
405                            "<column><column-name>key</column-name><column-value><![CDATA[");
406                    sb.append(getKey());
407                    sb.append("]]></column-value></column>");
408                    sb.append(
409                            "<column><column-name>owner</column-name><column-value><![CDATA[");
410                    sb.append(getOwner());
411                    sb.append("]]></column-value></column>");
412                    sb.append(
413                            "<column><column-name>inheritable</column-name><column-value><![CDATA[");
414                    sb.append(getInheritable());
415                    sb.append("]]></column-value></column>");
416                    sb.append(
417                            "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
418                    sb.append(getExpirationDate());
419                    sb.append("]]></column-value></column>");
420    
421                    sb.append("</model>");
422    
423                    return sb.toString();
424            }
425    
426            private String _uuid;
427            private long _lockId;
428            private long _companyId;
429            private long _userId;
430            private String _userUuid;
431            private String _userName;
432            private Date _createDate;
433            private String _className;
434            private String _originalClassName;
435            private String _key;
436            private String _originalKey;
437            private String _owner;
438            private boolean _inheritable;
439            private Date _expirationDate;
440            private transient ExpandoBridge _expandoBridge;
441    }