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  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <a href="DLFileEntryModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>DLFileEntry</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.documentlibrary.model.DLFileEntry
56   * @see com.liferay.portlet.documentlibrary.model.DLFileEntryModel
57   * @see com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl
58   *
59   */
60  public class DLFileEntryModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "DLFileEntry";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "uuid_", new Integer(Types.VARCHAR) },
64              
65  
66              { "fileEntryId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "userId", new Integer(Types.BIGINT) },
73              
74  
75              { "userName", new Integer(Types.VARCHAR) },
76              
77  
78              { "versionUserId", new Integer(Types.BIGINT) },
79              
80  
81              { "versionUserName", new Integer(Types.VARCHAR) },
82              
83  
84              { "createDate", new Integer(Types.TIMESTAMP) },
85              
86  
87              { "modifiedDate", new Integer(Types.TIMESTAMP) },
88              
89  
90              { "folderId", new Integer(Types.BIGINT) },
91              
92  
93              { "name", new Integer(Types.VARCHAR) },
94              
95  
96              { "title", new Integer(Types.VARCHAR) },
97              
98  
99              { "description", new Integer(Types.VARCHAR) },
100             
101 
102             { "version", new Integer(Types.DOUBLE) },
103             
104 
105             { "size_", new Integer(Types.INTEGER) },
106             
107 
108             { "readCount", new Integer(Types.INTEGER) },
109             
110 
111             { "extraSettings", new Integer(Types.CLOB) }
112         };
113     public static final String TABLE_SQL_CREATE = "create table DLFileEntry (uuid_ VARCHAR(75) null,fileEntryId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,versionUserId LONG,versionUserName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,folderId LONG,name VARCHAR(300) null,title VARCHAR(300) null,description STRING null,version DOUBLE,size_ INTEGER,readCount INTEGER,extraSettings TEXT null)";
114     public static final String TABLE_SQL_DROP = "drop table DLFileEntry";
115     public static final String DATA_SOURCE = "liferayDataSource";
116     public static final String SESSION_FACTORY = "liferaySessionFactory";
117     public static final String TX_MANAGER = "liferayTransactionManager";
118     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
119                 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
120             true);
121 
122     public static DLFileEntry toModel(DLFileEntrySoap soapModel) {
123         DLFileEntry model = new DLFileEntryImpl();
124 
125         model.setUuid(soapModel.getUuid());
126         model.setFileEntryId(soapModel.getFileEntryId());
127         model.setCompanyId(soapModel.getCompanyId());
128         model.setUserId(soapModel.getUserId());
129         model.setUserName(soapModel.getUserName());
130         model.setVersionUserId(soapModel.getVersionUserId());
131         model.setVersionUserName(soapModel.getVersionUserName());
132         model.setCreateDate(soapModel.getCreateDate());
133         model.setModifiedDate(soapModel.getModifiedDate());
134         model.setFolderId(soapModel.getFolderId());
135         model.setName(soapModel.getName());
136         model.setTitle(soapModel.getTitle());
137         model.setDescription(soapModel.getDescription());
138         model.setVersion(soapModel.getVersion());
139         model.setSize(soapModel.getSize());
140         model.setReadCount(soapModel.getReadCount());
141         model.setExtraSettings(soapModel.getExtraSettings());
142 
143         return model;
144     }
145 
146     public static List<DLFileEntry> toModels(DLFileEntrySoap[] soapModels) {
147         List<DLFileEntry> models = new ArrayList<DLFileEntry>(soapModels.length);
148 
149         for (DLFileEntrySoap soapModel : soapModels) {
150             models.add(toModel(soapModel));
151         }
152 
153         return models;
154     }
155 
156     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
157                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileEntry"));
158 
159     public DLFileEntryModelImpl() {
160     }
161 
162     public long getPrimaryKey() {
163         return _fileEntryId;
164     }
165 
166     public void setPrimaryKey(long pk) {
167         setFileEntryId(pk);
168     }
169 
170     public Serializable getPrimaryKeyObj() {
171         return new Long(_fileEntryId);
172     }
173 
174     public String getUuid() {
175         return GetterUtil.getString(_uuid);
176     }
177 
178     public void setUuid(String uuid) {
179         if ((uuid != null) && (uuid != _uuid)) {
180             _uuid = uuid;
181         }
182     }
183 
184     public long getFileEntryId() {
185         return _fileEntryId;
186     }
187 
188     public void setFileEntryId(long fileEntryId) {
189         if (fileEntryId != _fileEntryId) {
190             _fileEntryId = fileEntryId;
191         }
192     }
193 
194     public long getCompanyId() {
195         return _companyId;
196     }
197 
198     public void setCompanyId(long companyId) {
199         if (companyId != _companyId) {
200             _companyId = companyId;
201         }
202     }
203 
204     public long getUserId() {
205         return _userId;
206     }
207 
208     public void setUserId(long userId) {
209         if (userId != _userId) {
210             _userId = userId;
211         }
212     }
213 
214     public String getUserName() {
215         return GetterUtil.getString(_userName);
216     }
217 
218     public void setUserName(String userName) {
219         if (((userName == null) && (_userName != null)) ||
220                 ((userName != null) && (_userName == null)) ||
221                 ((userName != null) && (_userName != null) &&
222                 !userName.equals(_userName))) {
223             _userName = userName;
224         }
225     }
226 
227     public long getVersionUserId() {
228         return _versionUserId;
229     }
230 
231     public void setVersionUserId(long versionUserId) {
232         if (versionUserId != _versionUserId) {
233             _versionUserId = versionUserId;
234         }
235     }
236 
237     public String getVersionUserName() {
238         return GetterUtil.getString(_versionUserName);
239     }
240 
241     public void setVersionUserName(String versionUserName) {
242         if (((versionUserName == null) && (_versionUserName != null)) ||
243                 ((versionUserName != null) && (_versionUserName == null)) ||
244                 ((versionUserName != null) && (_versionUserName != null) &&
245                 !versionUserName.equals(_versionUserName))) {
246             _versionUserName = versionUserName;
247         }
248     }
249 
250     public Date getCreateDate() {
251         return _createDate;
252     }
253 
254     public void setCreateDate(Date createDate) {
255         if (((createDate == null) && (_createDate != null)) ||
256                 ((createDate != null) && (_createDate == null)) ||
257                 ((createDate != null) && (_createDate != null) &&
258                 !createDate.equals(_createDate))) {
259             _createDate = createDate;
260         }
261     }
262 
263     public Date getModifiedDate() {
264         return _modifiedDate;
265     }
266 
267     public void setModifiedDate(Date modifiedDate) {
268         if (((modifiedDate == null) && (_modifiedDate != null)) ||
269                 ((modifiedDate != null) && (_modifiedDate == null)) ||
270                 ((modifiedDate != null) && (_modifiedDate != null) &&
271                 !modifiedDate.equals(_modifiedDate))) {
272             _modifiedDate = modifiedDate;
273         }
274     }
275 
276     public long getFolderId() {
277         return _folderId;
278     }
279 
280     public void setFolderId(long folderId) {
281         if (folderId != _folderId) {
282             _folderId = folderId;
283         }
284     }
285 
286     public String getName() {
287         return GetterUtil.getString(_name);
288     }
289 
290     public void setName(String name) {
291         if (((name == null) && (_name != null)) ||
292                 ((name != null) && (_name == null)) ||
293                 ((name != null) && (_name != null) && !name.equals(_name))) {
294             _name = name;
295         }
296     }
297 
298     public String getTitle() {
299         return GetterUtil.getString(_title);
300     }
301 
302     public void setTitle(String title) {
303         if (((title == null) && (_title != null)) ||
304                 ((title != null) && (_title == null)) ||
305                 ((title != null) && (_title != null) && !title.equals(_title))) {
306             _title = title;
307         }
308     }
309 
310     public String getDescription() {
311         return GetterUtil.getString(_description);
312     }
313 
314     public void setDescription(String description) {
315         if (((description == null) && (_description != null)) ||
316                 ((description != null) && (_description == null)) ||
317                 ((description != null) && (_description != null) &&
318                 !description.equals(_description))) {
319             _description = description;
320         }
321     }
322 
323     public double getVersion() {
324         return _version;
325     }
326 
327     public void setVersion(double version) {
328         if (version != _version) {
329             _version = version;
330         }
331     }
332 
333     public int getSize() {
334         return _size;
335     }
336 
337     public void setSize(int size) {
338         if (size != _size) {
339             _size = size;
340         }
341     }
342 
343     public int getReadCount() {
344         return _readCount;
345     }
346 
347     public void setReadCount(int readCount) {
348         if (readCount != _readCount) {
349             _readCount = readCount;
350         }
351     }
352 
353     public String getExtraSettings() {
354         return GetterUtil.getString(_extraSettings);
355     }
356 
357     public void setExtraSettings(String extraSettings) {
358         if (((extraSettings == null) && (_extraSettings != null)) ||
359                 ((extraSettings != null) && (_extraSettings == null)) ||
360                 ((extraSettings != null) && (_extraSettings != null) &&
361                 !extraSettings.equals(_extraSettings))) {
362             _extraSettings = extraSettings;
363         }
364     }
365 
366     public DLFileEntry toEscapedModel() {
367         if (isEscapedModel()) {
368             return (DLFileEntry)this;
369         }
370         else {
371             DLFileEntry model = new DLFileEntryImpl();
372 
373             model.setNew(isNew());
374             model.setEscapedModel(true);
375 
376             model.setUuid(HtmlUtil.escape(getUuid()));
377             model.setFileEntryId(getFileEntryId());
378             model.setCompanyId(getCompanyId());
379             model.setUserId(getUserId());
380             model.setUserName(HtmlUtil.escape(getUserName()));
381             model.setVersionUserId(getVersionUserId());
382             model.setVersionUserName(HtmlUtil.escape(getVersionUserName()));
383             model.setCreateDate(getCreateDate());
384             model.setModifiedDate(getModifiedDate());
385             model.setFolderId(getFolderId());
386             model.setName(HtmlUtil.escape(getName()));
387             model.setTitle(HtmlUtil.escape(getTitle()));
388             model.setDescription(HtmlUtil.escape(getDescription()));
389             model.setVersion(getVersion());
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 Object clone() {
403         DLFileEntryImpl clone = new DLFileEntryImpl();
404 
405         clone.setUuid(getUuid());
406         clone.setFileEntryId(getFileEntryId());
407         clone.setCompanyId(getCompanyId());
408         clone.setUserId(getUserId());
409         clone.setUserName(getUserName());
410         clone.setVersionUserId(getVersionUserId());
411         clone.setVersionUserName(getVersionUserName());
412         clone.setCreateDate(getCreateDate());
413         clone.setModifiedDate(getModifiedDate());
414         clone.setFolderId(getFolderId());
415         clone.setName(getName());
416         clone.setTitle(getTitle());
417         clone.setDescription(getDescription());
418         clone.setVersion(getVersion());
419         clone.setSize(getSize());
420         clone.setReadCount(getReadCount());
421         clone.setExtraSettings(getExtraSettings());
422 
423         return clone;
424     }
425 
426     public int compareTo(Object obj) {
427         if (obj == null) {
428             return -1;
429         }
430 
431         DLFileEntryImpl dlFileEntry = (DLFileEntryImpl)obj;
432 
433         int value = 0;
434 
435         if (getFolderId() < dlFileEntry.getFolderId()) {
436             value = -1;
437         }
438         else if (getFolderId() > dlFileEntry.getFolderId()) {
439             value = 1;
440         }
441         else {
442             value = 0;
443         }
444 
445         if (value != 0) {
446             return value;
447         }
448 
449         value = getName().compareTo(dlFileEntry.getName());
450 
451         if (value != 0) {
452             return value;
453         }
454 
455         return 0;
456     }
457 
458     public boolean equals(Object obj) {
459         if (obj == null) {
460             return false;
461         }
462 
463         DLFileEntryImpl dlFileEntry = null;
464 
465         try {
466             dlFileEntry = (DLFileEntryImpl)obj;
467         }
468         catch (ClassCastException cce) {
469             return false;
470         }
471 
472         long pk = dlFileEntry.getPrimaryKey();
473 
474         if (getPrimaryKey() == pk) {
475             return true;
476         }
477         else {
478             return false;
479         }
480     }
481 
482     public int hashCode() {
483         return (int)getPrimaryKey();
484     }
485 
486     private String _uuid;
487     private long _fileEntryId;
488     private long _companyId;
489     private long _userId;
490     private String _userName;
491     private long _versionUserId;
492     private String _versionUserName;
493     private Date _createDate;
494     private Date _modifiedDate;
495     private long _folderId;
496     private String _name;
497     private String _title;
498     private String _description;
499     private double _version;
500     private int _size;
501     private int _readCount;
502     private String _extraSettings;
503 }