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