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