001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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                    _className = className;
176    
177                    if (_originalClassName == null) {
178                            _originalClassName = className;
179                    }
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                    _key = key;
197    
198                    if (_originalKey == null) {
199                            _originalKey = key;
200                    }
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 clone = new LockImpl();
265    
266                    clone.setUuid(getUuid());
267                    clone.setLockId(getLockId());
268                    clone.setCompanyId(getCompanyId());
269                    clone.setUserId(getUserId());
270                    clone.setUserName(getUserName());
271                    clone.setCreateDate(getCreateDate());
272                    clone.setClassName(getClassName());
273                    clone.setKey(getKey());
274                    clone.setOwner(getOwner());
275                    clone.setInheritable(getInheritable());
276                    clone.setExpirationDate(getExpirationDate());
277    
278                    return clone;
279            }
280    
281            public int compareTo(Lock lock) {
282                    long pk = lock.getPrimaryKey();
283    
284                    if (getPrimaryKey() < pk) {
285                            return -1;
286                    }
287                    else if (getPrimaryKey() > pk) {
288                            return 1;
289                    }
290                    else {
291                            return 0;
292                    }
293            }
294    
295            public boolean equals(Object obj) {
296                    if (obj == null) {
297                            return false;
298                    }
299    
300                    Lock lock = null;
301    
302                    try {
303                            lock = (Lock)obj;
304                    }
305                    catch (ClassCastException cce) {
306                            return false;
307                    }
308    
309                    long pk = lock.getPrimaryKey();
310    
311                    if (getPrimaryKey() == pk) {
312                            return true;
313                    }
314                    else {
315                            return false;
316                    }
317            }
318    
319            public int hashCode() {
320                    return (int)getPrimaryKey();
321            }
322    
323            public String toString() {
324                    StringBundler sb = new StringBundler(23);
325    
326                    sb.append("{uuid=");
327                    sb.append(getUuid());
328                    sb.append(", lockId=");
329                    sb.append(getLockId());
330                    sb.append(", companyId=");
331                    sb.append(getCompanyId());
332                    sb.append(", userId=");
333                    sb.append(getUserId());
334                    sb.append(", userName=");
335                    sb.append(getUserName());
336                    sb.append(", createDate=");
337                    sb.append(getCreateDate());
338                    sb.append(", className=");
339                    sb.append(getClassName());
340                    sb.append(", key=");
341                    sb.append(getKey());
342                    sb.append(", owner=");
343                    sb.append(getOwner());
344                    sb.append(", inheritable=");
345                    sb.append(getInheritable());
346                    sb.append(", expirationDate=");
347                    sb.append(getExpirationDate());
348                    sb.append("}");
349    
350                    return sb.toString();
351            }
352    
353            public String toXmlString() {
354                    StringBundler sb = new StringBundler(37);
355    
356                    sb.append("<model><model-name>");
357                    sb.append("com.liferay.portal.model.Lock");
358                    sb.append("</model-name>");
359    
360                    sb.append(
361                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
362                    sb.append(getUuid());
363                    sb.append("]]></column-value></column>");
364                    sb.append(
365                            "<column><column-name>lockId</column-name><column-value><![CDATA[");
366                    sb.append(getLockId());
367                    sb.append("]]></column-value></column>");
368                    sb.append(
369                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
370                    sb.append(getCompanyId());
371                    sb.append("]]></column-value></column>");
372                    sb.append(
373                            "<column><column-name>userId</column-name><column-value><![CDATA[");
374                    sb.append(getUserId());
375                    sb.append("]]></column-value></column>");
376                    sb.append(
377                            "<column><column-name>userName</column-name><column-value><![CDATA[");
378                    sb.append(getUserName());
379                    sb.append("]]></column-value></column>");
380                    sb.append(
381                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
382                    sb.append(getCreateDate());
383                    sb.append("]]></column-value></column>");
384                    sb.append(
385                            "<column><column-name>className</column-name><column-value><![CDATA[");
386                    sb.append(getClassName());
387                    sb.append("]]></column-value></column>");
388                    sb.append(
389                            "<column><column-name>key</column-name><column-value><![CDATA[");
390                    sb.append(getKey());
391                    sb.append("]]></column-value></column>");
392                    sb.append(
393                            "<column><column-name>owner</column-name><column-value><![CDATA[");
394                    sb.append(getOwner());
395                    sb.append("]]></column-value></column>");
396                    sb.append(
397                            "<column><column-name>inheritable</column-name><column-value><![CDATA[");
398                    sb.append(getInheritable());
399                    sb.append("]]></column-value></column>");
400                    sb.append(
401                            "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
402                    sb.append(getExpirationDate());
403                    sb.append("]]></column-value></column>");
404    
405                    sb.append("</model>");
406    
407                    return sb.toString();
408            }
409    
410            private String _uuid;
411            private long _lockId;
412            private long _companyId;
413            private long _userId;
414            private String _userUuid;
415            private String _userName;
416            private Date _createDate;
417            private String _className;
418            private String _originalClassName;
419            private String _key;
420            private String _originalKey;
421            private String _owner;
422            private boolean _inheritable;
423            private Date _expirationDate;
424            private transient ExpandoBridge _expandoBridge;
425    }