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.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  import com.liferay.portal.util.PortalUtil;
23  
24  import com.liferay.portlet.messageboards.model.MBDiscussion;
25  import com.liferay.portlet.messageboards.model.MBDiscussionSoap;
26  
27  import java.io.Serializable;
28  
29  import java.lang.reflect.Proxy;
30  
31  import java.sql.Types;
32  
33  import java.util.ArrayList;
34  import java.util.List;
35  
36  /**
37   * <a href="MBDiscussionModelImpl.java.html"><b><i>View Source</i></b></a>
38   *
39   * <p>
40   * ServiceBuilder generated this class. Modifications in this class will be
41   * overwritten the next time is generated.
42   * </p>
43   *
44   * <p>
45   * This interface is a model that represents the MBDiscussion table in the
46   * database.
47   * </p>
48   *
49   * @author    Brian Wing Shun Chan
50   * @see       MBDiscussionImpl
51   * @see       com.liferay.portlet.messageboards.model.MBDiscussion
52   * @see       com.liferay.portlet.messageboards.model.MBDiscussionModel
53   * @generated
54   */
55  public class MBDiscussionModelImpl extends BaseModelImpl<MBDiscussion> {
56      public static final String TABLE_NAME = "MBDiscussion";
57      public static final Object[][] TABLE_COLUMNS = {
58              { "discussionId", new Integer(Types.BIGINT) },
59              { "classNameId", new Integer(Types.BIGINT) },
60              { "classPK", new Integer(Types.BIGINT) },
61              { "threadId", new Integer(Types.BIGINT) }
62          };
63      public static final String TABLE_SQL_CREATE = "create table MBDiscussion (discussionId LONG not null primary key,classNameId LONG,classPK LONG,threadId LONG)";
64      public static final String TABLE_SQL_DROP = "drop table MBDiscussion";
65      public static final String DATA_SOURCE = "liferayDataSource";
66      public static final String SESSION_FACTORY = "liferaySessionFactory";
67      public static final String TX_MANAGER = "liferayTransactionManager";
68      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
69                  "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBDiscussion"),
70              true);
71      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
72                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBDiscussion"),
73              true);
74  
75      public static MBDiscussion toModel(MBDiscussionSoap soapModel) {
76          MBDiscussion model = new MBDiscussionImpl();
77  
78          model.setDiscussionId(soapModel.getDiscussionId());
79          model.setClassNameId(soapModel.getClassNameId());
80          model.setClassPK(soapModel.getClassPK());
81          model.setThreadId(soapModel.getThreadId());
82  
83          return model;
84      }
85  
86      public static List<MBDiscussion> toModels(MBDiscussionSoap[] soapModels) {
87          List<MBDiscussion> models = new ArrayList<MBDiscussion>(soapModels.length);
88  
89          for (MBDiscussionSoap soapModel : soapModels) {
90              models.add(toModel(soapModel));
91          }
92  
93          return models;
94      }
95  
96      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
97                  "lock.expiration.time.com.liferay.portlet.messageboards.model.MBDiscussion"));
98  
99      public MBDiscussionModelImpl() {
100     }
101 
102     public long getPrimaryKey() {
103         return _discussionId;
104     }
105 
106     public void setPrimaryKey(long pk) {
107         setDiscussionId(pk);
108     }
109 
110     public Serializable getPrimaryKeyObj() {
111         return new Long(_discussionId);
112     }
113 
114     public long getDiscussionId() {
115         return _discussionId;
116     }
117 
118     public void setDiscussionId(long discussionId) {
119         _discussionId = discussionId;
120     }
121 
122     public String getClassName() {
123         if (getClassNameId() <= 0) {
124             return StringPool.BLANK;
125         }
126 
127         return PortalUtil.getClassName(getClassNameId());
128     }
129 
130     public long getClassNameId() {
131         return _classNameId;
132     }
133 
134     public void setClassNameId(long classNameId) {
135         _classNameId = classNameId;
136 
137         if (!_setOriginalClassNameId) {
138             _setOriginalClassNameId = true;
139 
140             _originalClassNameId = classNameId;
141         }
142     }
143 
144     public long getOriginalClassNameId() {
145         return _originalClassNameId;
146     }
147 
148     public long getClassPK() {
149         return _classPK;
150     }
151 
152     public void setClassPK(long classPK) {
153         _classPK = classPK;
154 
155         if (!_setOriginalClassPK) {
156             _setOriginalClassPK = true;
157 
158             _originalClassPK = classPK;
159         }
160     }
161 
162     public long getOriginalClassPK() {
163         return _originalClassPK;
164     }
165 
166     public long getThreadId() {
167         return _threadId;
168     }
169 
170     public void setThreadId(long threadId) {
171         _threadId = threadId;
172 
173         if (!_setOriginalThreadId) {
174             _setOriginalThreadId = true;
175 
176             _originalThreadId = threadId;
177         }
178     }
179 
180     public long getOriginalThreadId() {
181         return _originalThreadId;
182     }
183 
184     public MBDiscussion toEscapedModel() {
185         if (isEscapedModel()) {
186             return (MBDiscussion)this;
187         }
188         else {
189             MBDiscussion model = new MBDiscussionImpl();
190 
191             model.setNew(isNew());
192             model.setEscapedModel(true);
193 
194             model.setDiscussionId(getDiscussionId());
195             model.setClassNameId(getClassNameId());
196             model.setClassPK(getClassPK());
197             model.setThreadId(getThreadId());
198 
199             model = (MBDiscussion)Proxy.newProxyInstance(MBDiscussion.class.getClassLoader(),
200                     new Class[] { MBDiscussion.class },
201                     new ReadOnlyBeanHandler(model));
202 
203             return model;
204         }
205     }
206 
207     public Object clone() {
208         MBDiscussionImpl clone = new MBDiscussionImpl();
209 
210         clone.setDiscussionId(getDiscussionId());
211         clone.setClassNameId(getClassNameId());
212         clone.setClassPK(getClassPK());
213         clone.setThreadId(getThreadId());
214 
215         return clone;
216     }
217 
218     public int compareTo(MBDiscussion mbDiscussion) {
219         long pk = mbDiscussion.getPrimaryKey();
220 
221         if (getPrimaryKey() < pk) {
222             return -1;
223         }
224         else if (getPrimaryKey() > pk) {
225             return 1;
226         }
227         else {
228             return 0;
229         }
230     }
231 
232     public boolean equals(Object obj) {
233         if (obj == null) {
234             return false;
235         }
236 
237         MBDiscussion mbDiscussion = null;
238 
239         try {
240             mbDiscussion = (MBDiscussion)obj;
241         }
242         catch (ClassCastException cce) {
243             return false;
244         }
245 
246         long pk = mbDiscussion.getPrimaryKey();
247 
248         if (getPrimaryKey() == pk) {
249             return true;
250         }
251         else {
252             return false;
253         }
254     }
255 
256     public int hashCode() {
257         return (int)getPrimaryKey();
258     }
259 
260     public String toString() {
261         StringBundler sb = new StringBundler(9);
262 
263         sb.append("{discussionId=");
264         sb.append(getDiscussionId());
265         sb.append(", classNameId=");
266         sb.append(getClassNameId());
267         sb.append(", classPK=");
268         sb.append(getClassPK());
269         sb.append(", threadId=");
270         sb.append(getThreadId());
271         sb.append("}");
272 
273         return sb.toString();
274     }
275 
276     public String toXmlString() {
277         StringBundler sb = new StringBundler(16);
278 
279         sb.append("<model><model-name>");
280         sb.append("com.liferay.portlet.messageboards.model.MBDiscussion");
281         sb.append("</model-name>");
282 
283         sb.append(
284             "<column><column-name>discussionId</column-name><column-value><![CDATA[");
285         sb.append(getDiscussionId());
286         sb.append("]]></column-value></column>");
287         sb.append(
288             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
289         sb.append(getClassNameId());
290         sb.append("]]></column-value></column>");
291         sb.append(
292             "<column><column-name>classPK</column-name><column-value><![CDATA[");
293         sb.append(getClassPK());
294         sb.append("]]></column-value></column>");
295         sb.append(
296             "<column><column-name>threadId</column-name><column-value><![CDATA[");
297         sb.append(getThreadId());
298         sb.append("]]></column-value></column>");
299 
300         sb.append("</model>");
301 
302         return sb.toString();
303     }
304 
305     private long _discussionId;
306     private long _classNameId;
307     private long _originalClassNameId;
308     private boolean _setOriginalClassNameId;
309     private long _classPK;
310     private long _originalClassPK;
311     private boolean _setOriginalClassPK;
312     private long _threadId;
313     private long _originalThreadId;
314     private boolean _setOriginalThreadId;
315 }