1   /**
2    * Copyright (c) 2000-2010 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   *
12   *
13   */
14  
15  package com.liferay.portlet.messageboards.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.kernel.util.StringPool;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.service.ServiceContext;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import com.liferay.portlet.expando.model.ExpandoBridge;
27  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
28  import com.liferay.portlet.messageboards.model.MBCategory;
29  import com.liferay.portlet.messageboards.model.MBCategorySoap;
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="MBCategoryModelImpl.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 interface is a model that represents the MBCategory table in the
51   * database.
52   * </p>
53   *
54   * @author    Brian Wing Shun Chan
55   * @see       MBCategoryImpl
56   * @see       com.liferay.portlet.messageboards.model.MBCategory
57   * @see       com.liferay.portlet.messageboards.model.MBCategoryModel
58   * @generated
59   */
60  public class MBCategoryModelImpl extends BaseModelImpl<MBCategory> {
61      public static final String TABLE_NAME = "MBCategory";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "uuid_", new Integer(Types.VARCHAR) },
64              { "categoryId", new Integer(Types.BIGINT) },
65              { "groupId", new Integer(Types.BIGINT) },
66              { "companyId", new Integer(Types.BIGINT) },
67              { "userId", new Integer(Types.BIGINT) },
68              { "userName", new Integer(Types.VARCHAR) },
69              { "createDate", new Integer(Types.TIMESTAMP) },
70              { "modifiedDate", new Integer(Types.TIMESTAMP) },
71              { "parentCategoryId", new Integer(Types.BIGINT) },
72              { "name", new Integer(Types.VARCHAR) },
73              { "description", new Integer(Types.VARCHAR) },
74              { "threadCount", new Integer(Types.INTEGER) },
75              { "messageCount", new Integer(Types.INTEGER) },
76              { "lastPostDate", new Integer(Types.TIMESTAMP) }
77          };
78      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,threadCount INTEGER,messageCount INTEGER,lastPostDate DATE null)";
79      public static final String TABLE_SQL_DROP = "drop table MBCategory";
80      public static final String ORDER_BY_JPQL = " ORDER BY mbCategory.parentCategoryId ASC, mbCategory.name ASC";
81      public static final String ORDER_BY_SQL = " ORDER BY MBCategory.parentCategoryId ASC, MBCategory.name ASC";
82      public static final String DATA_SOURCE = "liferayDataSource";
83      public static final String SESSION_FACTORY = "liferaySessionFactory";
84      public static final String TX_MANAGER = "liferayTransactionManager";
85      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
87              true);
88      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
89                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
90              true);
91  
92      public static MBCategory toModel(MBCategorySoap soapModel) {
93          MBCategory model = new MBCategoryImpl();
94  
95          model.setUuid(soapModel.getUuid());
96          model.setCategoryId(soapModel.getCategoryId());
97          model.setGroupId(soapModel.getGroupId());
98          model.setCompanyId(soapModel.getCompanyId());
99          model.setUserId(soapModel.getUserId());
100         model.setUserName(soapModel.getUserName());
101         model.setCreateDate(soapModel.getCreateDate());
102         model.setModifiedDate(soapModel.getModifiedDate());
103         model.setParentCategoryId(soapModel.getParentCategoryId());
104         model.setName(soapModel.getName());
105         model.setDescription(soapModel.getDescription());
106         model.setThreadCount(soapModel.getThreadCount());
107         model.setMessageCount(soapModel.getMessageCount());
108         model.setLastPostDate(soapModel.getLastPostDate());
109 
110         return model;
111     }
112 
113     public static List<MBCategory> toModels(MBCategorySoap[] soapModels) {
114         List<MBCategory> models = new ArrayList<MBCategory>(soapModels.length);
115 
116         for (MBCategorySoap soapModel : soapModels) {
117             models.add(toModel(soapModel));
118         }
119 
120         return models;
121     }
122 
123     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
124                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBCategory"));
125 
126     public MBCategoryModelImpl() {
127     }
128 
129     public long getPrimaryKey() {
130         return _categoryId;
131     }
132 
133     public void setPrimaryKey(long pk) {
134         setCategoryId(pk);
135     }
136 
137     public Serializable getPrimaryKeyObj() {
138         return new Long(_categoryId);
139     }
140 
141     public String getUuid() {
142         if (_uuid == null) {
143             return StringPool.BLANK;
144         }
145         else {
146             return _uuid;
147         }
148     }
149 
150     public void setUuid(String uuid) {
151         _uuid = uuid;
152 
153         if (_originalUuid == null) {
154             _originalUuid = uuid;
155         }
156     }
157 
158     public String getOriginalUuid() {
159         return GetterUtil.getString(_originalUuid);
160     }
161 
162     public long getCategoryId() {
163         return _categoryId;
164     }
165 
166     public void setCategoryId(long categoryId) {
167         _categoryId = categoryId;
168     }
169 
170     public long getGroupId() {
171         return _groupId;
172     }
173 
174     public void setGroupId(long groupId) {
175         _groupId = groupId;
176 
177         if (!_setOriginalGroupId) {
178             _setOriginalGroupId = true;
179 
180             _originalGroupId = groupId;
181         }
182     }
183 
184     public long getOriginalGroupId() {
185         return _originalGroupId;
186     }
187 
188     public long getCompanyId() {
189         return _companyId;
190     }
191 
192     public void setCompanyId(long companyId) {
193         _companyId = companyId;
194     }
195 
196     public long getUserId() {
197         return _userId;
198     }
199 
200     public void setUserId(long userId) {
201         _userId = userId;
202     }
203 
204     public String getUserUuid() throws SystemException {
205         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
206     }
207 
208     public void setUserUuid(String userUuid) {
209         _userUuid = userUuid;
210     }
211 
212     public String getUserName() {
213         if (_userName == null) {
214             return StringPool.BLANK;
215         }
216         else {
217             return _userName;
218         }
219     }
220 
221     public void setUserName(String userName) {
222         _userName = userName;
223     }
224 
225     public Date getCreateDate() {
226         return _createDate;
227     }
228 
229     public void setCreateDate(Date createDate) {
230         _createDate = createDate;
231     }
232 
233     public Date getModifiedDate() {
234         return _modifiedDate;
235     }
236 
237     public void setModifiedDate(Date modifiedDate) {
238         _modifiedDate = modifiedDate;
239     }
240 
241     public long getParentCategoryId() {
242         return _parentCategoryId;
243     }
244 
245     public void setParentCategoryId(long parentCategoryId) {
246         _parentCategoryId = parentCategoryId;
247     }
248 
249     public String getName() {
250         if (_name == null) {
251             return StringPool.BLANK;
252         }
253         else {
254             return _name;
255         }
256     }
257 
258     public void setName(String name) {
259         _name = name;
260     }
261 
262     public String getDescription() {
263         if (_description == null) {
264             return StringPool.BLANK;
265         }
266         else {
267             return _description;
268         }
269     }
270 
271     public void setDescription(String description) {
272         _description = description;
273     }
274 
275     public int getThreadCount() {
276         return _threadCount;
277     }
278 
279     public void setThreadCount(int threadCount) {
280         _threadCount = threadCount;
281     }
282 
283     public int getMessageCount() {
284         return _messageCount;
285     }
286 
287     public void setMessageCount(int messageCount) {
288         _messageCount = messageCount;
289     }
290 
291     public Date getLastPostDate() {
292         return _lastPostDate;
293     }
294 
295     public void setLastPostDate(Date lastPostDate) {
296         _lastPostDate = lastPostDate;
297     }
298 
299     public MBCategory toEscapedModel() {
300         if (isEscapedModel()) {
301             return (MBCategory)this;
302         }
303         else {
304             return (MBCategory)Proxy.newProxyInstance(MBCategory.class.getClassLoader(),
305                 new Class[] { MBCategory.class },
306                 new AutoEscapeBeanHandler(this));
307         }
308     }
309 
310     public ExpandoBridge getExpandoBridge() {
311         if (_expandoBridge == null) {
312             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(MBCategory.class.getName(),
313                     getPrimaryKey());
314         }
315 
316         return _expandoBridge;
317     }
318 
319     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
320         getExpandoBridge().setAttributes(serviceContext);
321     }
322 
323     public Object clone() {
324         MBCategoryImpl clone = new MBCategoryImpl();
325 
326         clone.setUuid(getUuid());
327         clone.setCategoryId(getCategoryId());
328         clone.setGroupId(getGroupId());
329         clone.setCompanyId(getCompanyId());
330         clone.setUserId(getUserId());
331         clone.setUserName(getUserName());
332         clone.setCreateDate(getCreateDate());
333         clone.setModifiedDate(getModifiedDate());
334         clone.setParentCategoryId(getParentCategoryId());
335         clone.setName(getName());
336         clone.setDescription(getDescription());
337         clone.setThreadCount(getThreadCount());
338         clone.setMessageCount(getMessageCount());
339         clone.setLastPostDate(getLastPostDate());
340 
341         return clone;
342     }
343 
344     public int compareTo(MBCategory mbCategory) {
345         int value = 0;
346 
347         if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
348             value = -1;
349         }
350         else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
351             value = 1;
352         }
353         else {
354             value = 0;
355         }
356 
357         if (value != 0) {
358             return value;
359         }
360 
361         value = getName().toLowerCase()
362                     .compareTo(mbCategory.getName().toLowerCase());
363 
364         if (value != 0) {
365             return value;
366         }
367 
368         return 0;
369     }
370 
371     public boolean equals(Object obj) {
372         if (obj == null) {
373             return false;
374         }
375 
376         MBCategory mbCategory = null;
377 
378         try {
379             mbCategory = (MBCategory)obj;
380         }
381         catch (ClassCastException cce) {
382             return false;
383         }
384 
385         long pk = mbCategory.getPrimaryKey();
386 
387         if (getPrimaryKey() == pk) {
388             return true;
389         }
390         else {
391             return false;
392         }
393     }
394 
395     public int hashCode() {
396         return (int)getPrimaryKey();
397     }
398 
399     public String toString() {
400         StringBundler sb = new StringBundler(29);
401 
402         sb.append("{uuid=");
403         sb.append(getUuid());
404         sb.append(", categoryId=");
405         sb.append(getCategoryId());
406         sb.append(", groupId=");
407         sb.append(getGroupId());
408         sb.append(", companyId=");
409         sb.append(getCompanyId());
410         sb.append(", userId=");
411         sb.append(getUserId());
412         sb.append(", userName=");
413         sb.append(getUserName());
414         sb.append(", createDate=");
415         sb.append(getCreateDate());
416         sb.append(", modifiedDate=");
417         sb.append(getModifiedDate());
418         sb.append(", parentCategoryId=");
419         sb.append(getParentCategoryId());
420         sb.append(", name=");
421         sb.append(getName());
422         sb.append(", description=");
423         sb.append(getDescription());
424         sb.append(", threadCount=");
425         sb.append(getThreadCount());
426         sb.append(", messageCount=");
427         sb.append(getMessageCount());
428         sb.append(", lastPostDate=");
429         sb.append(getLastPostDate());
430         sb.append("}");
431 
432         return sb.toString();
433     }
434 
435     public String toXmlString() {
436         StringBundler sb = new StringBundler(46);
437 
438         sb.append("<model><model-name>");
439         sb.append("com.liferay.portlet.messageboards.model.MBCategory");
440         sb.append("</model-name>");
441 
442         sb.append(
443             "<column><column-name>uuid</column-name><column-value><![CDATA[");
444         sb.append(getUuid());
445         sb.append("]]></column-value></column>");
446         sb.append(
447             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
448         sb.append(getCategoryId());
449         sb.append("]]></column-value></column>");
450         sb.append(
451             "<column><column-name>groupId</column-name><column-value><![CDATA[");
452         sb.append(getGroupId());
453         sb.append("]]></column-value></column>");
454         sb.append(
455             "<column><column-name>companyId</column-name><column-value><![CDATA[");
456         sb.append(getCompanyId());
457         sb.append("]]></column-value></column>");
458         sb.append(
459             "<column><column-name>userId</column-name><column-value><![CDATA[");
460         sb.append(getUserId());
461         sb.append("]]></column-value></column>");
462         sb.append(
463             "<column><column-name>userName</column-name><column-value><![CDATA[");
464         sb.append(getUserName());
465         sb.append("]]></column-value></column>");
466         sb.append(
467             "<column><column-name>createDate</column-name><column-value><![CDATA[");
468         sb.append(getCreateDate());
469         sb.append("]]></column-value></column>");
470         sb.append(
471             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
472         sb.append(getModifiedDate());
473         sb.append("]]></column-value></column>");
474         sb.append(
475             "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
476         sb.append(getParentCategoryId());
477         sb.append("]]></column-value></column>");
478         sb.append(
479             "<column><column-name>name</column-name><column-value><![CDATA[");
480         sb.append(getName());
481         sb.append("]]></column-value></column>");
482         sb.append(
483             "<column><column-name>description</column-name><column-value><![CDATA[");
484         sb.append(getDescription());
485         sb.append("]]></column-value></column>");
486         sb.append(
487             "<column><column-name>threadCount</column-name><column-value><![CDATA[");
488         sb.append(getThreadCount());
489         sb.append("]]></column-value></column>");
490         sb.append(
491             "<column><column-name>messageCount</column-name><column-value><![CDATA[");
492         sb.append(getMessageCount());
493         sb.append("]]></column-value></column>");
494         sb.append(
495             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
496         sb.append(getLastPostDate());
497         sb.append("]]></column-value></column>");
498 
499         sb.append("</model>");
500 
501         return sb.toString();
502     }
503 
504     private String _uuid;
505     private String _originalUuid;
506     private long _categoryId;
507     private long _groupId;
508     private long _originalGroupId;
509     private boolean _setOriginalGroupId;
510     private long _companyId;
511     private long _userId;
512     private String _userUuid;
513     private String _userName;
514     private Date _createDate;
515     private Date _modifiedDate;
516     private long _parentCategoryId;
517     private String _name;
518     private String _description;
519     private int _threadCount;
520     private int _messageCount;
521     private Date _lastPostDate;
522     private transient ExpandoBridge _expandoBridge;
523 }