1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.kernel.util.StringPool;
22  import com.liferay.portal.model.Lock;
23  import com.liferay.portal.model.LockSoap;
24  import com.liferay.portal.service.ServiceContext;
25  import com.liferay.portal.util.PortalUtil;
26  
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <a href="LockModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This interface is a model that represents the Lock_ table in the
50   * database.
51   * </p>
52   *
53   * @author    Brian Wing Shun Chan
54   * @see       LockImpl
55   * @see       com.liferay.portal.model.Lock
56   * @see       com.liferay.portal.model.LockModel
57   * @generated
58   */
59  public class LockModelImpl extends BaseModelImpl<Lock> {
60      public static final String TABLE_NAME = "Lock_";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "uuid_", new Integer(Types.VARCHAR) },
63              { "lockId", new Integer(Types.BIGINT) },
64              { "companyId", new Integer(Types.BIGINT) },
65              { "userId", new Integer(Types.BIGINT) },
66              { "userName", new Integer(Types.VARCHAR) },
67              { "createDate", new Integer(Types.TIMESTAMP) },
68              { "className", new Integer(Types.VARCHAR) },
69              { "key_", new Integer(Types.VARCHAR) },
70              { "owner", new Integer(Types.VARCHAR) },
71              { "inheritable", new Integer(Types.BOOLEAN) },
72              { "expirationDate", new Integer(Types.TIMESTAMP) }
73          };
74      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)";
75      public static final String TABLE_SQL_DROP = "drop table Lock_";
76      public static final String DATA_SOURCE = "liferayDataSource";
77      public static final String SESSION_FACTORY = "liferaySessionFactory";
78      public static final String TX_MANAGER = "liferayTransactionManager";
79      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.entity.cache.enabled.com.liferay.portal.model.Lock"),
81              true);
82      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portal.model.Lock"),
84              true);
85  
86      public static Lock toModel(LockSoap soapModel) {
87          Lock model = new LockImpl();
88  
89          model.setUuid(soapModel.getUuid());
90          model.setLockId(soapModel.getLockId());
91          model.setCompanyId(soapModel.getCompanyId());
92          model.setUserId(soapModel.getUserId());
93          model.setUserName(soapModel.getUserName());
94          model.setCreateDate(soapModel.getCreateDate());
95          model.setClassName(soapModel.getClassName());
96          model.setKey(soapModel.getKey());
97          model.setOwner(soapModel.getOwner());
98          model.setInheritable(soapModel.getInheritable());
99          model.setExpirationDate(soapModel.getExpirationDate());
100 
101         return model;
102     }
103 
104     public static List<Lock> toModels(LockSoap[] soapModels) {
105         List<Lock> models = new ArrayList<Lock>(soapModels.length);
106 
107         for (LockSoap soapModel : soapModels) {
108             models.add(toModel(soapModel));
109         }
110 
111         return models;
112     }
113 
114     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115                 "lock.expiration.time.com.liferay.portal.model.Lock"));
116 
117     public LockModelImpl() {
118     }
119 
120     public long getPrimaryKey() {
121         return _lockId;
122     }
123 
124     public void setPrimaryKey(long pk) {
125         setLockId(pk);
126     }
127 
128     public Serializable getPrimaryKeyObj() {
129         return new Long(_lockId);
130     }
131 
132     public String getUuid() {
133         if (_uuid == null) {
134             return StringPool.BLANK;
135         }
136         else {
137             return _uuid;
138         }
139     }
140 
141     public void setUuid(String uuid) {
142         _uuid = uuid;
143     }
144 
145     public long getLockId() {
146         return _lockId;
147     }
148 
149     public void setLockId(long lockId) {
150         _lockId = lockId;
151     }
152 
153     public long getCompanyId() {
154         return _companyId;
155     }
156 
157     public void setCompanyId(long companyId) {
158         _companyId = companyId;
159     }
160 
161     public long getUserId() {
162         return _userId;
163     }
164 
165     public void setUserId(long userId) {
166         _userId = userId;
167     }
168 
169     public String getUserUuid() throws SystemException {
170         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
171     }
172 
173     public void setUserUuid(String userUuid) {
174         _userUuid = userUuid;
175     }
176 
177     public String getUserName() {
178         if (_userName == null) {
179             return StringPool.BLANK;
180         }
181         else {
182             return _userName;
183         }
184     }
185 
186     public void setUserName(String userName) {
187         _userName = userName;
188     }
189 
190     public Date getCreateDate() {
191         return _createDate;
192     }
193 
194     public void setCreateDate(Date createDate) {
195         _createDate = createDate;
196     }
197 
198     public String getClassName() {
199         if (_className == null) {
200             return StringPool.BLANK;
201         }
202         else {
203             return _className;
204         }
205     }
206 
207     public void setClassName(String className) {
208         _className = className;
209 
210         if (_originalClassName == null) {
211             _originalClassName = className;
212         }
213     }
214 
215     public String getOriginalClassName() {
216         return GetterUtil.getString(_originalClassName);
217     }
218 
219     public String getKey() {
220         if (_key == null) {
221             return StringPool.BLANK;
222         }
223         else {
224             return _key;
225         }
226     }
227 
228     public void setKey(String key) {
229         _key = key;
230 
231         if (_originalKey == null) {
232             _originalKey = key;
233         }
234     }
235 
236     public String getOriginalKey() {
237         return GetterUtil.getString(_originalKey);
238     }
239 
240     public String getOwner() {
241         if (_owner == null) {
242             return StringPool.BLANK;
243         }
244         else {
245             return _owner;
246         }
247     }
248 
249     public void setOwner(String owner) {
250         _owner = owner;
251     }
252 
253     public boolean getInheritable() {
254         return _inheritable;
255     }
256 
257     public boolean isInheritable() {
258         return _inheritable;
259     }
260 
261     public void setInheritable(boolean inheritable) {
262         _inheritable = inheritable;
263     }
264 
265     public Date getExpirationDate() {
266         return _expirationDate;
267     }
268 
269     public void setExpirationDate(Date expirationDate) {
270         _expirationDate = expirationDate;
271     }
272 
273     public Lock toEscapedModel() {
274         if (isEscapedModel()) {
275             return (Lock)this;
276         }
277         else {
278             return (Lock)Proxy.newProxyInstance(Lock.class.getClassLoader(),
279                 new Class[] { Lock.class }, new AutoEscapeBeanHandler(this));
280         }
281     }
282 
283     public ExpandoBridge getExpandoBridge() {
284         if (_expandoBridge == null) {
285             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(Lock.class.getName(),
286                     getPrimaryKey());
287         }
288 
289         return _expandoBridge;
290     }
291 
292     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
293         getExpandoBridge().setAttributes(serviceContext);
294     }
295 
296     public Object clone() {
297         LockImpl clone = new LockImpl();
298 
299         clone.setUuid(getUuid());
300         clone.setLockId(getLockId());
301         clone.setCompanyId(getCompanyId());
302         clone.setUserId(getUserId());
303         clone.setUserName(getUserName());
304         clone.setCreateDate(getCreateDate());
305         clone.setClassName(getClassName());
306         clone.setKey(getKey());
307         clone.setOwner(getOwner());
308         clone.setInheritable(getInheritable());
309         clone.setExpirationDate(getExpirationDate());
310 
311         return clone;
312     }
313 
314     public int compareTo(Lock lock) {
315         long pk = lock.getPrimaryKey();
316 
317         if (getPrimaryKey() < pk) {
318             return -1;
319         }
320         else if (getPrimaryKey() > pk) {
321             return 1;
322         }
323         else {
324             return 0;
325         }
326     }
327 
328     public boolean equals(Object obj) {
329         if (obj == null) {
330             return false;
331         }
332 
333         Lock lock = null;
334 
335         try {
336             lock = (Lock)obj;
337         }
338         catch (ClassCastException cce) {
339             return false;
340         }
341 
342         long pk = lock.getPrimaryKey();
343 
344         if (getPrimaryKey() == pk) {
345             return true;
346         }
347         else {
348             return false;
349         }
350     }
351 
352     public int hashCode() {
353         return (int)getPrimaryKey();
354     }
355 
356     public String toString() {
357         StringBundler sb = new StringBundler(23);
358 
359         sb.append("{uuid=");
360         sb.append(getUuid());
361         sb.append(", lockId=");
362         sb.append(getLockId());
363         sb.append(", companyId=");
364         sb.append(getCompanyId());
365         sb.append(", userId=");
366         sb.append(getUserId());
367         sb.append(", userName=");
368         sb.append(getUserName());
369         sb.append(", createDate=");
370         sb.append(getCreateDate());
371         sb.append(", className=");
372         sb.append(getClassName());
373         sb.append(", key=");
374         sb.append(getKey());
375         sb.append(", owner=");
376         sb.append(getOwner());
377         sb.append(", inheritable=");
378         sb.append(getInheritable());
379         sb.append(", expirationDate=");
380         sb.append(getExpirationDate());
381         sb.append("}");
382 
383         return sb.toString();
384     }
385 
386     public String toXmlString() {
387         StringBundler sb = new StringBundler(37);
388 
389         sb.append("<model><model-name>");
390         sb.append("com.liferay.portal.model.Lock");
391         sb.append("</model-name>");
392 
393         sb.append(
394             "<column><column-name>uuid</column-name><column-value><![CDATA[");
395         sb.append(getUuid());
396         sb.append("]]></column-value></column>");
397         sb.append(
398             "<column><column-name>lockId</column-name><column-value><![CDATA[");
399         sb.append(getLockId());
400         sb.append("]]></column-value></column>");
401         sb.append(
402             "<column><column-name>companyId</column-name><column-value><![CDATA[");
403         sb.append(getCompanyId());
404         sb.append("]]></column-value></column>");
405         sb.append(
406             "<column><column-name>userId</column-name><column-value><![CDATA[");
407         sb.append(getUserId());
408         sb.append("]]></column-value></column>");
409         sb.append(
410             "<column><column-name>userName</column-name><column-value><![CDATA[");
411         sb.append(getUserName());
412         sb.append("]]></column-value></column>");
413         sb.append(
414             "<column><column-name>createDate</column-name><column-value><![CDATA[");
415         sb.append(getCreateDate());
416         sb.append("]]></column-value></column>");
417         sb.append(
418             "<column><column-name>className</column-name><column-value><![CDATA[");
419         sb.append(getClassName());
420         sb.append("]]></column-value></column>");
421         sb.append(
422             "<column><column-name>key</column-name><column-value><![CDATA[");
423         sb.append(getKey());
424         sb.append("]]></column-value></column>");
425         sb.append(
426             "<column><column-name>owner</column-name><column-value><![CDATA[");
427         sb.append(getOwner());
428         sb.append("]]></column-value></column>");
429         sb.append(
430             "<column><column-name>inheritable</column-name><column-value><![CDATA[");
431         sb.append(getInheritable());
432         sb.append("]]></column-value></column>");
433         sb.append(
434             "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
435         sb.append(getExpirationDate());
436         sb.append("]]></column-value></column>");
437 
438         sb.append("</model>");
439 
440         return sb.toString();
441     }
442 
443     private String _uuid;
444     private long _lockId;
445     private long _companyId;
446     private long _userId;
447     private String _userUuid;
448     private String _userName;
449     private Date _createDate;
450     private String _className;
451     private String _originalClassName;
452     private String _key;
453     private String _originalKey;
454     private String _owner;
455     private boolean _inheritable;
456     private Date _expirationDate;
457     private transient ExpandoBridge _expandoBridge;
458 }