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.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    import com.liferay.portal.util.PortalUtil;
024    
025    import com.liferay.portlet.expando.model.ExpandoBridge;
026    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027    import com.liferay.portlet.messageboards.model.MBDiscussion;
028    import com.liferay.portlet.messageboards.model.MBDiscussionModel;
029    
030    import java.io.Serializable;
031    
032    import java.lang.reflect.Proxy;
033    
034    import java.sql.Types;
035    
036    /**
037     * <p>
038     * This interface is a model that represents the MBDiscussion table in the
039     * database.
040     * </p>
041     *
042     * @author    Brian Wing Shun Chan
043     * @see       MBDiscussionImpl
044     * @see       com.liferay.portlet.messageboards.model.MBDiscussion
045     * @see       com.liferay.portlet.messageboards.model.MBDiscussionModel
046     * @generated
047     */
048    public class MBDiscussionModelImpl extends BaseModelImpl<MBDiscussion>
049            implements MBDiscussionModel {
050            public static final String TABLE_NAME = "MBDiscussion";
051            public static final Object[][] TABLE_COLUMNS = {
052                            { "discussionId", new Integer(Types.BIGINT) },
053                            { "classNameId", new Integer(Types.BIGINT) },
054                            { "classPK", new Integer(Types.BIGINT) },
055                            { "threadId", new Integer(Types.BIGINT) }
056                    };
057            public static final String TABLE_SQL_CREATE = "create table MBDiscussion (discussionId LONG not null primary key,classNameId LONG,classPK LONG,threadId LONG)";
058            public static final String TABLE_SQL_DROP = "drop table MBDiscussion";
059            public static final String DATA_SOURCE = "liferayDataSource";
060            public static final String SESSION_FACTORY = "liferaySessionFactory";
061            public static final String TX_MANAGER = "liferayTransactionManager";
062            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
063                                    "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBDiscussion"),
064                            true);
065            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
066                                    "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBDiscussion"),
067                            true);
068            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
069                                    "lock.expiration.time.com.liferay.portlet.messageboards.model.MBDiscussion"));
070    
071            public MBDiscussionModelImpl() {
072            }
073    
074            public long getPrimaryKey() {
075                    return _discussionId;
076            }
077    
078            public void setPrimaryKey(long pk) {
079                    setDiscussionId(pk);
080            }
081    
082            public Serializable getPrimaryKeyObj() {
083                    return new Long(_discussionId);
084            }
085    
086            public long getDiscussionId() {
087                    return _discussionId;
088            }
089    
090            public void setDiscussionId(long discussionId) {
091                    _discussionId = discussionId;
092            }
093    
094            public String getClassName() {
095                    if (getClassNameId() <= 0) {
096                            return StringPool.BLANK;
097                    }
098    
099                    return PortalUtil.getClassName(getClassNameId());
100            }
101    
102            public long getClassNameId() {
103                    return _classNameId;
104            }
105    
106            public void setClassNameId(long classNameId) {
107                    _classNameId = classNameId;
108    
109                    if (!_setOriginalClassNameId) {
110                            _setOriginalClassNameId = true;
111    
112                            _originalClassNameId = classNameId;
113                    }
114            }
115    
116            public long getOriginalClassNameId() {
117                    return _originalClassNameId;
118            }
119    
120            public long getClassPK() {
121                    return _classPK;
122            }
123    
124            public void setClassPK(long classPK) {
125                    _classPK = classPK;
126    
127                    if (!_setOriginalClassPK) {
128                            _setOriginalClassPK = true;
129    
130                            _originalClassPK = classPK;
131                    }
132            }
133    
134            public long getOriginalClassPK() {
135                    return _originalClassPK;
136            }
137    
138            public long getThreadId() {
139                    return _threadId;
140            }
141    
142            public void setThreadId(long threadId) {
143                    _threadId = threadId;
144    
145                    if (!_setOriginalThreadId) {
146                            _setOriginalThreadId = true;
147    
148                            _originalThreadId = threadId;
149                    }
150            }
151    
152            public long getOriginalThreadId() {
153                    return _originalThreadId;
154            }
155    
156            public MBDiscussion toEscapedModel() {
157                    if (isEscapedModel()) {
158                            return (MBDiscussion)this;
159                    }
160                    else {
161                            return (MBDiscussion)Proxy.newProxyInstance(MBDiscussion.class.getClassLoader(),
162                                    new Class[] { MBDiscussion.class },
163                                    new AutoEscapeBeanHandler(this));
164                    }
165            }
166    
167            public ExpandoBridge getExpandoBridge() {
168                    if (_expandoBridge == null) {
169                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
170                                            MBDiscussion.class.getName(), getPrimaryKey());
171                    }
172    
173                    return _expandoBridge;
174            }
175    
176            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
177                    getExpandoBridge().setAttributes(serviceContext);
178            }
179    
180            public Object clone() {
181                    MBDiscussionImpl clone = new MBDiscussionImpl();
182    
183                    clone.setDiscussionId(getDiscussionId());
184                    clone.setClassNameId(getClassNameId());
185                    clone.setClassPK(getClassPK());
186                    clone.setThreadId(getThreadId());
187    
188                    return clone;
189            }
190    
191            public int compareTo(MBDiscussion mbDiscussion) {
192                    long pk = mbDiscussion.getPrimaryKey();
193    
194                    if (getPrimaryKey() < pk) {
195                            return -1;
196                    }
197                    else if (getPrimaryKey() > pk) {
198                            return 1;
199                    }
200                    else {
201                            return 0;
202                    }
203            }
204    
205            public boolean equals(Object obj) {
206                    if (obj == null) {
207                            return false;
208                    }
209    
210                    MBDiscussion mbDiscussion = null;
211    
212                    try {
213                            mbDiscussion = (MBDiscussion)obj;
214                    }
215                    catch (ClassCastException cce) {
216                            return false;
217                    }
218    
219                    long pk = mbDiscussion.getPrimaryKey();
220    
221                    if (getPrimaryKey() == pk) {
222                            return true;
223                    }
224                    else {
225                            return false;
226                    }
227            }
228    
229            public int hashCode() {
230                    return (int)getPrimaryKey();
231            }
232    
233            public String toString() {
234                    StringBundler sb = new StringBundler(9);
235    
236                    sb.append("{discussionId=");
237                    sb.append(getDiscussionId());
238                    sb.append(", classNameId=");
239                    sb.append(getClassNameId());
240                    sb.append(", classPK=");
241                    sb.append(getClassPK());
242                    sb.append(", threadId=");
243                    sb.append(getThreadId());
244                    sb.append("}");
245    
246                    return sb.toString();
247            }
248    
249            public String toXmlString() {
250                    StringBundler sb = new StringBundler(16);
251    
252                    sb.append("<model><model-name>");
253                    sb.append("com.liferay.portlet.messageboards.model.MBDiscussion");
254                    sb.append("</model-name>");
255    
256                    sb.append(
257                            "<column><column-name>discussionId</column-name><column-value><![CDATA[");
258                    sb.append(getDiscussionId());
259                    sb.append("]]></column-value></column>");
260                    sb.append(
261                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
262                    sb.append(getClassNameId());
263                    sb.append("]]></column-value></column>");
264                    sb.append(
265                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
266                    sb.append(getClassPK());
267                    sb.append("]]></column-value></column>");
268                    sb.append(
269                            "<column><column-name>threadId</column-name><column-value><![CDATA[");
270                    sb.append(getThreadId());
271                    sb.append("]]></column-value></column>");
272    
273                    sb.append("</model>");
274    
275                    return sb.toString();
276            }
277    
278            private long _discussionId;
279            private long _classNameId;
280            private long _originalClassNameId;
281            private boolean _setOriginalClassNameId;
282            private long _classPK;
283            private long _originalClassPK;
284            private boolean _setOriginalClassPK;
285            private long _threadId;
286            private long _originalThreadId;
287            private boolean _setOriginalThreadId;
288            private transient ExpandoBridge _expandoBridge;
289    }