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