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