1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.kernel.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  import java.util.Date;
36  
37  /**
38   * <a href="DLFileEntryModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be overwritten
42   * the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>DLFileEntry</code> table in the
47   * database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portlet.documentlibrary.service.model.DLFileEntry
53   * @see com.liferay.portlet.documentlibrary.service.model.DLFileEntryModel
54   * @see com.liferay.portlet.documentlibrary.service.model.impl.DLFileEntryImpl
55   *
56   */
57  public class DLFileEntryModelImpl extends BaseModelImpl {
58      public static String TABLE_NAME = "DLFileEntry";
59      public static Object[][] TABLE_COLUMNS = {
60              { "fileEntryId", new Integer(Types.BIGINT) },
61              { "companyId", new Integer(Types.BIGINT) },
62              { "userId", new Integer(Types.BIGINT) },
63              { "userName", new Integer(Types.VARCHAR) },
64              { "versionUserId", new Integer(Types.BIGINT) },
65              { "versionUserName", new Integer(Types.VARCHAR) },
66              { "createDate", new Integer(Types.TIMESTAMP) },
67              { "modifiedDate", new Integer(Types.TIMESTAMP) },
68              { "folderId", new Integer(Types.BIGINT) },
69              { "name", new Integer(Types.VARCHAR) },
70              { "title", new Integer(Types.VARCHAR) },
71              { "description", new Integer(Types.VARCHAR) },
72              { "version", new Integer(Types.DOUBLE) },
73              { "size_", new Integer(Types.INTEGER) },
74              { "readCount", new Integer(Types.INTEGER) },
75              { "extraSettings", new Integer(Types.CLOB) }
76          };
77      public static String TABLE_SQL_CREATE = "create table DLFileEntry (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)";
78      public static String TABLE_SQL_DROP = "drop table DLFileEntry";
79      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
80                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileEntry"),
81              XSS_ALLOW);
82      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
83                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileEntry.userName"),
84              XSS_ALLOW_BY_MODEL);
85      public static boolean XSS_ALLOW_VERSIONUSERNAME = GetterUtil.getBoolean(PropsUtil.get(
86                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileEntry.versionUserName"),
87              XSS_ALLOW_BY_MODEL);
88      public static boolean XSS_ALLOW_NAME = GetterUtil.getBoolean(PropsUtil.get(
89                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileEntry.name"),
90              XSS_ALLOW_BY_MODEL);
91      public static boolean XSS_ALLOW_TITLE = GetterUtil.getBoolean(PropsUtil.get(
92                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileEntry.title"),
93              XSS_ALLOW_BY_MODEL);
94      public static boolean XSS_ALLOW_DESCRIPTION = GetterUtil.getBoolean(PropsUtil.get(
95                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileEntry.description"),
96              XSS_ALLOW_BY_MODEL);
97      public static boolean XSS_ALLOW_EXTRASETTINGS = GetterUtil.getBoolean(PropsUtil.get(
98                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileEntry.extraSettings"),
99              XSS_ALLOW_BY_MODEL);
100     public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
101                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileEntryModel"));
102 
103     public DLFileEntryModelImpl() {
104     }
105 
106     public long getPrimaryKey() {
107         return _fileEntryId;
108     }
109 
110     public void setPrimaryKey(long pk) {
111         setFileEntryId(pk);
112     }
113 
114     public Serializable getPrimaryKeyObj() {
115         return new Long(_fileEntryId);
116     }
117 
118     public long getFileEntryId() {
119         return _fileEntryId;
120     }
121 
122     public void setFileEntryId(long fileEntryId) {
123         if (fileEntryId != _fileEntryId) {
124             _fileEntryId = fileEntryId;
125         }
126     }
127 
128     public long getCompanyId() {
129         return _companyId;
130     }
131 
132     public void setCompanyId(long companyId) {
133         if (companyId != _companyId) {
134             _companyId = companyId;
135         }
136     }
137 
138     public long getUserId() {
139         return _userId;
140     }
141 
142     public void setUserId(long userId) {
143         if (userId != _userId) {
144             _userId = userId;
145         }
146     }
147 
148     public String getUserName() {
149         return GetterUtil.getString(_userName);
150     }
151 
152     public void setUserName(String userName) {
153         if (((userName == null) && (_userName != null)) ||
154                 ((userName != null) && (_userName == null)) ||
155                 ((userName != null) && (_userName != null) &&
156                 !userName.equals(_userName))) {
157             if (!XSS_ALLOW_USERNAME) {
158                 userName = XSSUtil.strip(userName);
159             }
160 
161             _userName = userName;
162         }
163     }
164 
165     public long getVersionUserId() {
166         return _versionUserId;
167     }
168 
169     public void setVersionUserId(long versionUserId) {
170         if (versionUserId != _versionUserId) {
171             _versionUserId = versionUserId;
172         }
173     }
174 
175     public String getVersionUserName() {
176         return GetterUtil.getString(_versionUserName);
177     }
178 
179     public void setVersionUserName(String versionUserName) {
180         if (((versionUserName == null) && (_versionUserName != null)) ||
181                 ((versionUserName != null) && (_versionUserName == null)) ||
182                 ((versionUserName != null) && (_versionUserName != null) &&
183                 !versionUserName.equals(_versionUserName))) {
184             if (!XSS_ALLOW_VERSIONUSERNAME) {
185                 versionUserName = XSSUtil.strip(versionUserName);
186             }
187 
188             _versionUserName = versionUserName;
189         }
190     }
191 
192     public Date getCreateDate() {
193         return _createDate;
194     }
195 
196     public void setCreateDate(Date createDate) {
197         if (((createDate == null) && (_createDate != null)) ||
198                 ((createDate != null) && (_createDate == null)) ||
199                 ((createDate != null) && (_createDate != null) &&
200                 !createDate.equals(_createDate))) {
201             _createDate = createDate;
202         }
203     }
204 
205     public Date getModifiedDate() {
206         return _modifiedDate;
207     }
208 
209     public void setModifiedDate(Date modifiedDate) {
210         if (((modifiedDate == null) && (_modifiedDate != null)) ||
211                 ((modifiedDate != null) && (_modifiedDate == null)) ||
212                 ((modifiedDate != null) && (_modifiedDate != null) &&
213                 !modifiedDate.equals(_modifiedDate))) {
214             _modifiedDate = modifiedDate;
215         }
216     }
217 
218     public long getFolderId() {
219         return _folderId;
220     }
221 
222     public void setFolderId(long folderId) {
223         if (folderId != _folderId) {
224             _folderId = folderId;
225         }
226     }
227 
228     public String getName() {
229         return GetterUtil.getString(_name);
230     }
231 
232     public void setName(String name) {
233         if (((name == null) && (_name != null)) ||
234                 ((name != null) && (_name == null)) ||
235                 ((name != null) && (_name != null) && !name.equals(_name))) {
236             if (!XSS_ALLOW_NAME) {
237                 name = XSSUtil.strip(name);
238             }
239 
240             _name = name;
241         }
242     }
243 
244     public String getTitle() {
245         return GetterUtil.getString(_title);
246     }
247 
248     public void setTitle(String title) {
249         if (((title == null) && (_title != null)) ||
250                 ((title != null) && (_title == null)) ||
251                 ((title != null) && (_title != null) && !title.equals(_title))) {
252             if (!XSS_ALLOW_TITLE) {
253                 title = XSSUtil.strip(title);
254             }
255 
256             _title = title;
257         }
258     }
259 
260     public String getDescription() {
261         return GetterUtil.getString(_description);
262     }
263 
264     public void setDescription(String description) {
265         if (((description == null) && (_description != null)) ||
266                 ((description != null) && (_description == null)) ||
267                 ((description != null) && (_description != null) &&
268                 !description.equals(_description))) {
269             if (!XSS_ALLOW_DESCRIPTION) {
270                 description = XSSUtil.strip(description);
271             }
272 
273             _description = description;
274         }
275     }
276 
277     public double getVersion() {
278         return _version;
279     }
280 
281     public void setVersion(double version) {
282         if (version != _version) {
283             _version = version;
284         }
285     }
286 
287     public int getSize() {
288         return _size;
289     }
290 
291     public void setSize(int size) {
292         if (size != _size) {
293             _size = size;
294         }
295     }
296 
297     public int getReadCount() {
298         return _readCount;
299     }
300 
301     public void setReadCount(int readCount) {
302         if (readCount != _readCount) {
303             _readCount = readCount;
304         }
305     }
306 
307     public String getExtraSettings() {
308         return GetterUtil.getString(_extraSettings);
309     }
310 
311     public void setExtraSettings(String extraSettings) {
312         if (((extraSettings == null) && (_extraSettings != null)) ||
313                 ((extraSettings != null) && (_extraSettings == null)) ||
314                 ((extraSettings != null) && (_extraSettings != null) &&
315                 !extraSettings.equals(_extraSettings))) {
316             if (!XSS_ALLOW_EXTRASETTINGS) {
317                 extraSettings = XSSUtil.strip(extraSettings);
318             }
319 
320             _extraSettings = extraSettings;
321         }
322     }
323 
324     public Object clone() {
325         DLFileEntryImpl clone = new DLFileEntryImpl();
326         clone.setFileEntryId(getFileEntryId());
327         clone.setCompanyId(getCompanyId());
328         clone.setUserId(getUserId());
329         clone.setUserName(getUserName());
330         clone.setVersionUserId(getVersionUserId());
331         clone.setVersionUserName(getVersionUserName());
332         clone.setCreateDate(getCreateDate());
333         clone.setModifiedDate(getModifiedDate());
334         clone.setFolderId(getFolderId());
335         clone.setName(getName());
336         clone.setTitle(getTitle());
337         clone.setDescription(getDescription());
338         clone.setVersion(getVersion());
339         clone.setSize(getSize());
340         clone.setReadCount(getReadCount());
341         clone.setExtraSettings(getExtraSettings());
342 
343         return clone;
344     }
345 
346     public int compareTo(Object obj) {
347         if (obj == null) {
348             return -1;
349         }
350 
351         DLFileEntryImpl dlFileEntry = (DLFileEntryImpl)obj;
352         int value = 0;
353 
354         if (getFolderId() < dlFileEntry.getFolderId()) {
355             value = -1;
356         }
357         else if (getFolderId() > dlFileEntry.getFolderId()) {
358             value = 1;
359         }
360         else {
361             value = 0;
362         }
363 
364         if (value != 0) {
365             return value;
366         }
367 
368         value = getName().compareTo(dlFileEntry.getName());
369 
370         if (value != 0) {
371             return value;
372         }
373 
374         return 0;
375     }
376 
377     public boolean equals(Object obj) {
378         if (obj == null) {
379             return false;
380         }
381 
382         DLFileEntryImpl dlFileEntry = null;
383 
384         try {
385             dlFileEntry = (DLFileEntryImpl)obj;
386         }
387         catch (ClassCastException cce) {
388             return false;
389         }
390 
391         long pk = dlFileEntry.getPrimaryKey();
392 
393         if (getPrimaryKey() == pk) {
394             return true;
395         }
396         else {
397             return false;
398         }
399     }
400 
401     public int hashCode() {
402         return (int)getPrimaryKey();
403     }
404 
405     private long _fileEntryId;
406     private long _companyId;
407     private long _userId;
408     private String _userName;
409     private long _versionUserId;
410     private String _versionUserName;
411     private Date _createDate;
412     private Date _modifiedDate;
413     private long _folderId;
414     private String _name;
415     private String _title;
416     private String _description;
417     private double _version;
418     private int _size;
419     private int _readCount;
420     private String _extraSettings;
421 }