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