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.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  
30  import com.liferay.portlet.documentlibrary.model.DLFileEntry;
31  import com.liferay.portlet.documentlibrary.model.DLFileEntrySoap;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="DLFileEntryModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>DLFileEntry</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.documentlibrary.model.DLFileEntry
59   * @see com.liferay.portlet.documentlibrary.model.DLFileEntryModel
60   * @see com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl
61   *
62   */
63  public class DLFileEntryModelImpl extends BaseModelImpl<DLFileEntry> {
64      public static final String TABLE_NAME = "DLFileEntry";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "uuid_", new Integer(Types.VARCHAR) },
67              
68  
69              { "fileEntryId", new Integer(Types.BIGINT) },
70              
71  
72              { "groupId", new Integer(Types.BIGINT) },
73              
74  
75              { "companyId", new Integer(Types.BIGINT) },
76              
77  
78              { "userId", new Integer(Types.BIGINT) },
79              
80  
81              { "userName", new Integer(Types.VARCHAR) },
82              
83  
84              { "versionUserId", new Integer(Types.BIGINT) },
85              
86  
87              { "versionUserName", new Integer(Types.VARCHAR) },
88              
89  
90              { "createDate", new Integer(Types.TIMESTAMP) },
91              
92  
93              { "modifiedDate", new Integer(Types.TIMESTAMP) },
94              
95  
96              { "folderId", new Integer(Types.BIGINT) },
97              
98  
99              { "name", new Integer(Types.VARCHAR) },
100             
101 
102             { "title", new Integer(Types.VARCHAR) },
103             
104 
105             { "description", new Integer(Types.VARCHAR) },
106             
107 
108             { "version", new Integer(Types.DOUBLE) },
109             
110 
111             { "size_", new Integer(Types.INTEGER) },
112             
113 
114             { "readCount", new Integer(Types.INTEGER) },
115             
116 
117             { "extraSettings", new Integer(Types.CLOB) }
118         };
119     public static final String TABLE_SQL_CREATE = "create table DLFileEntry (uuid_ VARCHAR(75) null,fileEntryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,versionUserId LONG,versionUserName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,folderId LONG,name VARCHAR(255) null,title VARCHAR(255) null,description STRING null,version DOUBLE,size_ INTEGER,readCount INTEGER,extraSettings TEXT null)";
120     public static final String TABLE_SQL_DROP = "drop table DLFileEntry";
121     public static final String DATA_SOURCE = "liferayDataSource";
122     public static final String SESSION_FACTORY = "liferaySessionFactory";
123     public static final String TX_MANAGER = "liferayTransactionManager";
124     public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
125                 "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
126             true);
127     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
128                 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
129             true);
130 
131     public static DLFileEntry toModel(DLFileEntrySoap soapModel) {
132         DLFileEntry model = new DLFileEntryImpl();
133 
134         model.setUuid(soapModel.getUuid());
135         model.setFileEntryId(soapModel.getFileEntryId());
136         model.setGroupId(soapModel.getGroupId());
137         model.setCompanyId(soapModel.getCompanyId());
138         model.setUserId(soapModel.getUserId());
139         model.setUserName(soapModel.getUserName());
140         model.setVersionUserId(soapModel.getVersionUserId());
141         model.setVersionUserName(soapModel.getVersionUserName());
142         model.setCreateDate(soapModel.getCreateDate());
143         model.setModifiedDate(soapModel.getModifiedDate());
144         model.setFolderId(soapModel.getFolderId());
145         model.setName(soapModel.getName());
146         model.setTitle(soapModel.getTitle());
147         model.setDescription(soapModel.getDescription());
148         model.setVersion(soapModel.getVersion());
149         model.setSize(soapModel.getSize());
150         model.setReadCount(soapModel.getReadCount());
151         model.setExtraSettings(soapModel.getExtraSettings());
152 
153         return model;
154     }
155 
156     public static List<DLFileEntry> toModels(DLFileEntrySoap[] soapModels) {
157         List<DLFileEntry> models = new ArrayList<DLFileEntry>(soapModels.length);
158 
159         for (DLFileEntrySoap soapModel : soapModels) {
160             models.add(toModel(soapModel));
161         }
162 
163         return models;
164     }
165 
166     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
167                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileEntry"));
168 
169     public DLFileEntryModelImpl() {
170     }
171 
172     public long getPrimaryKey() {
173         return _fileEntryId;
174     }
175 
176     public void setPrimaryKey(long pk) {
177         setFileEntryId(pk);
178     }
179 
180     public Serializable getPrimaryKeyObj() {
181         return new Long(_fileEntryId);
182     }
183 
184     public String getUuid() {
185         return GetterUtil.getString(_uuid);
186     }
187 
188     public void setUuid(String uuid) {
189         _uuid = uuid;
190 
191         if (_originalUuid == null) {
192             _originalUuid = uuid;
193         }
194     }
195 
196     public String getOriginalUuid() {
197         return GetterUtil.getString(_originalUuid);
198     }
199 
200     public long getFileEntryId() {
201         return _fileEntryId;
202     }
203 
204     public void setFileEntryId(long fileEntryId) {
205         _fileEntryId = fileEntryId;
206     }
207 
208     public long getGroupId() {
209         return _groupId;
210     }
211 
212     public void setGroupId(long groupId) {
213         _groupId = groupId;
214 
215         if (!_setOriginalGroupId) {
216             _setOriginalGroupId = true;
217 
218             _originalGroupId = groupId;
219         }
220     }
221 
222     public long getOriginalGroupId() {
223         return _originalGroupId;
224     }
225 
226     public long getCompanyId() {
227         return _companyId;
228     }
229 
230     public void setCompanyId(long companyId) {
231         _companyId = companyId;
232     }
233 
234     public long getUserId() {
235         return _userId;
236     }
237 
238     public void setUserId(long userId) {
239         _userId = userId;
240     }
241 
242     public String getUserName() {
243         return GetterUtil.getString(_userName);
244     }
245 
246     public void setUserName(String userName) {
247         _userName = userName;
248     }
249 
250     public long getVersionUserId() {
251         return _versionUserId;
252     }
253 
254     public void setVersionUserId(long versionUserId) {
255         _versionUserId = versionUserId;
256     }
257 
258     public String getVersionUserName() {
259         return GetterUtil.getString(_versionUserName);
260     }
261 
262     public void setVersionUserName(String versionUserName) {
263         _versionUserName = versionUserName;
264     }
265 
266     public Date getCreateDate() {
267         return _createDate;
268     }
269 
270     public void setCreateDate(Date createDate) {
271         _createDate = createDate;
272     }
273 
274     public Date getModifiedDate() {
275         return _modifiedDate;
276     }
277 
278     public void setModifiedDate(Date modifiedDate) {
279         _modifiedDate = modifiedDate;
280     }
281 
282     public long getFolderId() {
283         return _folderId;
284     }
285 
286     public void setFolderId(long folderId) {
287         _folderId = folderId;
288 
289         if (!_setOriginalFolderId) {
290             _setOriginalFolderId = true;
291 
292             _originalFolderId = folderId;
293         }
294     }
295 
296     public long getOriginalFolderId() {
297         return _originalFolderId;
298     }
299 
300     public String getName() {
301         return GetterUtil.getString(_name);
302     }
303 
304     public void setName(String name) {
305         _name = name;
306 
307         if (_originalName == null) {
308             _originalName = name;
309         }
310     }
311 
312     public String getOriginalName() {
313         return GetterUtil.getString(_originalName);
314     }
315 
316     public String getTitle() {
317         return GetterUtil.getString(_title);
318     }
319 
320     public void setTitle(String title) {
321         _title = title;
322     }
323 
324     public String getDescription() {
325         return GetterUtil.getString(_description);
326     }
327 
328     public void setDescription(String description) {
329         _description = description;
330     }
331 
332     public double getVersion() {
333         return _version;
334     }
335 
336     public void setVersion(double version) {
337         _version = version;
338     }
339 
340     public int getSize() {
341         return _size;
342     }
343 
344     public void setSize(int size) {
345         _size = size;
346     }
347 
348     public int getReadCount() {
349         return _readCount;
350     }
351 
352     public void setReadCount(int readCount) {
353         _readCount = readCount;
354     }
355 
356     public String getExtraSettings() {
357         return GetterUtil.getString(_extraSettings);
358     }
359 
360     public void setExtraSettings(String extraSettings) {
361         _extraSettings = extraSettings;
362     }
363 
364     public DLFileEntry toEscapedModel() {
365         if (isEscapedModel()) {
366             return (DLFileEntry)this;
367         }
368         else {
369             DLFileEntry model = new DLFileEntryImpl();
370 
371             model.setNew(isNew());
372             model.setEscapedModel(true);
373 
374             model.setUuid(HtmlUtil.escape(getUuid()));
375             model.setFileEntryId(getFileEntryId());
376             model.setGroupId(getGroupId());
377             model.setCompanyId(getCompanyId());
378             model.setUserId(getUserId());
379             model.setUserName(HtmlUtil.escape(getUserName()));
380             model.setVersionUserId(getVersionUserId());
381             model.setVersionUserName(HtmlUtil.escape(getVersionUserName()));
382             model.setCreateDate(getCreateDate());
383             model.setModifiedDate(getModifiedDate());
384             model.setFolderId(getFolderId());
385             model.setName(HtmlUtil.escape(getName()));
386             model.setTitle(HtmlUtil.escape(getTitle()));
387             model.setDescription(HtmlUtil.escape(getDescription()));
388             model.setVersion(getVersion());
389             model.setSize(getSize());
390             model.setReadCount(getReadCount());
391             model.setExtraSettings(HtmlUtil.escape(getExtraSettings()));
392 
393             model = (DLFileEntry)Proxy.newProxyInstance(DLFileEntry.class.getClassLoader(),
394                     new Class[] { DLFileEntry.class },
395                     new ReadOnlyBeanHandler(model));
396 
397             return model;
398         }
399     }
400 
401     public Object clone() {
402         DLFileEntryImpl clone = new DLFileEntryImpl();
403 
404         clone.setUuid(getUuid());
405         clone.setFileEntryId(getFileEntryId());
406         clone.setGroupId(getGroupId());
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(DLFileEntry dlFileEntry) {
427         int value = 0;
428 
429         if (getFolderId() < dlFileEntry.getFolderId()) {
430             value = -1;
431         }
432         else if (getFolderId() > dlFileEntry.getFolderId()) {
433             value = 1;
434         }
435         else {
436             value = 0;
437         }
438 
439         if (value != 0) {
440             return value;
441         }
442 
443         value = getName().compareTo(dlFileEntry.getName());
444 
445         if (value != 0) {
446             return value;
447         }
448 
449         return 0;
450     }
451 
452     public boolean equals(Object obj) {
453         if (obj == null) {
454             return false;
455         }
456 
457         DLFileEntry dlFileEntry = null;
458 
459         try {
460             dlFileEntry = (DLFileEntry)obj;
461         }
462         catch (ClassCastException cce) {
463             return false;
464         }
465 
466         long pk = dlFileEntry.getPrimaryKey();
467 
468         if (getPrimaryKey() == pk) {
469             return true;
470         }
471         else {
472             return false;
473         }
474     }
475 
476     public int hashCode() {
477         return (int)getPrimaryKey();
478     }
479 
480     public String toString() {
481         StringBuilder sb = new StringBuilder();
482 
483         sb.append("{uuid=");
484         sb.append(getUuid());
485         sb.append(", fileEntryId=");
486         sb.append(getFileEntryId());
487         sb.append(", groupId=");
488         sb.append(getGroupId());
489         sb.append(", companyId=");
490         sb.append(getCompanyId());
491         sb.append(", userId=");
492         sb.append(getUserId());
493         sb.append(", userName=");
494         sb.append(getUserName());
495         sb.append(", versionUserId=");
496         sb.append(getVersionUserId());
497         sb.append(", versionUserName=");
498         sb.append(getVersionUserName());
499         sb.append(", createDate=");
500         sb.append(getCreateDate());
501         sb.append(", modifiedDate=");
502         sb.append(getModifiedDate());
503         sb.append(", folderId=");
504         sb.append(getFolderId());
505         sb.append(", name=");
506         sb.append(getName());
507         sb.append(", title=");
508         sb.append(getTitle());
509         sb.append(", description=");
510         sb.append(getDescription());
511         sb.append(", version=");
512         sb.append(getVersion());
513         sb.append(", size=");
514         sb.append(getSize());
515         sb.append(", readCount=");
516         sb.append(getReadCount());
517         sb.append(", extraSettings=");
518         sb.append(getExtraSettings());
519         sb.append("}");
520 
521         return sb.toString();
522     }
523 
524     public String toXmlString() {
525         StringBuilder sb = new StringBuilder();
526 
527         sb.append("<model><model-name>");
528         sb.append("com.liferay.portlet.documentlibrary.model.DLFileEntry");
529         sb.append("</model-name>");
530 
531         sb.append(
532             "<column><column-name>uuid</column-name><column-value><![CDATA[");
533         sb.append(getUuid());
534         sb.append("]]></column-value></column>");
535         sb.append(
536             "<column><column-name>fileEntryId</column-name><column-value><![CDATA[");
537         sb.append(getFileEntryId());
538         sb.append("]]></column-value></column>");
539         sb.append(
540             "<column><column-name>groupId</column-name><column-value><![CDATA[");
541         sb.append(getGroupId());
542         sb.append("]]></column-value></column>");
543         sb.append(
544             "<column><column-name>companyId</column-name><column-value><![CDATA[");
545         sb.append(getCompanyId());
546         sb.append("]]></column-value></column>");
547         sb.append(
548             "<column><column-name>userId</column-name><column-value><![CDATA[");
549         sb.append(getUserId());
550         sb.append("]]></column-value></column>");
551         sb.append(
552             "<column><column-name>userName</column-name><column-value><![CDATA[");
553         sb.append(getUserName());
554         sb.append("]]></column-value></column>");
555         sb.append(
556             "<column><column-name>versionUserId</column-name><column-value><![CDATA[");
557         sb.append(getVersionUserId());
558         sb.append("]]></column-value></column>");
559         sb.append(
560             "<column><column-name>versionUserName</column-name><column-value><![CDATA[");
561         sb.append(getVersionUserName());
562         sb.append("]]></column-value></column>");
563         sb.append(
564             "<column><column-name>createDate</column-name><column-value><![CDATA[");
565         sb.append(getCreateDate());
566         sb.append("]]></column-value></column>");
567         sb.append(
568             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
569         sb.append(getModifiedDate());
570         sb.append("]]></column-value></column>");
571         sb.append(
572             "<column><column-name>folderId</column-name><column-value><![CDATA[");
573         sb.append(getFolderId());
574         sb.append("]]></column-value></column>");
575         sb.append(
576             "<column><column-name>name</column-name><column-value><![CDATA[");
577         sb.append(getName());
578         sb.append("]]></column-value></column>");
579         sb.append(
580             "<column><column-name>title</column-name><column-value><![CDATA[");
581         sb.append(getTitle());
582         sb.append("]]></column-value></column>");
583         sb.append(
584             "<column><column-name>description</column-name><column-value><![CDATA[");
585         sb.append(getDescription());
586         sb.append("]]></column-value></column>");
587         sb.append(
588             "<column><column-name>version</column-name><column-value><![CDATA[");
589         sb.append(getVersion());
590         sb.append("]]></column-value></column>");
591         sb.append(
592             "<column><column-name>size</column-name><column-value><![CDATA[");
593         sb.append(getSize());
594         sb.append("]]></column-value></column>");
595         sb.append(
596             "<column><column-name>readCount</column-name><column-value><![CDATA[");
597         sb.append(getReadCount());
598         sb.append("]]></column-value></column>");
599         sb.append(
600             "<column><column-name>extraSettings</column-name><column-value><![CDATA[");
601         sb.append(getExtraSettings());
602         sb.append("]]></column-value></column>");
603 
604         sb.append("</model>");
605 
606         return sb.toString();
607     }
608 
609     private String _uuid;
610     private String _originalUuid;
611     private long _fileEntryId;
612     private long _groupId;
613     private long _originalGroupId;
614     private boolean _setOriginalGroupId;
615     private long _companyId;
616     private long _userId;
617     private String _userName;
618     private long _versionUserId;
619     private String _versionUserName;
620     private Date _createDate;
621     private Date _modifiedDate;
622     private long _folderId;
623     private long _originalFolderId;
624     private boolean _setOriginalFolderId;
625     private String _name;
626     private String _originalName;
627     private String _title;
628     private String _description;
629     private double _version;
630     private int _size;
631     private int _readCount;
632     private String _extraSettings;
633 }