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