1   /**
2    * Copyright (c) 2000-2008 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.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 class is a model that represents the <code>MBDiscussion</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.messageboards.model.MBDiscussion
59   * @see com.liferay.portlet.messageboards.model.MBDiscussionModel
60   * @see com.liferay.portlet.messageboards.model.impl.MBDiscussionImpl
61   *
62   */
63  public class MBDiscussionModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "MBDiscussion";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "discussionId", new Integer(Types.BIGINT) },
67              
68  
69              { "classNameId", new Integer(Types.BIGINT) },
70              
71  
72              { "classPK", new Integer(Types.BIGINT) },
73              
74  
75              { "threadId", new Integer(Types.BIGINT) }
76          };
77      public static final String TABLE_SQL_CREATE = "create table MBDiscussion (discussionId LONG not null primary key,classNameId LONG,classPK LONG,threadId LONG)";
78      public static final String TABLE_SQL_DROP = "drop table MBDiscussion";
79      public static final String DATA_SOURCE = "liferayDataSource";
80      public static final String SESSION_FACTORY = "liferaySessionFactory";
81      public static final String TX_MANAGER = "liferayTransactionManager";
82      public static final boolean 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         if (discussionId != _discussionId) {
131             _discussionId = discussionId;
132         }
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         if (classNameId != _classNameId) {
149             _classNameId = classNameId;
150         }
151     }
152 
153     public long getClassPK() {
154         return _classPK;
155     }
156 
157     public void setClassPK(long classPK) {
158         if (classPK != _classPK) {
159             _classPK = classPK;
160         }
161     }
162 
163     public long getThreadId() {
164         return _threadId;
165     }
166 
167     public void setThreadId(long threadId) {
168         if (threadId != _threadId) {
169             _threadId = threadId;
170         }
171     }
172 
173     public MBDiscussion toEscapedModel() {
174         if (isEscapedModel()) {
175             return (MBDiscussion)this;
176         }
177         else {
178             MBDiscussion model = new MBDiscussionImpl();
179 
180             model.setNew(isNew());
181             model.setEscapedModel(true);
182 
183             model.setDiscussionId(getDiscussionId());
184             model.setClassNameId(getClassNameId());
185             model.setClassPK(getClassPK());
186             model.setThreadId(getThreadId());
187 
188             model = (MBDiscussion)Proxy.newProxyInstance(MBDiscussion.class.getClassLoader(),
189                     new Class[] { MBDiscussion.class },
190                     new ReadOnlyBeanHandler(model));
191 
192             return model;
193         }
194     }
195 
196     public Object clone() {
197         MBDiscussionImpl clone = new MBDiscussionImpl();
198 
199         clone.setDiscussionId(getDiscussionId());
200         clone.setClassNameId(getClassNameId());
201         clone.setClassPK(getClassPK());
202         clone.setThreadId(getThreadId());
203 
204         return clone;
205     }
206 
207     public int compareTo(Object obj) {
208         if (obj == null) {
209             return -1;
210         }
211 
212         MBDiscussionImpl mbDiscussion = (MBDiscussionImpl)obj;
213 
214         long pk = mbDiscussion.getPrimaryKey();
215 
216         if (getPrimaryKey() < pk) {
217             return -1;
218         }
219         else if (getPrimaryKey() > pk) {
220             return 1;
221         }
222         else {
223             return 0;
224         }
225     }
226 
227     public boolean equals(Object obj) {
228         if (obj == null) {
229             return false;
230         }
231 
232         MBDiscussionImpl mbDiscussion = null;
233 
234         try {
235             mbDiscussion = (MBDiscussionImpl)obj;
236         }
237         catch (ClassCastException cce) {
238             return false;
239         }
240 
241         long pk = mbDiscussion.getPrimaryKey();
242 
243         if (getPrimaryKey() == pk) {
244             return true;
245         }
246         else {
247             return false;
248         }
249     }
250 
251     public int hashCode() {
252         return (int)getPrimaryKey();
253     }
254 
255     private long _discussionId;
256     private long _classNameId;
257     private long _classPK;
258     private long _threadId;
259 }