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