1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.documentlibrary.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.DateUtil;
24  import com.liferay.portal.kernel.util.GetterUtil;
25  import com.liferay.portal.kernel.util.HtmlUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  
28  import com.liferay.portlet.documentlibrary.model.DLFileRank;
29  import com.liferay.portlet.documentlibrary.model.DLFileRankSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.Date;
39  import java.util.List;
40  
41  /**
42   * <a href="DLFileRankModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>DLFileRank</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portlet.documentlibrary.model.DLFileRank
57   * @see com.liferay.portlet.documentlibrary.model.DLFileRankModel
58   * @see com.liferay.portlet.documentlibrary.model.impl.DLFileRankImpl
59   *
60   */
61  public class DLFileRankModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "DLFileRank";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "fileRankId", new Integer(Types.BIGINT) },
65              
66  
67              { "companyId", new Integer(Types.BIGINT) },
68              
69  
70              { "userId", new Integer(Types.BIGINT) },
71              
72  
73              { "createDate", new Integer(Types.TIMESTAMP) },
74              
75  
76              { "folderId", new Integer(Types.BIGINT) },
77              
78  
79              { "name", new Integer(Types.VARCHAR) }
80          };
81      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)";
82      public static final String TABLE_SQL_DROP = "drop table DLFileRank";
83      public static final String DATA_SOURCE = "liferayDataSource";
84      public static final String SESSION_FACTORY = "liferaySessionFactory";
85      public static final String TX_MANAGER = "liferayTransactionManager";
86      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87                  "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileRank"),
88              true);
89  
90      public static DLFileRank toModel(DLFileRankSoap soapModel) {
91          DLFileRank model = new DLFileRankImpl();
92  
93          model.setFileRankId(soapModel.getFileRankId());
94          model.setCompanyId(soapModel.getCompanyId());
95          model.setUserId(soapModel.getUserId());
96          model.setCreateDate(soapModel.getCreateDate());
97          model.setFolderId(soapModel.getFolderId());
98          model.setName(soapModel.getName());
99  
100         return model;
101     }
102 
103     public static List<DLFileRank> toModels(DLFileRankSoap[] soapModels) {
104         List<DLFileRank> models = new ArrayList<DLFileRank>(soapModels.length);
105 
106         for (DLFileRankSoap soapModel : soapModels) {
107             models.add(toModel(soapModel));
108         }
109 
110         return models;
111     }
112 
113     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
114                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileRank"));
115 
116     public DLFileRankModelImpl() {
117     }
118 
119     public long getPrimaryKey() {
120         return _fileRankId;
121     }
122 
123     public void setPrimaryKey(long pk) {
124         setFileRankId(pk);
125     }
126 
127     public Serializable getPrimaryKeyObj() {
128         return new Long(_fileRankId);
129     }
130 
131     public long getFileRankId() {
132         return _fileRankId;
133     }
134 
135     public void setFileRankId(long fileRankId) {
136         if (fileRankId != _fileRankId) {
137             _fileRankId = fileRankId;
138         }
139     }
140 
141     public long getCompanyId() {
142         return _companyId;
143     }
144 
145     public void setCompanyId(long companyId) {
146         if (companyId != _companyId) {
147             _companyId = companyId;
148         }
149     }
150 
151     public long getUserId() {
152         return _userId;
153     }
154 
155     public void setUserId(long userId) {
156         if (userId != _userId) {
157             _userId = userId;
158         }
159     }
160 
161     public Date getCreateDate() {
162         return _createDate;
163     }
164 
165     public void setCreateDate(Date createDate) {
166         if (((createDate == null) && (_createDate != null)) ||
167                 ((createDate != null) && (_createDate == null)) ||
168                 ((createDate != null) && (_createDate != null) &&
169                 !createDate.equals(_createDate))) {
170             _createDate = createDate;
171         }
172     }
173 
174     public long getFolderId() {
175         return _folderId;
176     }
177 
178     public void setFolderId(long folderId) {
179         if (folderId != _folderId) {
180             _folderId = folderId;
181         }
182     }
183 
184     public String getName() {
185         return GetterUtil.getString(_name);
186     }
187 
188     public void setName(String name) {
189         if (((name == null) && (_name != null)) ||
190                 ((name != null) && (_name == null)) ||
191                 ((name != null) && (_name != null) && !name.equals(_name))) {
192             _name = name;
193         }
194     }
195 
196     public DLFileRank toEscapedModel() {
197         if (isEscapedModel()) {
198             return (DLFileRank)this;
199         }
200         else {
201             DLFileRank model = new DLFileRankImpl();
202 
203             model.setNew(isNew());
204             model.setEscapedModel(true);
205 
206             model.setFileRankId(getFileRankId());
207             model.setCompanyId(getCompanyId());
208             model.setUserId(getUserId());
209             model.setCreateDate(getCreateDate());
210             model.setFolderId(getFolderId());
211             model.setName(HtmlUtil.escape(getName()));
212 
213             model = (DLFileRank)Proxy.newProxyInstance(DLFileRank.class.getClassLoader(),
214                     new Class[] { DLFileRank.class },
215                     new ReadOnlyBeanHandler(model));
216 
217             return model;
218         }
219     }
220 
221     public Object clone() {
222         DLFileRankImpl clone = new DLFileRankImpl();
223 
224         clone.setFileRankId(getFileRankId());
225         clone.setCompanyId(getCompanyId());
226         clone.setUserId(getUserId());
227         clone.setCreateDate(getCreateDate());
228         clone.setFolderId(getFolderId());
229         clone.setName(getName());
230 
231         return clone;
232     }
233 
234     public int compareTo(Object obj) {
235         if (obj == null) {
236             return -1;
237         }
238 
239         DLFileRankImpl dlFileRank = (DLFileRankImpl)obj;
240 
241         int value = 0;
242 
243         value = DateUtil.compareTo(getCreateDate(), dlFileRank.getCreateDate());
244 
245         value = value * -1;
246 
247         if (value != 0) {
248             return value;
249         }
250 
251         return 0;
252     }
253 
254     public boolean equals(Object obj) {
255         if (obj == null) {
256             return false;
257         }
258 
259         DLFileRankImpl dlFileRank = null;
260 
261         try {
262             dlFileRank = (DLFileRankImpl)obj;
263         }
264         catch (ClassCastException cce) {
265             return false;
266         }
267 
268         long pk = dlFileRank.getPrimaryKey();
269 
270         if (getPrimaryKey() == pk) {
271             return true;
272         }
273         else {
274             return false;
275         }
276     }
277 
278     public int hashCode() {
279         return (int)getPrimaryKey();
280     }
281 
282     private long _fileRankId;
283     private long _companyId;
284     private long _userId;
285     private Date _createDate;
286     private long _folderId;
287     private String _name;
288 }