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