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