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