1   /**
2    * Copyright (c) 2000-2008 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.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.portlet.documentlibrary.model.DLFileRank;
32  
33  import com.liferay.util.Html;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.Date;
42  
43  /**
44   * <a href="DLFileRankModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>DLFileRank</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.documentlibrary.service.model.DLFileRank
59   * @see com.liferay.portlet.documentlibrary.service.model.DLFileRankModel
60   * @see com.liferay.portlet.documentlibrary.service.model.impl.DLFileRankImpl
61   *
62   */
63  public class DLFileRankModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "DLFileRank";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "fileRankId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "userId", new Integer(Types.BIGINT) },
73              
74  
75              { "createDate", new Integer(Types.TIMESTAMP) },
76              
77  
78              { "folderId", new Integer(Types.BIGINT) },
79              
80  
81              { "name", new Integer(Types.VARCHAR) }
82          };
83      public static final String TABLE_SQL_CREATE = "create table DLFileRank (fileRankId LONG not null primary key,companyId LONG,userId LONG,createDate DATE null,folderId LONG,name VARCHAR(300) null)";
84      public static final String TABLE_SQL_DROP = "drop table DLFileRank";
85      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
86                  "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileRank"),
87              true);
88      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
89                  "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileRank"));
90  
91      public DLFileRankModelImpl() {
92      }
93  
94      public long getPrimaryKey() {
95          return _fileRankId;
96      }
97  
98      public void setPrimaryKey(long pk) {
99          setFileRankId(pk);
100     }
101 
102     public Serializable getPrimaryKeyObj() {
103         return new Long(_fileRankId);
104     }
105 
106     public long getFileRankId() {
107         return _fileRankId;
108     }
109 
110     public void setFileRankId(long fileRankId) {
111         if (fileRankId != _fileRankId) {
112             _fileRankId = fileRankId;
113         }
114     }
115 
116     public long getCompanyId() {
117         return _companyId;
118     }
119 
120     public void setCompanyId(long companyId) {
121         if (companyId != _companyId) {
122             _companyId = companyId;
123         }
124     }
125 
126     public long getUserId() {
127         return _userId;
128     }
129 
130     public void setUserId(long userId) {
131         if (userId != _userId) {
132             _userId = userId;
133         }
134     }
135 
136     public Date getCreateDate() {
137         return _createDate;
138     }
139 
140     public void setCreateDate(Date createDate) {
141         if (((createDate == null) && (_createDate != null)) ||
142                 ((createDate != null) && (_createDate == null)) ||
143                 ((createDate != null) && (_createDate != null) &&
144                 !createDate.equals(_createDate))) {
145             _createDate = createDate;
146         }
147     }
148 
149     public long getFolderId() {
150         return _folderId;
151     }
152 
153     public void setFolderId(long folderId) {
154         if (folderId != _folderId) {
155             _folderId = folderId;
156         }
157     }
158 
159     public String getName() {
160         return GetterUtil.getString(_name);
161     }
162 
163     public void setName(String name) {
164         if (((name == null) && (_name != null)) ||
165                 ((name != null) && (_name == null)) ||
166                 ((name != null) && (_name != null) && !name.equals(_name))) {
167             _name = name;
168         }
169     }
170 
171     public DLFileRank toEscapedModel() {
172         if (isEscapedModel()) {
173             return (DLFileRank)this;
174         }
175         else {
176             DLFileRank model = new DLFileRankImpl();
177 
178             model.setEscapedModel(true);
179 
180             model.setFileRankId(getFileRankId());
181             model.setCompanyId(getCompanyId());
182             model.setUserId(getUserId());
183             model.setCreateDate(getCreateDate());
184             model.setFolderId(getFolderId());
185             model.setName(Html.escape(getName()));
186 
187             model = (DLFileRank)Proxy.newProxyInstance(DLFileRank.class.getClassLoader(),
188                     new Class[] { DLFileRank.class },
189                     new ReadOnlyBeanHandler(model));
190 
191             return model;
192         }
193     }
194 
195     public Object clone() {
196         DLFileRankImpl clone = new DLFileRankImpl();
197 
198         clone.setFileRankId(getFileRankId());
199         clone.setCompanyId(getCompanyId());
200         clone.setUserId(getUserId());
201         clone.setCreateDate(getCreateDate());
202         clone.setFolderId(getFolderId());
203         clone.setName(getName());
204 
205         return clone;
206     }
207 
208     public int compareTo(Object obj) {
209         if (obj == null) {
210             return -1;
211         }
212 
213         DLFileRankImpl dlFileRank = (DLFileRankImpl)obj;
214 
215         int value = 0;
216 
217         value = DateUtil.compareTo(getCreateDate(), dlFileRank.getCreateDate());
218 
219         value = value * -1;
220 
221         if (value != 0) {
222             return value;
223         }
224 
225         return 0;
226     }
227 
228     public boolean equals(Object obj) {
229         if (obj == null) {
230             return false;
231         }
232 
233         DLFileRankImpl dlFileRank = null;
234 
235         try {
236             dlFileRank = (DLFileRankImpl)obj;
237         }
238         catch (ClassCastException cce) {
239             return false;
240         }
241 
242         long pk = dlFileRank.getPrimaryKey();
243 
244         if (getPrimaryKey() == pk) {
245             return true;
246         }
247         else {
248             return false;
249         }
250     }
251 
252     public int hashCode() {
253         return (int)getPrimaryKey();
254     }
255 
256     private long _fileRankId;
257     private long _companyId;
258     private long _userId;
259     private Date _createDate;
260     private long _folderId;
261     private String _name;
262 }