1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.documentlibrary.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.HtmlUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.service.ServiceContext;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import com.liferay.portlet.documentlibrary.model.DLFileEntry;
27  import com.liferay.portlet.documentlibrary.model.DLFileEntrySoap;
28  import com.liferay.portlet.expando.model.ExpandoBridge;
29  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.Date;
39  import java.util.List;
40  
41  /**
42   * <a href="DLFileEntryModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This interface is a model that represents the DLFileEntry table in the
51   * database.
52   * </p>
53   *
54   * @author    Brian Wing Shun Chan
55   * @see       DLFileEntryImpl
56   * @see       com.liferay.portlet.documentlibrary.model.DLFileEntry
57   * @see       com.liferay.portlet.documentlibrary.model.DLFileEntryModel
58   * @generated
59   */
60  public class DLFileEntryModelImpl extends BaseModelImpl<DLFileEntry> {
61      public static final String TABLE_NAME = "DLFileEntry";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "uuid_", new Integer(Types.VARCHAR) },
64              { "fileEntryId", new Integer(Types.BIGINT) },
65              { "groupId", new Integer(Types.BIGINT) },
66              { "companyId", new Integer(Types.BIGINT) },
67              { "userId", new Integer(Types.BIGINT) },
68              { "userName", new Integer(Types.VARCHAR) },
69              { "versionUserId", new Integer(Types.BIGINT) },
70              { "versionUserName", new Integer(Types.VARCHAR) },
71              { "createDate", new Integer(Types.TIMESTAMP) },
72              { "modifiedDate", new Integer(Types.TIMESTAMP) },
73              { "folderId", new Integer(Types.BIGINT) },
74              { "name", new Integer(Types.VARCHAR) },
75              { "title", new Integer(Types.VARCHAR) },
76              { "description", new Integer(Types.VARCHAR) },
77              { "version", new Integer(Types.VARCHAR) },
78              { "pendingVersion", new Integer(Types.VARCHAR) },
79              { "size_", new Integer(Types.INTEGER) },
80              { "readCount", new Integer(Types.INTEGER) },
81              { "extraSettings", new Integer(Types.CLOB) }
82          };
83      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 VARCHAR(75) null,pendingVersion VARCHAR(75) null,size_ INTEGER,readCount INTEGER,extraSettings TEXT null)";
84      public static final String TABLE_SQL_DROP = "drop table DLFileEntry";
85      public static final String ORDER_BY_JPQL = " ORDER BY dlFileEntry.folderId ASC, dlFileEntry.name ASC";
86      public static final String ORDER_BY_SQL = " ORDER BY DLFileEntry.folderId ASC, DLFileEntry.name ASC";
87      public static final String DATA_SOURCE = "liferayDataSource";
88      public static final String SESSION_FACTORY = "liferaySessionFactory";
89      public static final String TX_MANAGER = "liferayTransactionManager";
90      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
91                  "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
92              true);
93      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
94                  "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
95              true);
96  
97      public static DLFileEntry toModel(DLFileEntrySoap soapModel) {
98          DLFileEntry model = new DLFileEntryImpl();
99  
100         model.setUuid(soapModel.getUuid());
101         model.setFileEntryId(soapModel.getFileEntryId());
102         model.setGroupId(soapModel.getGroupId());
103         model.setCompanyId(soapModel.getCompanyId());
104         model.setUserId(soapModel.getUserId());
105         model.setUserName(soapModel.getUserName());
106         model.setVersionUserId(soapModel.getVersionUserId());
107         model.setVersionUserName(soapModel.getVersionUserName());
108         model.setCreateDate(soapModel.getCreateDate());
109         model.setModifiedDate(soapModel.getModifiedDate());
110         model.setFolderId(soapModel.getFolderId());
111         model.setName(soapModel.getName());
112         model.setTitle(soapModel.getTitle());
113         model.setDescription(soapModel.getDescription());
114         model.setVersion(soapModel.getVersion());
115         model.setPendingVersion(soapModel.getPendingVersion());
116         model.setSize(soapModel.getSize());
117         model.setReadCount(soapModel.getReadCount());
118         model.setExtraSettings(soapModel.getExtraSettings());
119 
120         return model;
121     }
122 
123     public static List<DLFileEntry> toModels(DLFileEntrySoap[] soapModels) {
124         List<DLFileEntry> models = new ArrayList<DLFileEntry>(soapModels.length);
125 
126         for (DLFileEntrySoap soapModel : soapModels) {
127             models.add(toModel(soapModel));
128         }
129 
130         return models;
131     }
132 
133     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
134                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileEntry"));
135 
136     public DLFileEntryModelImpl() {
137     }
138 
139     public long getPrimaryKey() {
140         return _fileEntryId;
141     }
142 
143     public void setPrimaryKey(long pk) {
144         setFileEntryId(pk);
145     }
146 
147     public Serializable getPrimaryKeyObj() {
148         return new Long(_fileEntryId);
149     }
150 
151     public String getUuid() {
152         return GetterUtil.getString(_uuid);
153     }
154 
155     public void setUuid(String uuid) {
156         _uuid = uuid;
157 
158         if (_originalUuid == null) {
159             _originalUuid = uuid;
160         }
161     }
162 
163     public String getOriginalUuid() {
164         return GetterUtil.getString(_originalUuid);
165     }
166 
167     public long getFileEntryId() {
168         return _fileEntryId;
169     }
170 
171     public void setFileEntryId(long fileEntryId) {
172         _fileEntryId = fileEntryId;
173     }
174 
175     public long getGroupId() {
176         return _groupId;
177     }
178 
179     public void setGroupId(long groupId) {
180         _groupId = groupId;
181 
182         if (!_setOriginalGroupId) {
183             _setOriginalGroupId = true;
184 
185             _originalGroupId = groupId;
186         }
187     }
188 
189     public long getOriginalGroupId() {
190         return _originalGroupId;
191     }
192 
193     public long getCompanyId() {
194         return _companyId;
195     }
196 
197     public void setCompanyId(long companyId) {
198         _companyId = companyId;
199     }
200 
201     public long getUserId() {
202         return _userId;
203     }
204 
205     public void setUserId(long userId) {
206         _userId = userId;
207     }
208 
209     public String getUserUuid() throws SystemException {
210         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
211     }
212 
213     public void setUserUuid(String userUuid) {
214         _userUuid = userUuid;
215     }
216 
217     public String getUserName() {
218         return GetterUtil.getString(_userName);
219     }
220 
221     public void setUserName(String userName) {
222         _userName = userName;
223     }
224 
225     public long getVersionUserId() {
226         return _versionUserId;
227     }
228 
229     public void setVersionUserId(long versionUserId) {
230         _versionUserId = versionUserId;
231     }
232 
233     public String getVersionUserUuid() throws SystemException {
234         return PortalUtil.getUserValue(getVersionUserId(), "uuid",
235             _versionUserUuid);
236     }
237 
238     public void setVersionUserUuid(String versionUserUuid) {
239         _versionUserUuid = versionUserUuid;
240     }
241 
242     public String getVersionUserName() {
243         return GetterUtil.getString(_versionUserName);
244     }
245 
246     public void setVersionUserName(String versionUserName) {
247         _versionUserName = versionUserName;
248     }
249 
250     public Date getCreateDate() {
251         return _createDate;
252     }
253 
254     public void setCreateDate(Date createDate) {
255         _createDate = createDate;
256     }
257 
258     public Date getModifiedDate() {
259         return _modifiedDate;
260     }
261 
262     public void setModifiedDate(Date modifiedDate) {
263         _modifiedDate = modifiedDate;
264     }
265 
266     public long getFolderId() {
267         return _folderId;
268     }
269 
270     public void setFolderId(long folderId) {
271         _folderId = folderId;
272 
273         if (!_setOriginalFolderId) {
274             _setOriginalFolderId = true;
275 
276             _originalFolderId = folderId;
277         }
278     }
279 
280     public long getOriginalFolderId() {
281         return _originalFolderId;
282     }
283 
284     public String getName() {
285         return GetterUtil.getString(_name);
286     }
287 
288     public void setName(String name) {
289         _name = name;
290 
291         if (_originalName == null) {
292             _originalName = name;
293         }
294     }
295 
296     public String getOriginalName() {
297         return GetterUtil.getString(_originalName);
298     }
299 
300     public String getTitle() {
301         return GetterUtil.getString(_title);
302     }
303 
304     public void setTitle(String title) {
305         _title = title;
306 
307         if (_originalTitle == null) {
308             _originalTitle = title;
309         }
310     }
311 
312     public String getOriginalTitle() {
313         return GetterUtil.getString(_originalTitle);
314     }
315 
316     public String getDescription() {
317         return GetterUtil.getString(_description);
318     }
319 
320     public void setDescription(String description) {
321         _description = description;
322     }
323 
324     public String getVersion() {
325         return GetterUtil.getString(_version);
326     }
327 
328     public void setVersion(String version) {
329         _version = version;
330     }
331 
332     public String getPendingVersion() {
333         return GetterUtil.getString(_pendingVersion);
334     }
335 
336     public void setPendingVersion(String pendingVersion) {
337         _pendingVersion = pendingVersion;
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(HtmlUtil.escape(getVersion()));
389             model.setPendingVersion(HtmlUtil.escape(getPendingVersion()));
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 ExpandoBridge getExpandoBridge() {
403         if (_expandoBridge == null) {
404             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
405                     DLFileEntry.class.getName(), getPrimaryKey());
406         }
407 
408         return _expandoBridge;
409     }
410 
411     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
412         getExpandoBridge().setAttributes(serviceContext);
413     }
414 
415     public Object clone() {
416         DLFileEntryImpl clone = new DLFileEntryImpl();
417 
418         clone.setUuid(getUuid());
419         clone.setFileEntryId(getFileEntryId());
420         clone.setGroupId(getGroupId());
421         clone.setCompanyId(getCompanyId());
422         clone.setUserId(getUserId());
423         clone.setUserName(getUserName());
424         clone.setVersionUserId(getVersionUserId());
425         clone.setVersionUserName(getVersionUserName());
426         clone.setCreateDate(getCreateDate());
427         clone.setModifiedDate(getModifiedDate());
428         clone.setFolderId(getFolderId());
429         clone.setName(getName());
430         clone.setTitle(getTitle());
431         clone.setDescription(getDescription());
432         clone.setVersion(getVersion());
433         clone.setPendingVersion(getPendingVersion());
434         clone.setSize(getSize());
435         clone.setReadCount(getReadCount());
436         clone.setExtraSettings(getExtraSettings());
437 
438         return clone;
439     }
440 
441     public int compareTo(DLFileEntry dlFileEntry) {
442         int value = 0;
443 
444         if (getFolderId() < dlFileEntry.getFolderId()) {
445             value = -1;
446         }
447         else if (getFolderId() > dlFileEntry.getFolderId()) {
448             value = 1;
449         }
450         else {
451             value = 0;
452         }
453 
454         if (value != 0) {
455             return value;
456         }
457 
458         value = getName().compareTo(dlFileEntry.getName());
459 
460         if (value != 0) {
461             return value;
462         }
463 
464         return 0;
465     }
466 
467     public boolean equals(Object obj) {
468         if (obj == null) {
469             return false;
470         }
471 
472         DLFileEntry dlFileEntry = null;
473 
474         try {
475             dlFileEntry = (DLFileEntry)obj;
476         }
477         catch (ClassCastException cce) {
478             return false;
479         }
480 
481         long pk = dlFileEntry.getPrimaryKey();
482 
483         if (getPrimaryKey() == pk) {
484             return true;
485         }
486         else {
487             return false;
488         }
489     }
490 
491     public int hashCode() {
492         return (int)getPrimaryKey();
493     }
494 
495     public String toString() {
496         StringBundler sb = new StringBundler(39);
497 
498         sb.append("{uuid=");
499         sb.append(getUuid());
500         sb.append(", fileEntryId=");
501         sb.append(getFileEntryId());
502         sb.append(", groupId=");
503         sb.append(getGroupId());
504         sb.append(", companyId=");
505         sb.append(getCompanyId());
506         sb.append(", userId=");
507         sb.append(getUserId());
508         sb.append(", userName=");
509         sb.append(getUserName());
510         sb.append(", versionUserId=");
511         sb.append(getVersionUserId());
512         sb.append(", versionUserName=");
513         sb.append(getVersionUserName());
514         sb.append(", createDate=");
515         sb.append(getCreateDate());
516         sb.append(", modifiedDate=");
517         sb.append(getModifiedDate());
518         sb.append(", folderId=");
519         sb.append(getFolderId());
520         sb.append(", name=");
521         sb.append(getName());
522         sb.append(", title=");
523         sb.append(getTitle());
524         sb.append(", description=");
525         sb.append(getDescription());
526         sb.append(", version=");
527         sb.append(getVersion());
528         sb.append(", pendingVersion=");
529         sb.append(getPendingVersion());
530         sb.append(", size=");
531         sb.append(getSize());
532         sb.append(", readCount=");
533         sb.append(getReadCount());
534         sb.append(", extraSettings=");
535         sb.append(getExtraSettings());
536         sb.append("}");
537 
538         return sb.toString();
539     }
540 
541     public String toXmlString() {
542         StringBundler sb = new StringBundler(61);
543 
544         sb.append("<model><model-name>");
545         sb.append("com.liferay.portlet.documentlibrary.model.DLFileEntry");
546         sb.append("</model-name>");
547 
548         sb.append(
549             "<column><column-name>uuid</column-name><column-value><![CDATA[");
550         sb.append(getUuid());
551         sb.append("]]></column-value></column>");
552         sb.append(
553             "<column><column-name>fileEntryId</column-name><column-value><![CDATA[");
554         sb.append(getFileEntryId());
555         sb.append("]]></column-value></column>");
556         sb.append(
557             "<column><column-name>groupId</column-name><column-value><![CDATA[");
558         sb.append(getGroupId());
559         sb.append("]]></column-value></column>");
560         sb.append(
561             "<column><column-name>companyId</column-name><column-value><![CDATA[");
562         sb.append(getCompanyId());
563         sb.append("]]></column-value></column>");
564         sb.append(
565             "<column><column-name>userId</column-name><column-value><![CDATA[");
566         sb.append(getUserId());
567         sb.append("]]></column-value></column>");
568         sb.append(
569             "<column><column-name>userName</column-name><column-value><![CDATA[");
570         sb.append(getUserName());
571         sb.append("]]></column-value></column>");
572         sb.append(
573             "<column><column-name>versionUserId</column-name><column-value><![CDATA[");
574         sb.append(getVersionUserId());
575         sb.append("]]></column-value></column>");
576         sb.append(
577             "<column><column-name>versionUserName</column-name><column-value><![CDATA[");
578         sb.append(getVersionUserName());
579         sb.append("]]></column-value></column>");
580         sb.append(
581             "<column><column-name>createDate</column-name><column-value><![CDATA[");
582         sb.append(getCreateDate());
583         sb.append("]]></column-value></column>");
584         sb.append(
585             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
586         sb.append(getModifiedDate());
587         sb.append("]]></column-value></column>");
588         sb.append(
589             "<column><column-name>folderId</column-name><column-value><![CDATA[");
590         sb.append(getFolderId());
591         sb.append("]]></column-value></column>");
592         sb.append(
593             "<column><column-name>name</column-name><column-value><![CDATA[");
594         sb.append(getName());
595         sb.append("]]></column-value></column>");
596         sb.append(
597             "<column><column-name>title</column-name><column-value><![CDATA[");
598         sb.append(getTitle());
599         sb.append("]]></column-value></column>");
600         sb.append(
601             "<column><column-name>description</column-name><column-value><![CDATA[");
602         sb.append(getDescription());
603         sb.append("]]></column-value></column>");
604         sb.append(
605             "<column><column-name>version</column-name><column-value><![CDATA[");
606         sb.append(getVersion());
607         sb.append("]]></column-value></column>");
608         sb.append(
609             "<column><column-name>pendingVersion</column-name><column-value><![CDATA[");
610         sb.append(getPendingVersion());
611         sb.append("]]></column-value></column>");
612         sb.append(
613             "<column><column-name>size</column-name><column-value><![CDATA[");
614         sb.append(getSize());
615         sb.append("]]></column-value></column>");
616         sb.append(
617             "<column><column-name>readCount</column-name><column-value><![CDATA[");
618         sb.append(getReadCount());
619         sb.append("]]></column-value></column>");
620         sb.append(
621             "<column><column-name>extraSettings</column-name><column-value><![CDATA[");
622         sb.append(getExtraSettings());
623         sb.append("]]></column-value></column>");
624 
625         sb.append("</model>");
626 
627         return sb.toString();
628     }
629 
630     private String _uuid;
631     private String _originalUuid;
632     private long _fileEntryId;
633     private long _groupId;
634     private long _originalGroupId;
635     private boolean _setOriginalGroupId;
636     private long _companyId;
637     private long _userId;
638     private String _userUuid;
639     private String _userName;
640     private long _versionUserId;
641     private String _versionUserUuid;
642     private String _versionUserName;
643     private Date _createDate;
644     private Date _modifiedDate;
645     private long _folderId;
646     private long _originalFolderId;
647     private boolean _setOriginalFolderId;
648     private String _name;
649     private String _originalName;
650     private String _title;
651     private String _originalTitle;
652     private String _description;
653     private String _version;
654     private String _pendingVersion;
655     private int _size;
656     private int _readCount;
657     private String _extraSettings;
658     private transient ExpandoBridge _expandoBridge;
659 }