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