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="DLFileVersionModelImpl.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>DLFileVersion</code> table in
47   * the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portlet.documentlibrary.service.model.DLFileVersion
53   * @see com.liferay.portlet.documentlibrary.service.model.DLFileVersionModel
54   * @see com.liferay.portlet.documentlibrary.service.model.impl.DLFileVersionImpl
55   *
56   */
57  public class DLFileVersionModelImpl extends BaseModelImpl {
58      public static String TABLE_NAME = "DLFileVersion";
59      public static Object[][] TABLE_COLUMNS = {
60              { "fileVersionId", new Integer(Types.BIGINT) },
61              { "companyId", new Integer(Types.BIGINT) },
62              { "userId", new Integer(Types.BIGINT) },
63              { "userName", new Integer(Types.VARCHAR) },
64              { "createDate", new Integer(Types.TIMESTAMP) },
65              { "folderId", new Integer(Types.BIGINT) },
66              { "name", new Integer(Types.VARCHAR) },
67              { "version", new Integer(Types.DOUBLE) },
68              { "size_", new Integer(Types.INTEGER) }
69          };
70      public static String TABLE_SQL_CREATE = "create table DLFileVersion (fileVersionId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,folderId LONG,name VARCHAR(300) null,version DOUBLE,size_ INTEGER)";
71      public static String TABLE_SQL_DROP = "drop table DLFileVersion";
72      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
73                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileVersion"),
74              XSS_ALLOW);
75      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
76                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileVersion.userName"),
77              XSS_ALLOW_BY_MODEL);
78      public static boolean XSS_ALLOW_NAME = GetterUtil.getBoolean(PropsUtil.get(
79                  "xss.allow.com.liferay.portlet.documentlibrary.model.DLFileVersion.name"),
80              XSS_ALLOW_BY_MODEL);
81      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
82                  "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileVersionModel"));
83  
84      public DLFileVersionModelImpl() {
85      }
86  
87      public long getPrimaryKey() {
88          return _fileVersionId;
89      }
90  
91      public void setPrimaryKey(long pk) {
92          setFileVersionId(pk);
93      }
94  
95      public Serializable getPrimaryKeyObj() {
96          return new Long(_fileVersionId);
97      }
98  
99      public long getFileVersionId() {
100         return _fileVersionId;
101     }
102 
103     public void setFileVersionId(long fileVersionId) {
104         if (fileVersionId != _fileVersionId) {
105             _fileVersionId = fileVersionId;
106         }
107     }
108 
109     public long getCompanyId() {
110         return _companyId;
111     }
112 
113     public void setCompanyId(long companyId) {
114         if (companyId != _companyId) {
115             _companyId = companyId;
116         }
117     }
118 
119     public long getUserId() {
120         return _userId;
121     }
122 
123     public void setUserId(long userId) {
124         if (userId != _userId) {
125             _userId = userId;
126         }
127     }
128 
129     public String getUserName() {
130         return GetterUtil.getString(_userName);
131     }
132 
133     public void setUserName(String userName) {
134         if (((userName == null) && (_userName != null)) ||
135                 ((userName != null) && (_userName == null)) ||
136                 ((userName != null) && (_userName != null) &&
137                 !userName.equals(_userName))) {
138             if (!XSS_ALLOW_USERNAME) {
139                 userName = XSSUtil.strip(userName);
140             }
141 
142             _userName = userName;
143         }
144     }
145 
146     public Date getCreateDate() {
147         return _createDate;
148     }
149 
150     public void setCreateDate(Date createDate) {
151         if (((createDate == null) && (_createDate != null)) ||
152                 ((createDate != null) && (_createDate == null)) ||
153                 ((createDate != null) && (_createDate != null) &&
154                 !createDate.equals(_createDate))) {
155             _createDate = createDate;
156         }
157     }
158 
159     public long getFolderId() {
160         return _folderId;
161     }
162 
163     public void setFolderId(long folderId) {
164         if (folderId != _folderId) {
165             _folderId = folderId;
166         }
167     }
168 
169     public String getName() {
170         return GetterUtil.getString(_name);
171     }
172 
173     public void setName(String name) {
174         if (((name == null) && (_name != null)) ||
175                 ((name != null) && (_name == null)) ||
176                 ((name != null) && (_name != null) && !name.equals(_name))) {
177             if (!XSS_ALLOW_NAME) {
178                 name = XSSUtil.strip(name);
179             }
180 
181             _name = name;
182         }
183     }
184 
185     public double getVersion() {
186         return _version;
187     }
188 
189     public void setVersion(double version) {
190         if (version != _version) {
191             _version = version;
192         }
193     }
194 
195     public int getSize() {
196         return _size;
197     }
198 
199     public void setSize(int size) {
200         if (size != _size) {
201             _size = size;
202         }
203     }
204 
205     public Object clone() {
206         DLFileVersionImpl clone = new DLFileVersionImpl();
207         clone.setFileVersionId(getFileVersionId());
208         clone.setCompanyId(getCompanyId());
209         clone.setUserId(getUserId());
210         clone.setUserName(getUserName());
211         clone.setCreateDate(getCreateDate());
212         clone.setFolderId(getFolderId());
213         clone.setName(getName());
214         clone.setVersion(getVersion());
215         clone.setSize(getSize());
216 
217         return clone;
218     }
219 
220     public int compareTo(Object obj) {
221         if (obj == null) {
222             return -1;
223         }
224 
225         DLFileVersionImpl dlFileVersion = (DLFileVersionImpl)obj;
226         int value = 0;
227 
228         if (getFolderId() < dlFileVersion.getFolderId()) {
229             value = -1;
230         }
231         else if (getFolderId() > dlFileVersion.getFolderId()) {
232             value = 1;
233         }
234         else {
235             value = 0;
236         }
237 
238         value = value * -1;
239 
240         if (value != 0) {
241             return value;
242         }
243 
244         value = getName().compareTo(dlFileVersion.getName());
245         value = value * -1;
246 
247         if (value != 0) {
248             return value;
249         }
250 
251         if (getVersion() < dlFileVersion.getVersion()) {
252             value = -1;
253         }
254         else if (getVersion() > dlFileVersion.getVersion()) {
255             value = 1;
256         }
257         else {
258             value = 0;
259         }
260 
261         value = value * -1;
262 
263         if (value != 0) {
264             return value;
265         }
266 
267         return 0;
268     }
269 
270     public boolean equals(Object obj) {
271         if (obj == null) {
272             return false;
273         }
274 
275         DLFileVersionImpl dlFileVersion = null;
276 
277         try {
278             dlFileVersion = (DLFileVersionImpl)obj;
279         }
280         catch (ClassCastException cce) {
281             return false;
282         }
283 
284         long pk = dlFileVersion.getPrimaryKey();
285 
286         if (getPrimaryKey() == pk) {
287             return true;
288         }
289         else {
290             return false;
291         }
292     }
293 
294     public int hashCode() {
295         return (int)getPrimaryKey();
296     }
297 
298     private long _fileVersionId;
299     private long _companyId;
300     private long _userId;
301     private String _userName;
302     private Date _createDate;
303     private long _folderId;
304     private String _name;
305     private double _version;
306     private int _size;
307 }