1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.messageboards.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.StringPool;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PortalUtil;
30  
31  import com.liferay.portlet.messageboards.model.MBDiscussion;
32  import com.liferay.portlet.messageboards.model.MBDiscussionSoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.List;
42  
43  /**
44   * <a href="MBDiscussionModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>MBDiscussion</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.messageboards.model.MBDiscussion
59   * @see com.liferay.portlet.messageboards.model.MBDiscussionModel
60   * @see com.liferay.portlet.messageboards.model.impl.MBDiscussionImpl
61   *
62   */
63  public class MBDiscussionModelImpl extends BaseModelImpl<MBDiscussion> {
64      public static final String TABLE_NAME = "MBDiscussion";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "discussionId", new Integer(Types.BIGINT) },
67              
68  
69              { "classNameId", new Integer(Types.BIGINT) },
70              
71  
72              { "classPK", new Integer(Types.BIGINT) },
73              
74  
75              { "threadId", new Integer(Types.BIGINT) }
76          };
77      public static final String TABLE_SQL_CREATE = "create table MBDiscussion (discussionId LONG not null primary key,classNameId LONG,classPK LONG,threadId LONG)";
78      public static final String TABLE_SQL_DROP = "drop table MBDiscussion";
79      public static final String DATA_SOURCE = "liferayDataSource";
80      public static final String SESSION_FACTORY = "liferaySessionFactory";
81      public static final String TX_MANAGER = "liferayTransactionManager";
82      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBDiscussion"),
84              true);
85      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBDiscussion"),
87              true);
88  
89      public static MBDiscussion toModel(MBDiscussionSoap soapModel) {
90          MBDiscussion model = new MBDiscussionImpl();
91  
92          model.setDiscussionId(soapModel.getDiscussionId());
93          model.setClassNameId(soapModel.getClassNameId());
94          model.setClassPK(soapModel.getClassPK());
95          model.setThreadId(soapModel.getThreadId());
96  
97          return model;
98      }
99  
100     public static List<MBDiscussion> toModels(MBDiscussionSoap[] soapModels) {
101         List<MBDiscussion> models = new ArrayList<MBDiscussion>(soapModels.length);
102 
103         for (MBDiscussionSoap soapModel : soapModels) {
104             models.add(toModel(soapModel));
105         }
106 
107         return models;
108     }
109 
110     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBDiscussion"));
112 
113     public MBDiscussionModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _discussionId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setDiscussionId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_discussionId);
126     }
127 
128     public long getDiscussionId() {
129         return _discussionId;
130     }
131 
132     public void setDiscussionId(long discussionId) {
133         _discussionId = discussionId;
134     }
135 
136     public String getClassName() {
137         if (getClassNameId() <= 0) {
138             return StringPool.BLANK;
139         }
140 
141         return PortalUtil.getClassName(getClassNameId());
142     }
143 
144     public long getClassNameId() {
145         return _classNameId;
146     }
147 
148     public void setClassNameId(long classNameId) {
149         _classNameId = classNameId;
150 
151         if (!_setOriginalClassNameId) {
152             _setOriginalClassNameId = true;
153 
154             _originalClassNameId = classNameId;
155         }
156     }
157 
158     public long getOriginalClassNameId() {
159         return _originalClassNameId;
160     }
161 
162     public long getClassPK() {
163         return _classPK;
164     }
165 
166     public void setClassPK(long classPK) {
167         _classPK = classPK;
168 
169         if (!_setOriginalClassPK) {
170             _setOriginalClassPK = true;
171 
172             _originalClassPK = classPK;
173         }
174     }
175 
176     public long getOriginalClassPK() {
177         return _originalClassPK;
178     }
179 
180     public long getThreadId() {
181         return _threadId;
182     }
183 
184     public void setThreadId(long threadId) {
185         _threadId = threadId;
186 
187         if (!_setOriginalThreadId) {
188             _setOriginalThreadId = true;
189 
190             _originalThreadId = threadId;
191         }
192     }
193 
194     public long getOriginalThreadId() {
195         return _originalThreadId;
196     }
197 
198     public MBDiscussion toEscapedModel() {
199         if (isEscapedModel()) {
200             return (MBDiscussion)this;
201         }
202         else {
203             MBDiscussion model = new MBDiscussionImpl();
204 
205             model.setNew(isNew());
206             model.setEscapedModel(true);
207 
208             model.setDiscussionId(getDiscussionId());
209             model.setClassNameId(getClassNameId());
210             model.setClassPK(getClassPK());
211             model.setThreadId(getThreadId());
212 
213             model = (MBDiscussion)Proxy.newProxyInstance(MBDiscussion.class.getClassLoader(),
214                     new Class[] { MBDiscussion.class },
215                     new ReadOnlyBeanHandler(model));
216 
217             return model;
218         }
219     }
220 
221     public Object clone() {
222         MBDiscussionImpl clone = new MBDiscussionImpl();
223 
224         clone.setDiscussionId(getDiscussionId());
225         clone.setClassNameId(getClassNameId());
226         clone.setClassPK(getClassPK());
227         clone.setThreadId(getThreadId());
228 
229         return clone;
230     }
231 
232     public int compareTo(MBDiscussion mbDiscussion) {
233         long pk = mbDiscussion.getPrimaryKey();
234 
235         if (getPrimaryKey() < pk) {
236             return -1;
237         }
238         else if (getPrimaryKey() > pk) {
239             return 1;
240         }
241         else {
242             return 0;
243         }
244     }
245 
246     public boolean equals(Object obj) {
247         if (obj == null) {
248             return false;
249         }
250 
251         MBDiscussion mbDiscussion = null;
252 
253         try {
254             mbDiscussion = (MBDiscussion)obj;
255         }
256         catch (ClassCastException cce) {
257             return false;
258         }
259 
260         long pk = mbDiscussion.getPrimaryKey();
261 
262         if (getPrimaryKey() == pk) {
263             return true;
264         }
265         else {
266             return false;
267         }
268     }
269 
270     public int hashCode() {
271         return (int)getPrimaryKey();
272     }
273 
274     public String toString() {
275         StringBuilder sb = new StringBuilder();
276 
277         sb.append("{discussionId=");
278         sb.append(getDiscussionId());
279         sb.append(", classNameId=");
280         sb.append(getClassNameId());
281         sb.append(", classPK=");
282         sb.append(getClassPK());
283         sb.append(", threadId=");
284         sb.append(getThreadId());
285         sb.append("}");
286 
287         return sb.toString();
288     }
289 
290     public String toXmlString() {
291         StringBuilder sb = new StringBuilder();
292 
293         sb.append("<model><model-name>");
294         sb.append("com.liferay.portlet.messageboards.model.MBDiscussion");
295         sb.append("</model-name>");
296 
297         sb.append(
298             "<column><column-name>discussionId</column-name><column-value><![CDATA[");
299         sb.append(getDiscussionId());
300         sb.append("]]></column-value></column>");
301         sb.append(
302             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
303         sb.append(getClassNameId());
304         sb.append("]]></column-value></column>");
305         sb.append(
306             "<column><column-name>classPK</column-name><column-value><![CDATA[");
307         sb.append(getClassPK());
308         sb.append("]]></column-value></column>");
309         sb.append(
310             "<column><column-name>threadId</column-name><column-value><![CDATA[");
311         sb.append(getThreadId());
312         sb.append("]]></column-value></column>");
313 
314         sb.append("</model>");
315 
316         return sb.toString();
317     }
318 
319     private long _discussionId;
320     private long _classNameId;
321     private long _originalClassNameId;
322     private boolean _setOriginalClassNameId;
323     private long _classPK;
324     private long _originalClassPK;
325     private boolean _setOriginalClassPK;
326     private long _threadId;
327     private long _originalThreadId;
328     private boolean _setOriginalThreadId;
329 }