001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.messageboards.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    import com.liferay.portlet.messageboards.model.MBCategory;
029    import com.liferay.portlet.messageboards.model.MBCategoryModel;
030    import com.liferay.portlet.messageboards.model.MBCategorySoap;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * <p>
044     * This interface is a model that represents the MBCategory table in the
045     * database.
046     * </p>
047     *
048     * @author    Brian Wing Shun Chan
049     * @see       MBCategoryImpl
050     * @see       com.liferay.portlet.messageboards.model.MBCategory
051     * @see       com.liferay.portlet.messageboards.model.MBCategoryModel
052     * @generated
053     */
054    public class MBCategoryModelImpl extends BaseModelImpl<MBCategory>
055            implements MBCategoryModel {
056            public static final String TABLE_NAME = "MBCategory";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "uuid_", new Integer(Types.VARCHAR) },
059                            { "categoryId", new Integer(Types.BIGINT) },
060                            { "groupId", new Integer(Types.BIGINT) },
061                            { "companyId", new Integer(Types.BIGINT) },
062                            { "userId", new Integer(Types.BIGINT) },
063                            { "userName", new Integer(Types.VARCHAR) },
064                            { "createDate", new Integer(Types.TIMESTAMP) },
065                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
066                            { "parentCategoryId", new Integer(Types.BIGINT) },
067                            { "name", new Integer(Types.VARCHAR) },
068                            { "description", new Integer(Types.VARCHAR) },
069                            { "threadCount", new Integer(Types.INTEGER) },
070                            { "messageCount", new Integer(Types.INTEGER) },
071                            { "lastPostDate", new Integer(Types.TIMESTAMP) }
072                    };
073            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)";
074            public static final String TABLE_SQL_DROP = "drop table MBCategory";
075            public static final String ORDER_BY_JPQL = " ORDER BY mbCategory.parentCategoryId ASC, mbCategory.name ASC";
076            public static final String ORDER_BY_SQL = " ORDER BY MBCategory.parentCategoryId ASC, MBCategory.name ASC";
077            public static final String DATA_SOURCE = "liferayDataSource";
078            public static final String SESSION_FACTORY = "liferaySessionFactory";
079            public static final String TX_MANAGER = "liferayTransactionManager";
080            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
082                            true);
083            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBCategory"),
085                            true);
086    
087            public static MBCategory toModel(MBCategorySoap soapModel) {
088                    MBCategory model = new MBCategoryImpl();
089    
090                    model.setUuid(soapModel.getUuid());
091                    model.setCategoryId(soapModel.getCategoryId());
092                    model.setGroupId(soapModel.getGroupId());
093                    model.setCompanyId(soapModel.getCompanyId());
094                    model.setUserId(soapModel.getUserId());
095                    model.setUserName(soapModel.getUserName());
096                    model.setCreateDate(soapModel.getCreateDate());
097                    model.setModifiedDate(soapModel.getModifiedDate());
098                    model.setParentCategoryId(soapModel.getParentCategoryId());
099                    model.setName(soapModel.getName());
100                    model.setDescription(soapModel.getDescription());
101                    model.setThreadCount(soapModel.getThreadCount());
102                    model.setMessageCount(soapModel.getMessageCount());
103                    model.setLastPostDate(soapModel.getLastPostDate());
104    
105                    return model;
106            }
107    
108            public static List<MBCategory> toModels(MBCategorySoap[] soapModels) {
109                    List<MBCategory> models = new ArrayList<MBCategory>(soapModels.length);
110    
111                    for (MBCategorySoap 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.messageboards.model.MBCategory"));
120    
121            public MBCategoryModelImpl() {
122            }
123    
124            public long getPrimaryKey() {
125                    return _categoryId;
126            }
127    
128            public void setPrimaryKey(long pk) {
129                    setCategoryId(pk);
130            }
131    
132            public Serializable getPrimaryKeyObj() {
133                    return new Long(_categoryId);
134            }
135    
136            public String getUuid() {
137                    if (_uuid == null) {
138                            return StringPool.BLANK;
139                    }
140                    else {
141                            return _uuid;
142                    }
143            }
144    
145            public void setUuid(String uuid) {
146                    _uuid = uuid;
147    
148                    if (_originalUuid == null) {
149                            _originalUuid = uuid;
150                    }
151            }
152    
153            public String getOriginalUuid() {
154                    return GetterUtil.getString(_originalUuid);
155            }
156    
157            public long getCategoryId() {
158                    return _categoryId;
159            }
160    
161            public void setCategoryId(long categoryId) {
162                    _categoryId = categoryId;
163            }
164    
165            public long getGroupId() {
166                    return _groupId;
167            }
168    
169            public void setGroupId(long groupId) {
170                    _groupId = groupId;
171    
172                    if (!_setOriginalGroupId) {
173                            _setOriginalGroupId = true;
174    
175                            _originalGroupId = groupId;
176                    }
177            }
178    
179            public long getOriginalGroupId() {
180                    return _originalGroupId;
181            }
182    
183            public long getCompanyId() {
184                    return _companyId;
185            }
186    
187            public void setCompanyId(long companyId) {
188                    _companyId = companyId;
189            }
190    
191            public long getUserId() {
192                    return _userId;
193            }
194    
195            public void setUserId(long userId) {
196                    _userId = userId;
197            }
198    
199            public String getUserUuid() throws SystemException {
200                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
201            }
202    
203            public void setUserUuid(String userUuid) {
204                    _userUuid = userUuid;
205            }
206    
207            public String getUserName() {
208                    if (_userName == null) {
209                            return StringPool.BLANK;
210                    }
211                    else {
212                            return _userName;
213                    }
214            }
215    
216            public void setUserName(String userName) {
217                    _userName = userName;
218            }
219    
220            public Date getCreateDate() {
221                    return _createDate;
222            }
223    
224            public void setCreateDate(Date createDate) {
225                    _createDate = createDate;
226            }
227    
228            public Date getModifiedDate() {
229                    return _modifiedDate;
230            }
231    
232            public void setModifiedDate(Date modifiedDate) {
233                    _modifiedDate = modifiedDate;
234            }
235    
236            public long getParentCategoryId() {
237                    return _parentCategoryId;
238            }
239    
240            public void setParentCategoryId(long parentCategoryId) {
241                    _parentCategoryId = parentCategoryId;
242            }
243    
244            public String getName() {
245                    if (_name == null) {
246                            return StringPool.BLANK;
247                    }
248                    else {
249                            return _name;
250                    }
251            }
252    
253            public void setName(String name) {
254                    _name = name;
255            }
256    
257            public String getDescription() {
258                    if (_description == null) {
259                            return StringPool.BLANK;
260                    }
261                    else {
262                            return _description;
263                    }
264            }
265    
266            public void setDescription(String description) {
267                    _description = description;
268            }
269    
270            public int getThreadCount() {
271                    return _threadCount;
272            }
273    
274            public void setThreadCount(int threadCount) {
275                    _threadCount = threadCount;
276            }
277    
278            public int getMessageCount() {
279                    return _messageCount;
280            }
281    
282            public void setMessageCount(int messageCount) {
283                    _messageCount = messageCount;
284            }
285    
286            public Date getLastPostDate() {
287                    return _lastPostDate;
288            }
289    
290            public void setLastPostDate(Date lastPostDate) {
291                    _lastPostDate = lastPostDate;
292            }
293    
294            public MBCategory toEscapedModel() {
295                    if (isEscapedModel()) {
296                            return (MBCategory)this;
297                    }
298                    else {
299                            return (MBCategory)Proxy.newProxyInstance(MBCategory.class.getClassLoader(),
300                                    new Class[] { MBCategory.class },
301                                    new AutoEscapeBeanHandler(this));
302                    }
303            }
304    
305            public ExpandoBridge getExpandoBridge() {
306                    if (_expandoBridge == null) {
307                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
308                                            MBCategory.class.getName(), getPrimaryKey());
309                    }
310    
311                    return _expandoBridge;
312            }
313    
314            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
315                    getExpandoBridge().setAttributes(serviceContext);
316            }
317    
318            public Object clone() {
319                    MBCategoryImpl clone = new MBCategoryImpl();
320    
321                    clone.setUuid(getUuid());
322                    clone.setCategoryId(getCategoryId());
323                    clone.setGroupId(getGroupId());
324                    clone.setCompanyId(getCompanyId());
325                    clone.setUserId(getUserId());
326                    clone.setUserName(getUserName());
327                    clone.setCreateDate(getCreateDate());
328                    clone.setModifiedDate(getModifiedDate());
329                    clone.setParentCategoryId(getParentCategoryId());
330                    clone.setName(getName());
331                    clone.setDescription(getDescription());
332                    clone.setThreadCount(getThreadCount());
333                    clone.setMessageCount(getMessageCount());
334                    clone.setLastPostDate(getLastPostDate());
335    
336                    return clone;
337            }
338    
339            public int compareTo(MBCategory mbCategory) {
340                    int value = 0;
341    
342                    if (getParentCategoryId() < mbCategory.getParentCategoryId()) {
343                            value = -1;
344                    }
345                    else if (getParentCategoryId() > mbCategory.getParentCategoryId()) {
346                            value = 1;
347                    }
348                    else {
349                            value = 0;
350                    }
351    
352                    if (value != 0) {
353                            return value;
354                    }
355    
356                    value = getName().toLowerCase()
357                                            .compareTo(mbCategory.getName().toLowerCase());
358    
359                    if (value != 0) {
360                            return value;
361                    }
362    
363                    return 0;
364            }
365    
366            public boolean equals(Object obj) {
367                    if (obj == null) {
368                            return false;
369                    }
370    
371                    MBCategory mbCategory = null;
372    
373                    try {
374                            mbCategory = (MBCategory)obj;
375                    }
376                    catch (ClassCastException cce) {
377                            return false;
378                    }
379    
380                    long pk = mbCategory.getPrimaryKey();
381    
382                    if (getPrimaryKey() == pk) {
383                            return true;
384                    }
385                    else {
386                            return false;
387                    }
388            }
389    
390            public int hashCode() {
391                    return (int)getPrimaryKey();
392            }
393    
394            public String toString() {
395                    StringBundler sb = new StringBundler(29);
396    
397                    sb.append("{uuid=");
398                    sb.append(getUuid());
399                    sb.append(", categoryId=");
400                    sb.append(getCategoryId());
401                    sb.append(", groupId=");
402                    sb.append(getGroupId());
403                    sb.append(", companyId=");
404                    sb.append(getCompanyId());
405                    sb.append(", userId=");
406                    sb.append(getUserId());
407                    sb.append(", userName=");
408                    sb.append(getUserName());
409                    sb.append(", createDate=");
410                    sb.append(getCreateDate());
411                    sb.append(", modifiedDate=");
412                    sb.append(getModifiedDate());
413                    sb.append(", parentCategoryId=");
414                    sb.append(getParentCategoryId());
415                    sb.append(", name=");
416                    sb.append(getName());
417                    sb.append(", description=");
418                    sb.append(getDescription());
419                    sb.append(", threadCount=");
420                    sb.append(getThreadCount());
421                    sb.append(", messageCount=");
422                    sb.append(getMessageCount());
423                    sb.append(", lastPostDate=");
424                    sb.append(getLastPostDate());
425                    sb.append("}");
426    
427                    return sb.toString();
428            }
429    
430            public String toXmlString() {
431                    StringBundler sb = new StringBundler(46);
432    
433                    sb.append("<model><model-name>");
434                    sb.append("com.liferay.portlet.messageboards.model.MBCategory");
435                    sb.append("</model-name>");
436    
437                    sb.append(
438                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
439                    sb.append(getUuid());
440                    sb.append("]]></column-value></column>");
441                    sb.append(
442                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
443                    sb.append(getCategoryId());
444                    sb.append("]]></column-value></column>");
445                    sb.append(
446                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
447                    sb.append(getGroupId());
448                    sb.append("]]></column-value></column>");
449                    sb.append(
450                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
451                    sb.append(getCompanyId());
452                    sb.append("]]></column-value></column>");
453                    sb.append(
454                            "<column><column-name>userId</column-name><column-value><![CDATA[");
455                    sb.append(getUserId());
456                    sb.append("]]></column-value></column>");
457                    sb.append(
458                            "<column><column-name>userName</column-name><column-value><![CDATA[");
459                    sb.append(getUserName());
460                    sb.append("]]></column-value></column>");
461                    sb.append(
462                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
463                    sb.append(getCreateDate());
464                    sb.append("]]></column-value></column>");
465                    sb.append(
466                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
467                    sb.append(getModifiedDate());
468                    sb.append("]]></column-value></column>");
469                    sb.append(
470                            "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
471                    sb.append(getParentCategoryId());
472                    sb.append("]]></column-value></column>");
473                    sb.append(
474                            "<column><column-name>name</column-name><column-value><![CDATA[");
475                    sb.append(getName());
476                    sb.append("]]></column-value></column>");
477                    sb.append(
478                            "<column><column-name>description</column-name><column-value><![CDATA[");
479                    sb.append(getDescription());
480                    sb.append("]]></column-value></column>");
481                    sb.append(
482                            "<column><column-name>threadCount</column-name><column-value><![CDATA[");
483                    sb.append(getThreadCount());
484                    sb.append("]]></column-value></column>");
485                    sb.append(
486                            "<column><column-name>messageCount</column-name><column-value><![CDATA[");
487                    sb.append(getMessageCount());
488                    sb.append("]]></column-value></column>");
489                    sb.append(
490                            "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
491                    sb.append(getLastPostDate());
492                    sb.append("]]></column-value></column>");
493    
494                    sb.append("</model>");
495    
496                    return sb.toString();
497            }
498    
499            private String _uuid;
500            private String _originalUuid;
501            private long _categoryId;
502            private long _groupId;
503            private long _originalGroupId;
504            private boolean _setOriginalGroupId;
505            private long _companyId;
506            private long _userId;
507            private String _userUuid;
508            private String _userName;
509            private Date _createDate;
510            private Date _modifiedDate;
511            private long _parentCategoryId;
512            private String _name;
513            private String _description;
514            private int _threadCount;
515            private int _messageCount;
516            private Date _lastPostDate;
517            private transient ExpandoBridge _expandoBridge;
518    }