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