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