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  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.Date;
43  import java.util.List;
44  
45  /**
46   * <a href="DLFileEntryModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This interface is a model that represents the DLFileEntry table in the
55   * database.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       DLFileEntryImpl
60   * @see       com.liferay.portlet.documentlibrary.model.DLFileEntry
61   * @see       com.liferay.portlet.documentlibrary.model.DLFileEntryModel
62   * @generated
63   */
64  public class DLFileEntryModelImpl extends BaseModelImpl<DLFileEntry> {
65      public static final String TABLE_NAME = "DLFileEntry";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "uuid_", new Integer(Types.VARCHAR) },
68              { "fileEntryId", new Integer(Types.BIGINT) },
69              { "groupId", new Integer(Types.BIGINT) },
70              { "companyId", new Integer(Types.BIGINT) },
71              { "userId", new Integer(Types.BIGINT) },
72              { "userName", new Integer(Types.VARCHAR) },
73              { "versionUserId", new Integer(Types.BIGINT) },
74              { "versionUserName", new Integer(Types.VARCHAR) },
75              { "createDate", new Integer(Types.TIMESTAMP) },
76              { "modifiedDate", new Integer(Types.TIMESTAMP) },
77              { "folderId", new Integer(Types.BIGINT) },
78              { "name", new Integer(Types.VARCHAR) },
79              { "title", new Integer(Types.VARCHAR) },
80              { "description", new Integer(Types.VARCHAR) },
81              { "version", new Integer(Types.DOUBLE) },
82              { "size_", new Integer(Types.INTEGER) },
83              { "readCount", new Integer(Types.INTEGER) },
84              { "extraSettings", new Integer(Types.CLOB) }
85          };
86      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)";
87      public static final String TABLE_SQL_DROP = "drop table DLFileEntry";
88      public static final String DATA_SOURCE = "liferayDataSource";
89      public static final String SESSION_FACTORY = "liferaySessionFactory";
90      public static final String TX_MANAGER = "liferayTransactionManager";
91      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
92                  "value.object.entity.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
93              true);
94      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95                  "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
96              true);
97  
98      public static DLFileEntry toModel(DLFileEntrySoap soapModel) {
99          DLFileEntry model = new DLFileEntryImpl();
100 
101         model.setUuid(soapModel.getUuid());
102         model.setFileEntryId(soapModel.getFileEntryId());
103         model.setGroupId(soapModel.getGroupId());
104         model.setCompanyId(soapModel.getCompanyId());
105         model.setUserId(soapModel.getUserId());
106         model.setUserName(soapModel.getUserName());
107         model.setVersionUserId(soapModel.getVersionUserId());
108         model.setVersionUserName(soapModel.getVersionUserName());
109         model.setCreateDate(soapModel.getCreateDate());
110         model.setModifiedDate(soapModel.getModifiedDate());
111         model.setFolderId(soapModel.getFolderId());
112         model.setName(soapModel.getName());
113         model.setTitle(soapModel.getTitle());
114         model.setDescription(soapModel.getDescription());
115         model.setVersion(soapModel.getVersion());
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 
308     public String getDescription() {
309         return GetterUtil.getString(_description);
310     }
311 
312     public void setDescription(String description) {
313         _description = description;
314     }
315 
316     public double getVersion() {
317         return _version;
318     }
319 
320     public void setVersion(double version) {
321         _version = version;
322     }
323 
324     public int getSize() {
325         return _size;
326     }
327 
328     public void setSize(int size) {
329         _size = size;
330     }
331 
332     public int getReadCount() {
333         return _readCount;
334     }
335 
336     public void setReadCount(int readCount) {
337         _readCount = readCount;
338     }
339 
340     public String getExtraSettings() {
341         return GetterUtil.getString(_extraSettings);
342     }
343 
344     public void setExtraSettings(String extraSettings) {
345         _extraSettings = extraSettings;
346     }
347 
348     public DLFileEntry toEscapedModel() {
349         if (isEscapedModel()) {
350             return (DLFileEntry)this;
351         }
352         else {
353             DLFileEntry model = new DLFileEntryImpl();
354 
355             model.setNew(isNew());
356             model.setEscapedModel(true);
357 
358             model.setUuid(HtmlUtil.escape(getUuid()));
359             model.setFileEntryId(getFileEntryId());
360             model.setGroupId(getGroupId());
361             model.setCompanyId(getCompanyId());
362             model.setUserId(getUserId());
363             model.setUserName(HtmlUtil.escape(getUserName()));
364             model.setVersionUserId(getVersionUserId());
365             model.setVersionUserName(HtmlUtil.escape(getVersionUserName()));
366             model.setCreateDate(getCreateDate());
367             model.setModifiedDate(getModifiedDate());
368             model.setFolderId(getFolderId());
369             model.setName(HtmlUtil.escape(getName()));
370             model.setTitle(HtmlUtil.escape(getTitle()));
371             model.setDescription(HtmlUtil.escape(getDescription()));
372             model.setVersion(getVersion());
373             model.setSize(getSize());
374             model.setReadCount(getReadCount());
375             model.setExtraSettings(HtmlUtil.escape(getExtraSettings()));
376 
377             model = (DLFileEntry)Proxy.newProxyInstance(DLFileEntry.class.getClassLoader(),
378                     new Class[] { DLFileEntry.class },
379                     new ReadOnlyBeanHandler(model));
380 
381             return model;
382         }
383     }
384 
385     public Object clone() {
386         DLFileEntryImpl clone = new DLFileEntryImpl();
387 
388         clone.setUuid(getUuid());
389         clone.setFileEntryId(getFileEntryId());
390         clone.setGroupId(getGroupId());
391         clone.setCompanyId(getCompanyId());
392         clone.setUserId(getUserId());
393         clone.setUserName(getUserName());
394         clone.setVersionUserId(getVersionUserId());
395         clone.setVersionUserName(getVersionUserName());
396         clone.setCreateDate(getCreateDate());
397         clone.setModifiedDate(getModifiedDate());
398         clone.setFolderId(getFolderId());
399         clone.setName(getName());
400         clone.setTitle(getTitle());
401         clone.setDescription(getDescription());
402         clone.setVersion(getVersion());
403         clone.setSize(getSize());
404         clone.setReadCount(getReadCount());
405         clone.setExtraSettings(getExtraSettings());
406 
407         return clone;
408     }
409 
410     public int compareTo(DLFileEntry dlFileEntry) {
411         int value = 0;
412 
413         if (getFolderId() < dlFileEntry.getFolderId()) {
414             value = -1;
415         }
416         else if (getFolderId() > dlFileEntry.getFolderId()) {
417             value = 1;
418         }
419         else {
420             value = 0;
421         }
422 
423         if (value != 0) {
424             return value;
425         }
426 
427         value = getName().compareTo(dlFileEntry.getName());
428 
429         if (value != 0) {
430             return value;
431         }
432 
433         return 0;
434     }
435 
436     public boolean equals(Object obj) {
437         if (obj == null) {
438             return false;
439         }
440 
441         DLFileEntry dlFileEntry = null;
442 
443         try {
444             dlFileEntry = (DLFileEntry)obj;
445         }
446         catch (ClassCastException cce) {
447             return false;
448         }
449 
450         long pk = dlFileEntry.getPrimaryKey();
451 
452         if (getPrimaryKey() == pk) {
453             return true;
454         }
455         else {
456             return false;
457         }
458     }
459 
460     public int hashCode() {
461         return (int)getPrimaryKey();
462     }
463 
464     public String toString() {
465         StringBuilder sb = new StringBuilder();
466 
467         sb.append("{uuid=");
468         sb.append(getUuid());
469         sb.append(", fileEntryId=");
470         sb.append(getFileEntryId());
471         sb.append(", groupId=");
472         sb.append(getGroupId());
473         sb.append(", companyId=");
474         sb.append(getCompanyId());
475         sb.append(", userId=");
476         sb.append(getUserId());
477         sb.append(", userName=");
478         sb.append(getUserName());
479         sb.append(", versionUserId=");
480         sb.append(getVersionUserId());
481         sb.append(", versionUserName=");
482         sb.append(getVersionUserName());
483         sb.append(", createDate=");
484         sb.append(getCreateDate());
485         sb.append(", modifiedDate=");
486         sb.append(getModifiedDate());
487         sb.append(", folderId=");
488         sb.append(getFolderId());
489         sb.append(", name=");
490         sb.append(getName());
491         sb.append(", title=");
492         sb.append(getTitle());
493         sb.append(", description=");
494         sb.append(getDescription());
495         sb.append(", version=");
496         sb.append(getVersion());
497         sb.append(", size=");
498         sb.append(getSize());
499         sb.append(", readCount=");
500         sb.append(getReadCount());
501         sb.append(", extraSettings=");
502         sb.append(getExtraSettings());
503         sb.append("}");
504 
505         return sb.toString();
506     }
507 
508     public String toXmlString() {
509         StringBuilder sb = new StringBuilder();
510 
511         sb.append("<model><model-name>");
512         sb.append("com.liferay.portlet.documentlibrary.model.DLFileEntry");
513         sb.append("</model-name>");
514 
515         sb.append(
516             "<column><column-name>uuid</column-name><column-value><![CDATA[");
517         sb.append(getUuid());
518         sb.append("]]></column-value></column>");
519         sb.append(
520             "<column><column-name>fileEntryId</column-name><column-value><![CDATA[");
521         sb.append(getFileEntryId());
522         sb.append("]]></column-value></column>");
523         sb.append(
524             "<column><column-name>groupId</column-name><column-value><![CDATA[");
525         sb.append(getGroupId());
526         sb.append("]]></column-value></column>");
527         sb.append(
528             "<column><column-name>companyId</column-name><column-value><![CDATA[");
529         sb.append(getCompanyId());
530         sb.append("]]></column-value></column>");
531         sb.append(
532             "<column><column-name>userId</column-name><column-value><![CDATA[");
533         sb.append(getUserId());
534         sb.append("]]></column-value></column>");
535         sb.append(
536             "<column><column-name>userName</column-name><column-value><![CDATA[");
537         sb.append(getUserName());
538         sb.append("]]></column-value></column>");
539         sb.append(
540             "<column><column-name>versionUserId</column-name><column-value><![CDATA[");
541         sb.append(getVersionUserId());
542         sb.append("]]></column-value></column>");
543         sb.append(
544             "<column><column-name>versionUserName</column-name><column-value><![CDATA[");
545         sb.append(getVersionUserName());
546         sb.append("]]></column-value></column>");
547         sb.append(
548             "<column><column-name>createDate</column-name><column-value><![CDATA[");
549         sb.append(getCreateDate());
550         sb.append("]]></column-value></column>");
551         sb.append(
552             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
553         sb.append(getModifiedDate());
554         sb.append("]]></column-value></column>");
555         sb.append(
556             "<column><column-name>folderId</column-name><column-value><![CDATA[");
557         sb.append(getFolderId());
558         sb.append("]]></column-value></column>");
559         sb.append(
560             "<column><column-name>name</column-name><column-value><![CDATA[");
561         sb.append(getName());
562         sb.append("]]></column-value></column>");
563         sb.append(
564             "<column><column-name>title</column-name><column-value><![CDATA[");
565         sb.append(getTitle());
566         sb.append("]]></column-value></column>");
567         sb.append(
568             "<column><column-name>description</column-name><column-value><![CDATA[");
569         sb.append(getDescription());
570         sb.append("]]></column-value></column>");
571         sb.append(
572             "<column><column-name>version</column-name><column-value><![CDATA[");
573         sb.append(getVersion());
574         sb.append("]]></column-value></column>");
575         sb.append(
576             "<column><column-name>size</column-name><column-value><![CDATA[");
577         sb.append(getSize());
578         sb.append("]]></column-value></column>");
579         sb.append(
580             "<column><column-name>readCount</column-name><column-value><![CDATA[");
581         sb.append(getReadCount());
582         sb.append("]]></column-value></column>");
583         sb.append(
584             "<column><column-name>extraSettings</column-name><column-value><![CDATA[");
585         sb.append(getExtraSettings());
586         sb.append("]]></column-value></column>");
587 
588         sb.append("</model>");
589 
590         return sb.toString();
591     }
592 
593     private String _uuid;
594     private String _originalUuid;
595     private long _fileEntryId;
596     private long _groupId;
597     private long _originalGroupId;
598     private boolean _setOriginalGroupId;
599     private long _companyId;
600     private long _userId;
601     private String _userUuid;
602     private String _userName;
603     private long _versionUserId;
604     private String _versionUserUuid;
605     private String _versionUserName;
606     private Date _createDate;
607     private Date _modifiedDate;
608     private long _folderId;
609     private long _originalFolderId;
610     private boolean _setOriginalFolderId;
611     private String _name;
612     private String _originalName;
613     private String _title;
614     private String _description;
615     private double _version;
616     private int _size;
617     private int _readCount;
618     private String _extraSettings;
619 }