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