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