1   /**
2    * Copyright (c) 2000-2009 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.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  
30  import com.liferay.portlet.documentlibrary.model.DLFileVersion;
31  import com.liferay.portlet.documentlibrary.model.DLFileVersionSoap;
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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="DLFileVersionModelImpl.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 class is a model that represents the <code>DLFileVersion</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.documentlibrary.model.DLFileVersion
61   * @see com.liferay.portlet.documentlibrary.model.DLFileVersionModel
62   * @see com.liferay.portlet.documentlibrary.model.impl.DLFileVersionImpl
63   *
64   */
65  public class DLFileVersionModelImpl extends BaseModelImpl {
66      public static final String TABLE_NAME = "DLFileVersion";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "fileVersionId", new Integer(Types.BIGINT) },
69              
70  
71              { "companyId", new Integer(Types.BIGINT) },
72              
73  
74              { "userId", new Integer(Types.BIGINT) },
75              
76  
77              { "userName", new Integer(Types.VARCHAR) },
78              
79  
80              { "createDate", new Integer(Types.TIMESTAMP) },
81              
82  
83              { "folderId", new Integer(Types.BIGINT) },
84              
85  
86              { "name", new Integer(Types.VARCHAR) },
87              
88  
89              { "version", new Integer(Types.DOUBLE) },
90              
91  
92              { "size_", new Integer(Types.INTEGER) }
93          };
94      public static final 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)";
95      public static final String TABLE_SQL_DROP = "drop table DLFileVersion";
96      public static final String DATA_SOURCE = "liferayDataSource";
97      public static final String SESSION_FACTORY = "liferaySessionFactory";
98      public static final String TX_MANAGER = "liferayTransactionManager";
99      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
100                 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileVersion"),
101             true);
102 
103     public static DLFileVersion toModel(DLFileVersionSoap soapModel) {
104         DLFileVersion model = new DLFileVersionImpl();
105 
106         model.setFileVersionId(soapModel.getFileVersionId());
107         model.setCompanyId(soapModel.getCompanyId());
108         model.setUserId(soapModel.getUserId());
109         model.setUserName(soapModel.getUserName());
110         model.setCreateDate(soapModel.getCreateDate());
111         model.setFolderId(soapModel.getFolderId());
112         model.setName(soapModel.getName());
113         model.setVersion(soapModel.getVersion());
114         model.setSize(soapModel.getSize());
115 
116         return model;
117     }
118 
119     public static List<DLFileVersion> toModels(DLFileVersionSoap[] soapModels) {
120         List<DLFileVersion> models = new ArrayList<DLFileVersion>(soapModels.length);
121 
122         for (DLFileVersionSoap soapModel : soapModels) {
123             models.add(toModel(soapModel));
124         }
125 
126         return models;
127     }
128 
129     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
130                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileVersion"));
131 
132     public DLFileVersionModelImpl() {
133     }
134 
135     public long getPrimaryKey() {
136         return _fileVersionId;
137     }
138 
139     public void setPrimaryKey(long pk) {
140         setFileVersionId(pk);
141     }
142 
143     public Serializable getPrimaryKeyObj() {
144         return new Long(_fileVersionId);
145     }
146 
147     public long getFileVersionId() {
148         return _fileVersionId;
149     }
150 
151     public void setFileVersionId(long fileVersionId) {
152         if (fileVersionId != _fileVersionId) {
153             _fileVersionId = fileVersionId;
154         }
155     }
156 
157     public long getCompanyId() {
158         return _companyId;
159     }
160 
161     public void setCompanyId(long companyId) {
162         if (companyId != _companyId) {
163             _companyId = companyId;
164         }
165     }
166 
167     public long getUserId() {
168         return _userId;
169     }
170 
171     public void setUserId(long userId) {
172         if (userId != _userId) {
173             _userId = userId;
174         }
175     }
176 
177     public String getUserName() {
178         return GetterUtil.getString(_userName);
179     }
180 
181     public void setUserName(String userName) {
182         if (((userName == null) && (_userName != null)) ||
183                 ((userName != null) && (_userName == null)) ||
184                 ((userName != null) && (_userName != null) &&
185                 !userName.equals(_userName))) {
186             _userName = userName;
187         }
188     }
189 
190     public Date getCreateDate() {
191         return _createDate;
192     }
193 
194     public void setCreateDate(Date createDate) {
195         if (((createDate == null) && (_createDate != null)) ||
196                 ((createDate != null) && (_createDate == null)) ||
197                 ((createDate != null) && (_createDate != null) &&
198                 !createDate.equals(_createDate))) {
199             _createDate = createDate;
200         }
201     }
202 
203     public long getFolderId() {
204         return _folderId;
205     }
206 
207     public void setFolderId(long folderId) {
208         if (folderId != _folderId) {
209             _folderId = folderId;
210         }
211     }
212 
213     public String getName() {
214         return GetterUtil.getString(_name);
215     }
216 
217     public void setName(String name) {
218         if (((name == null) && (_name != null)) ||
219                 ((name != null) && (_name == null)) ||
220                 ((name != null) && (_name != null) && !name.equals(_name))) {
221             _name = name;
222         }
223     }
224 
225     public double getVersion() {
226         return _version;
227     }
228 
229     public void setVersion(double version) {
230         if (version != _version) {
231             _version = version;
232         }
233     }
234 
235     public int getSize() {
236         return _size;
237     }
238 
239     public void setSize(int size) {
240         if (size != _size) {
241             _size = size;
242         }
243     }
244 
245     public DLFileVersion toEscapedModel() {
246         if (isEscapedModel()) {
247             return (DLFileVersion)this;
248         }
249         else {
250             DLFileVersion model = new DLFileVersionImpl();
251 
252             model.setNew(isNew());
253             model.setEscapedModel(true);
254 
255             model.setFileVersionId(getFileVersionId());
256             model.setCompanyId(getCompanyId());
257             model.setUserId(getUserId());
258             model.setUserName(HtmlUtil.escape(getUserName()));
259             model.setCreateDate(getCreateDate());
260             model.setFolderId(getFolderId());
261             model.setName(HtmlUtil.escape(getName()));
262             model.setVersion(getVersion());
263             model.setSize(getSize());
264 
265             model = (DLFileVersion)Proxy.newProxyInstance(DLFileVersion.class.getClassLoader(),
266                     new Class[] { DLFileVersion.class },
267                     new ReadOnlyBeanHandler(model));
268 
269             return model;
270         }
271     }
272 
273     public ExpandoBridge getExpandoBridge() {
274         if (_expandoBridge == null) {
275             _expandoBridge = new ExpandoBridgeImpl(DLFileVersion.class.getName(),
276                     getPrimaryKey());
277         }
278 
279         return _expandoBridge;
280     }
281 
282     public Object clone() {
283         DLFileVersionImpl clone = new DLFileVersionImpl();
284 
285         clone.setFileVersionId(getFileVersionId());
286         clone.setCompanyId(getCompanyId());
287         clone.setUserId(getUserId());
288         clone.setUserName(getUserName());
289         clone.setCreateDate(getCreateDate());
290         clone.setFolderId(getFolderId());
291         clone.setName(getName());
292         clone.setVersion(getVersion());
293         clone.setSize(getSize());
294 
295         return clone;
296     }
297 
298     public int compareTo(Object obj) {
299         if (obj == null) {
300             return -1;
301         }
302 
303         DLFileVersionImpl dlFileVersion = (DLFileVersionImpl)obj;
304 
305         int value = 0;
306 
307         if (getFolderId() < dlFileVersion.getFolderId()) {
308             value = -1;
309         }
310         else if (getFolderId() > dlFileVersion.getFolderId()) {
311             value = 1;
312         }
313         else {
314             value = 0;
315         }
316 
317         value = value * -1;
318 
319         if (value != 0) {
320             return value;
321         }
322 
323         value = getName().compareTo(dlFileVersion.getName());
324 
325         value = value * -1;
326 
327         if (value != 0) {
328             return value;
329         }
330 
331         if (getVersion() < dlFileVersion.getVersion()) {
332             value = -1;
333         }
334         else if (getVersion() > dlFileVersion.getVersion()) {
335             value = 1;
336         }
337         else {
338             value = 0;
339         }
340 
341         value = value * -1;
342 
343         if (value != 0) {
344             return value;
345         }
346 
347         return 0;
348     }
349 
350     public boolean equals(Object obj) {
351         if (obj == null) {
352             return false;
353         }
354 
355         DLFileVersionImpl dlFileVersion = null;
356 
357         try {
358             dlFileVersion = (DLFileVersionImpl)obj;
359         }
360         catch (ClassCastException cce) {
361             return false;
362         }
363 
364         long pk = dlFileVersion.getPrimaryKey();
365 
366         if (getPrimaryKey() == pk) {
367             return true;
368         }
369         else {
370             return false;
371         }
372     }
373 
374     public int hashCode() {
375         return (int)getPrimaryKey();
376     }
377 
378     private long _fileVersionId;
379     private long _companyId;
380     private long _userId;
381     private String _userName;
382     private Date _createDate;
383     private long _folderId;
384     private String _name;
385     private double _version;
386     private int _size;
387     private transient ExpandoBridge _expandoBridge;
388 }