1   /**
2    * Copyright (c) 2000-2008 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.portlet.documentlibrary.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.portlet.documentlibrary.model.DLFileEntry;
32  import com.liferay.portlet.documentlibrary.model.DLFileEntrySoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="DLFileEntryModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>DLFileEntry</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.documentlibrary.service.model.DLFileEntry
60   * @see com.liferay.portlet.documentlibrary.service.model.DLFileEntryModel
61   * @see com.liferay.portlet.documentlibrary.service.model.impl.DLFileEntryImpl
62   *
63   */
64  public class DLFileEntryModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "DLFileEntry";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "uuid_", new Integer(Types.VARCHAR) },
68              
69  
70              { "fileEntryId", new Integer(Types.BIGINT) },
71              
72  
73              { "companyId", new Integer(Types.BIGINT) },
74              
75  
76              { "userId", new Integer(Types.BIGINT) },
77              
78  
79              { "userName", new Integer(Types.VARCHAR) },
80              
81  
82              { "versionUserId", new Integer(Types.BIGINT) },
83              
84  
85              { "versionUserName", new Integer(Types.VARCHAR) },
86              
87  
88              { "createDate", new Integer(Types.TIMESTAMP) },
89              
90  
91              { "modifiedDate", new Integer(Types.TIMESTAMP) },
92              
93  
94              { "folderId", new Integer(Types.BIGINT) },
95              
96  
97              { "name", new Integer(Types.VARCHAR) },
98              
99  
100             { "title", new Integer(Types.VARCHAR) },
101             
102 
103             { "description", new Integer(Types.VARCHAR) },
104             
105 
106             { "version", new Integer(Types.DOUBLE) },
107             
108 
109             { "size_", new Integer(Types.INTEGER) },
110             
111 
112             { "readCount", new Integer(Types.INTEGER) },
113             
114 
115             { "extraSettings", new Integer(Types.CLOB) }
116         };
117     public static final String TABLE_SQL_CREATE = "create table DLFileEntry (uuid_ VARCHAR(75) null,fileEntryId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,versionUserId LONG,versionUserName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,folderId LONG,name VARCHAR(300) null,title VARCHAR(300) null,description STRING null,version DOUBLE,size_ INTEGER,readCount INTEGER,extraSettings TEXT null)";
118     public static final String TABLE_SQL_DROP = "drop table DLFileEntry";
119     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
120                 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
121             true);
122 
123     public static DLFileEntry toModel(DLFileEntrySoap soapModel) {
124         DLFileEntry model = new DLFileEntryImpl();
125 
126         model.setUuid(soapModel.getUuid());
127         model.setFileEntryId(soapModel.getFileEntryId());
128         model.setCompanyId(soapModel.getCompanyId());
129         model.setUserId(soapModel.getUserId());
130         model.setUserName(soapModel.getUserName());
131         model.setVersionUserId(soapModel.getVersionUserId());
132         model.setVersionUserName(soapModel.getVersionUserName());
133         model.setCreateDate(soapModel.getCreateDate());
134         model.setModifiedDate(soapModel.getModifiedDate());
135         model.setFolderId(soapModel.getFolderId());
136         model.setName(soapModel.getName());
137         model.setTitle(soapModel.getTitle());
138         model.setDescription(soapModel.getDescription());
139         model.setVersion(soapModel.getVersion());
140         model.setSize(soapModel.getSize());
141         model.setReadCount(soapModel.getReadCount());
142         model.setExtraSettings(soapModel.getExtraSettings());
143 
144         return model;
145     }
146 
147     public static List<DLFileEntry> toModels(DLFileEntrySoap[] soapModels) {
148         List<DLFileEntry> models = new ArrayList<DLFileEntry>(soapModels.length);
149 
150         for (DLFileEntrySoap soapModel : soapModels) {
151             models.add(toModel(soapModel));
152         }
153 
154         return models;
155     }
156 
157     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
158                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileEntry"));
159 
160     public DLFileEntryModelImpl() {
161     }
162 
163     public long getPrimaryKey() {
164         return _fileEntryId;
165     }
166 
167     public void setPrimaryKey(long pk) {
168         setFileEntryId(pk);
169     }
170 
171     public Serializable getPrimaryKeyObj() {
172         return new Long(_fileEntryId);
173     }
174 
175     public String getUuid() {
176         return GetterUtil.getString(_uuid);
177     }
178 
179     public void setUuid(String uuid) {
180         if ((uuid != null) && (uuid != _uuid)) {
181             _uuid = uuid;
182         }
183     }
184 
185     public long getFileEntryId() {
186         return _fileEntryId;
187     }
188 
189     public void setFileEntryId(long fileEntryId) {
190         if (fileEntryId != _fileEntryId) {
191             _fileEntryId = fileEntryId;
192         }
193     }
194 
195     public long getCompanyId() {
196         return _companyId;
197     }
198 
199     public void setCompanyId(long companyId) {
200         if (companyId != _companyId) {
201             _companyId = companyId;
202         }
203     }
204 
205     public long getUserId() {
206         return _userId;
207     }
208 
209     public void setUserId(long userId) {
210         if (userId != _userId) {
211             _userId = userId;
212         }
213     }
214 
215     public String getUserName() {
216         return GetterUtil.getString(_userName);
217     }
218 
219     public void setUserName(String userName) {
220         if (((userName == null) && (_userName != null)) ||
221                 ((userName != null) && (_userName == null)) ||
222                 ((userName != null) && (_userName != null) &&
223                 !userName.equals(_userName))) {
224             _userName = userName;
225         }
226     }
227 
228     public long getVersionUserId() {
229         return _versionUserId;
230     }
231 
232     public void setVersionUserId(long versionUserId) {
233         if (versionUserId != _versionUserId) {
234             _versionUserId = versionUserId;
235         }
236     }
237 
238     public String getVersionUserName() {
239         return GetterUtil.getString(_versionUserName);
240     }
241 
242     public void setVersionUserName(String versionUserName) {
243         if (((versionUserName == null) && (_versionUserName != null)) ||
244                 ((versionUserName != null) && (_versionUserName == null)) ||
245                 ((versionUserName != null) && (_versionUserName != null) &&
246                 !versionUserName.equals(_versionUserName))) {
247             _versionUserName = versionUserName;
248         }
249     }
250 
251     public Date getCreateDate() {
252         return _createDate;
253     }
254 
255     public void setCreateDate(Date createDate) {
256         if (((createDate == null) && (_createDate != null)) ||
257                 ((createDate != null) && (_createDate == null)) ||
258                 ((createDate != null) && (_createDate != null) &&
259                 !createDate.equals(_createDate))) {
260             _createDate = createDate;
261         }
262     }
263 
264     public Date getModifiedDate() {
265         return _modifiedDate;
266     }
267 
268     public void setModifiedDate(Date modifiedDate) {
269         if (((modifiedDate == null) && (_modifiedDate != null)) ||
270                 ((modifiedDate != null) && (_modifiedDate == null)) ||
271                 ((modifiedDate != null) && (_modifiedDate != null) &&
272                 !modifiedDate.equals(_modifiedDate))) {
273             _modifiedDate = modifiedDate;
274         }
275     }
276 
277     public long getFolderId() {
278         return _folderId;
279     }
280 
281     public void setFolderId(long folderId) {
282         if (folderId != _folderId) {
283             _folderId = folderId;
284         }
285     }
286 
287     public String getName() {
288         return GetterUtil.getString(_name);
289     }
290 
291     public void setName(String name) {
292         if (((name == null) && (_name != null)) ||
293                 ((name != null) && (_name == null)) ||
294                 ((name != null) && (_name != null) && !name.equals(_name))) {
295             _name = name;
296         }
297     }
298 
299     public String getTitle() {
300         return GetterUtil.getString(_title);
301     }
302 
303     public void setTitle(String title) {
304         if (((title == null) && (_title != null)) ||
305                 ((title != null) && (_title == null)) ||
306                 ((title != null) && (_title != null) && !title.equals(_title))) {
307             _title = title;
308         }
309     }
310 
311     public String getDescription() {
312         return GetterUtil.getString(_description);
313     }
314 
315     public void setDescription(String description) {
316         if (((description == null) && (_description != null)) ||
317                 ((description != null) && (_description == null)) ||
318                 ((description != null) && (_description != null) &&
319                 !description.equals(_description))) {
320             _description = description;
321         }
322     }
323 
324     public double getVersion() {
325         return _version;
326     }
327 
328     public void setVersion(double version) {
329         if (version != _version) {
330             _version = version;
331         }
332     }
333 
334     public int getSize() {
335         return _size;
336     }
337 
338     public void setSize(int size) {
339         if (size != _size) {
340             _size = size;
341         }
342     }
343 
344     public int getReadCount() {
345         return _readCount;
346     }
347 
348     public void setReadCount(int readCount) {
349         if (readCount != _readCount) {
350             _readCount = readCount;
351         }
352     }
353 
354     public String getExtraSettings() {
355         return GetterUtil.getString(_extraSettings);
356     }
357 
358     public void setExtraSettings(String extraSettings) {
359         if (((extraSettings == null) && (_extraSettings != null)) ||
360                 ((extraSettings != null) && (_extraSettings == null)) ||
361                 ((extraSettings != null) && (_extraSettings != null) &&
362                 !extraSettings.equals(_extraSettings))) {
363             _extraSettings = extraSettings;
364         }
365     }
366 
367     public DLFileEntry toEscapedModel() {
368         if (isEscapedModel()) {
369             return (DLFileEntry)this;
370         }
371         else {
372             DLFileEntry model = new DLFileEntryImpl();
373 
374             model.setEscapedModel(true);
375 
376             model.setUuid(HtmlUtil.escape(getUuid()));
377             model.setFileEntryId(getFileEntryId());
378             model.setCompanyId(getCompanyId());
379             model.setUserId(getUserId());
380             model.setUserName(HtmlUtil.escape(getUserName()));
381             model.setVersionUserId(getVersionUserId());
382             model.setVersionUserName(HtmlUtil.escape(getVersionUserName()));
383             model.setCreateDate(getCreateDate());
384             model.setModifiedDate(getModifiedDate());
385             model.setFolderId(getFolderId());
386             model.setName(HtmlUtil.escape(getName()));
387             model.setTitle(HtmlUtil.escape(getTitle()));
388             model.setDescription(HtmlUtil.escape(getDescription()));
389             model.setVersion(getVersion());
390             model.setSize(getSize());
391             model.setReadCount(getReadCount());
392             model.setExtraSettings(HtmlUtil.escape(getExtraSettings()));
393 
394             model = (DLFileEntry)Proxy.newProxyInstance(DLFileEntry.class.getClassLoader(),
395                     new Class[] { DLFileEntry.class },
396                     new ReadOnlyBeanHandler(model));
397 
398             return model;
399         }
400     }
401 
402     public Object clone() {
403         DLFileEntryImpl clone = new DLFileEntryImpl();
404 
405         clone.setUuid(getUuid());
406         clone.setFileEntryId(getFileEntryId());
407         clone.setCompanyId(getCompanyId());
408         clone.setUserId(getUserId());
409         clone.setUserName(getUserName());
410         clone.setVersionUserId(getVersionUserId());
411         clone.setVersionUserName(getVersionUserName());
412         clone.setCreateDate(getCreateDate());
413         clone.setModifiedDate(getModifiedDate());
414         clone.setFolderId(getFolderId());
415         clone.setName(getName());
416         clone.setTitle(getTitle());
417         clone.setDescription(getDescription());
418         clone.setVersion(getVersion());
419         clone.setSize(getSize());
420         clone.setReadCount(getReadCount());
421         clone.setExtraSettings(getExtraSettings());
422 
423         return clone;
424     }
425 
426     public int compareTo(Object obj) {
427         if (obj == null) {
428             return -1;
429         }
430 
431         DLFileEntryImpl dlFileEntry = (DLFileEntryImpl)obj;
432 
433         int value = 0;
434 
435         if (getFolderId() < dlFileEntry.getFolderId()) {
436             value = -1;
437         }
438         else if (getFolderId() > dlFileEntry.getFolderId()) {
439             value = 1;
440         }
441         else {
442             value = 0;
443         }
444 
445         if (value != 0) {
446             return value;
447         }
448 
449         value = getName().compareTo(dlFileEntry.getName());
450 
451         if (value != 0) {
452             return value;
453         }
454 
455         return 0;
456     }
457 
458     public boolean equals(Object obj) {
459         if (obj == null) {
460             return false;
461         }
462 
463         DLFileEntryImpl dlFileEntry = null;
464 
465         try {
466             dlFileEntry = (DLFileEntryImpl)obj;
467         }
468         catch (ClassCastException cce) {
469             return false;
470         }
471 
472         long pk = dlFileEntry.getPrimaryKey();
473 
474         if (getPrimaryKey() == pk) {
475             return true;
476         }
477         else {
478             return false;
479         }
480     }
481 
482     public int hashCode() {
483         return (int)getPrimaryKey();
484     }
485 
486     private String _uuid;
487     private long _fileEntryId;
488     private long _companyId;
489     private long _userId;
490     private String _userName;
491     private long _versionUserId;
492     private String _versionUserName;
493     private Date _createDate;
494     private Date _modifiedDate;
495     private long _folderId;
496     private String _name;
497     private String _title;
498     private String _description;
499     private double _version;
500     private int _size;
501     private int _readCount;
502     private String _extraSettings;
503 }