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.messageboards.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.messageboards.model.MBCategory;
31  import com.liferay.portlet.messageboards.model.MBCategorySoap;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="MBCategoryModelImpl.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>MBCategory</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.messageboards.service.model.MBCategory
59   * @see com.liferay.portlet.messageboards.service.model.MBCategoryModel
60   * @see com.liferay.portlet.messageboards.service.model.impl.MBCategoryImpl
61   *
62   */
63  public class MBCategoryModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "MBCategory";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "uuid_", new Integer(Types.VARCHAR) },
67              
68  
69              { "categoryId", new Integer(Types.BIGINT) },
70              
71  
72              { "groupId", new Integer(Types.BIGINT) },
73              
74  
75              { "companyId", new Integer(Types.BIGINT) },
76              
77  
78              { "userId", new Integer(Types.BIGINT) },
79              
80  
81              { "userName", new Integer(Types.VARCHAR) },
82              
83  
84              { "createDate", new Integer(Types.TIMESTAMP) },
85              
86  
87              { "modifiedDate", new Integer(Types.TIMESTAMP) },
88              
89  
90              { "parentCategoryId", new Integer(Types.BIGINT) },
91              
92  
93              { "name", new Integer(Types.VARCHAR) },
94              
95  
96              { "description", new Integer(Types.VARCHAR) },
97              
98  
99              { "lastPostDate", new Integer(Types.TIMESTAMP) }
100         };
101     public static final String TABLE_SQL_CREATE = "create table MBCategory (uuid_ VARCHAR(75) null,categoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentCategoryId LONG,name VARCHAR(75) null,description STRING null,lastPostDate DATE null)";
102     public static final String TABLE_SQL_DROP = "drop table MBCategory";
103     public static final String DATA_SOURCE = "liferayDataSource";
104     public static final String SESSION_FACTORY = "liferaySessionFactory";
105     public static final String TX_MANAGER = "liferayTransactionManager";
106     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
107                 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
108             true);
109 
110     public static MBCategory toModel(MBCategorySoap soapModel) {
111         MBCategory model = new MBCategoryImpl();
112 
113         model.setUuid(soapModel.getUuid());
114         model.setCategoryId(soapModel.getCategoryId());
115         model.setGroupId(soapModel.getGroupId());
116         model.setCompanyId(soapModel.getCompanyId());
117         model.setUserId(soapModel.getUserId());
118         model.setUserName(soapModel.getUserName());
119         model.setCreateDate(soapModel.getCreateDate());
120         model.setModifiedDate(soapModel.getModifiedDate());
121         model.setParentCategoryId(soapModel.getParentCategoryId());
122         model.setName(soapModel.getName());
123         model.setDescription(soapModel.getDescription());
124         model.setLastPostDate(soapModel.getLastPostDate());
125 
126         return model;
127     }
128 
129     public static List<MBCategory> toModels(MBCategorySoap[] soapModels) {
130         List<MBCategory> models = new ArrayList<MBCategory>(soapModels.length);
131 
132         for (MBCategorySoap soapModel : soapModels) {
133             models.add(toModel(soapModel));
134         }
135 
136         return models;
137     }
138 
139     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
140                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBCategory"));
141 
142     public MBCategoryModelImpl() {
143     }
144 
145     public long getPrimaryKey() {
146         return _categoryId;
147     }
148 
149     public void setPrimaryKey(long pk) {
150         setCategoryId(pk);
151     }
152 
153     public Serializable getPrimaryKeyObj() {
154         return new Long(_categoryId);
155     }
156 
157     public String getUuid() {
158         return GetterUtil.getString(_uuid);
159     }
160 
161     public void setUuid(String uuid) {
162         if ((uuid != null) && (uuid != _uuid)) {
163             _uuid = uuid;
164         }
165     }
166 
167     public long getCategoryId() {
168         return _categoryId;
169     }
170 
171     public void setCategoryId(long categoryId) {
172         if (categoryId != _categoryId) {
173             _categoryId = categoryId;
174         }
175     }
176 
177     public long getGroupId() {
178         return _groupId;
179     }
180 
181     public void setGroupId(long groupId) {
182         if (groupId != _groupId) {
183             _groupId = groupId;
184         }
185     }
186 
187     public long getCompanyId() {
188         return _companyId;
189     }
190 
191     public void setCompanyId(long companyId) {
192         if (companyId != _companyId) {
193             _companyId = companyId;
194         }
195     }
196 
197     public long getUserId() {
198         return _userId;
199     }
200 
201     public void setUserId(long userId) {
202         if (userId != _userId) {
203             _userId = userId;
204         }
205     }
206 
207     public String getUserName() {
208         return GetterUtil.getString(_userName);
209     }
210 
211     public void setUserName(String userName) {
212         if (((userName == null) && (_userName != null)) ||
213                 ((userName != null) && (_userName == null)) ||
214                 ((userName != null) && (_userName != null) &&
215                 !userName.equals(_userName))) {
216             _userName = userName;
217         }
218     }
219 
220     public Date getCreateDate() {
221         return _createDate;
222     }
223 
224     public void setCreateDate(Date createDate) {
225         if (((createDate == null) && (_createDate != null)) ||
226                 ((createDate != null) && (_createDate == null)) ||
227                 ((createDate != null) && (_createDate != null) &&
228                 !createDate.equals(_createDate))) {
229             _createDate = createDate;
230         }
231     }
232 
233     public Date getModifiedDate() {
234         return _modifiedDate;
235     }
236 
237     public void setModifiedDate(Date modifiedDate) {
238         if (((modifiedDate == null) && (_modifiedDate != null)) ||
239                 ((modifiedDate != null) && (_modifiedDate == null)) ||
240                 ((modifiedDate != null) && (_modifiedDate != null) &&
241                 !modifiedDate.equals(_modifiedDate))) {
242             _modifiedDate = modifiedDate;
243         }
244     }
245 
246     public long getParentCategoryId() {
247         return _parentCategoryId;
248     }
249 
250     public void setParentCategoryId(long parentCategoryId) {
251         if (parentCategoryId != _parentCategoryId) {
252             _parentCategoryId = parentCategoryId;
253         }
254     }
255 
256     public String getName() {
257         return GetterUtil.getString(_name);
258     }
259 
260     public void setName(String name) {
261         if (((name == null) && (_name != null)) ||
262                 ((name != null) && (_name == null)) ||
263                 ((name != null) && (_name != null) && !name.equals(_name))) {
264             _name = name;
265         }
266     }
267 
268     public String getDescription() {
269         return GetterUtil.getString(_description);
270     }
271 
272     public void setDescription(String description) {
273         if (((description == null) && (_description != null)) ||
274                 ((description != null) && (_description == null)) ||
275                 ((description != null) && (_description != null) &&
276                 !description.equals(_description))) {
277             _description = description;
278         }
279     }
280 
281     public Date getLastPostDate() {
282         return _lastPostDate;
283     }
284 
285     public void setLastPostDate(Date lastPostDate) {
286         if (((lastPostDate == null) && (_lastPostDate != null)) ||
287                 ((lastPostDate != null) && (_lastPostDate == null)) ||
288                 ((lastPostDate != null) && (_lastPostDate != null) &&
289                 !lastPostDate.equals(_lastPostDate))) {
290             _lastPostDate = lastPostDate;
291         }
292     }
293 
294     public MBCategory toEscapedModel() {
295         if (isEscapedModel()) {
296             return (MBCategory)this;
297         }
298         else {
299             MBCategory model = new MBCategoryImpl();
300 
301             model.setEscapedModel(true);
302 
303             model.setUuid(HtmlUtil.escape(getUuid()));
304             model.setCategoryId(getCategoryId());
305             model.setGroupId(getGroupId());
306             model.setCompanyId(getCompanyId());
307             model.setUserId(getUserId());
308             model.setUserName(HtmlUtil.escape(getUserName()));
309             model.setCreateDate(getCreateDate());
310             model.setModifiedDate(getModifiedDate());
311             model.setParentCategoryId(getParentCategoryId());
312             model.setName(HtmlUtil.escape(getName()));
313             model.setDescription(HtmlUtil.escape(getDescription()));
314             model.setLastPostDate(getLastPostDate());
315 
316             model = (MBCategory)Proxy.newProxyInstance(MBCategory.class.getClassLoader(),
317                     new Class[] { MBCategory.class },
318                     new ReadOnlyBeanHandler(model));
319 
320             return model;
321         }
322     }
323 
324     public Object clone() {
325         MBCategoryImpl clone = new MBCategoryImpl();
326 
327         clone.setUuid(getUuid());
328         clone.setCategoryId(getCategoryId());
329         clone.setGroupId(getGroupId());
330         clone.setCompanyId(getCompanyId());
331         clone.setUserId(getUserId());
332         clone.setUserName(getUserName());
333         clone.setCreateDate(getCreateDate());
334         clone.setModifiedDate(getModifiedDate());
335         clone.setParentCategoryId(getParentCategoryId());
336         clone.setName(getName());
337         clone.setDescription(getDescription());
338         clone.setLastPostDate(getLastPostDate());
339 
340         return clone;
341     }
342 
343     public int compareTo(Object obj) {
344         if (obj == null) {
345             return -1;
346         }
347 
348         MBCategoryImpl mbCategory = (MBCategoryImpl)obj;
349 
350         int value = 0;
351 
352         if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
353             value = -1;
354         }
355         else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
356             value = 1;
357         }
358         else {
359             value = 0;
360         }
361 
362         if (value != 0) {
363             return value;
364         }
365 
366         value = getName().toLowerCase()
367                     .compareTo(mbCategory.getName().toLowerCase());
368 
369         if (value != 0) {
370             return value;
371         }
372 
373         return 0;
374     }
375 
376     public boolean equals(Object obj) {
377         if (obj == null) {
378             return false;
379         }
380 
381         MBCategoryImpl mbCategory = null;
382 
383         try {
384             mbCategory = (MBCategoryImpl)obj;
385         }
386         catch (ClassCastException cce) {
387             return false;
388         }
389 
390         long pk = mbCategory.getPrimaryKey();
391 
392         if (getPrimaryKey() == pk) {
393             return true;
394         }
395         else {
396             return false;
397         }
398     }
399 
400     public int hashCode() {
401         return (int)getPrimaryKey();
402     }
403 
404     private String _uuid;
405     private long _categoryId;
406     private long _groupId;
407     private long _companyId;
408     private long _userId;
409     private String _userName;
410     private Date _createDate;
411     private Date _modifiedDate;
412     private long _parentCategoryId;
413     private String _name;
414     private String _description;
415     private Date _lastPostDate;
416 }