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