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.messageboards.model.MBDiscussion;
29  import com.liferay.portlet.messageboards.model.MBDiscussionSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="MBDiscussionModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>MBDiscussion</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.messageboards.model.MBDiscussion
56   * @see com.liferay.portlet.messageboards.model.MBDiscussionModel
57   * @see com.liferay.portlet.messageboards.model.impl.MBDiscussionImpl
58   *
59   */
60  public class MBDiscussionModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "MBDiscussion";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "discussionId", new Integer(Types.BIGINT) },
64              
65  
66              { "classNameId", new Integer(Types.BIGINT) },
67              
68  
69              { "classPK", new Integer(Types.BIGINT) },
70              
71  
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBDiscussion"),
81              true);
82  
83      public static MBDiscussion toModel(MBDiscussionSoap soapModel) {
84          MBDiscussion model = new MBDiscussionImpl();
85  
86          model.setDiscussionId(soapModel.getDiscussionId());
87          model.setClassNameId(soapModel.getClassNameId());
88          model.setClassPK(soapModel.getClassPK());
89          model.setThreadId(soapModel.getThreadId());
90  
91          return model;
92      }
93  
94      public static List<MBDiscussion> toModels(MBDiscussionSoap[] soapModels) {
95          List<MBDiscussion> models = new ArrayList<MBDiscussion>(soapModels.length);
96  
97          for (MBDiscussionSoap soapModel : soapModels) {
98              models.add(toModel(soapModel));
99          }
100 
101         return models;
102     }
103 
104     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
105                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBDiscussion"));
106 
107     public MBDiscussionModelImpl() {
108     }
109 
110     public long getPrimaryKey() {
111         return _discussionId;
112     }
113 
114     public void setPrimaryKey(long pk) {
115         setDiscussionId(pk);
116     }
117 
118     public Serializable getPrimaryKeyObj() {
119         return new Long(_discussionId);
120     }
121 
122     public long getDiscussionId() {
123         return _discussionId;
124     }
125 
126     public void setDiscussionId(long discussionId) {
127         if (discussionId != _discussionId) {
128             _discussionId = discussionId;
129         }
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         if (classNameId != _classNameId) {
146             _classNameId = classNameId;
147         }
148     }
149 
150     public long getClassPK() {
151         return _classPK;
152     }
153 
154     public void setClassPK(long classPK) {
155         if (classPK != _classPK) {
156             _classPK = classPK;
157         }
158     }
159 
160     public long getThreadId() {
161         return _threadId;
162     }
163 
164     public void setThreadId(long threadId) {
165         if (threadId != _threadId) {
166             _threadId = threadId;
167         }
168     }
169 
170     public MBDiscussion toEscapedModel() {
171         if (isEscapedModel()) {
172             return (MBDiscussion)this;
173         }
174         else {
175             MBDiscussion model = new MBDiscussionImpl();
176 
177             model.setNew(isNew());
178             model.setEscapedModel(true);
179 
180             model.setDiscussionId(getDiscussionId());
181             model.setClassNameId(getClassNameId());
182             model.setClassPK(getClassPK());
183             model.setThreadId(getThreadId());
184 
185             model = (MBDiscussion)Proxy.newProxyInstance(MBDiscussion.class.getClassLoader(),
186                     new Class[] { MBDiscussion.class },
187                     new ReadOnlyBeanHandler(model));
188 
189             return model;
190         }
191     }
192 
193     public Object clone() {
194         MBDiscussionImpl clone = new MBDiscussionImpl();
195 
196         clone.setDiscussionId(getDiscussionId());
197         clone.setClassNameId(getClassNameId());
198         clone.setClassPK(getClassPK());
199         clone.setThreadId(getThreadId());
200 
201         return clone;
202     }
203 
204     public int compareTo(Object obj) {
205         if (obj == null) {
206             return -1;
207         }
208 
209         MBDiscussionImpl mbDiscussion = (MBDiscussionImpl)obj;
210 
211         long pk = mbDiscussion.getPrimaryKey();
212 
213         if (getPrimaryKey() < pk) {
214             return -1;
215         }
216         else if (getPrimaryKey() > pk) {
217             return 1;
218         }
219         else {
220             return 0;
221         }
222     }
223 
224     public boolean equals(Object obj) {
225         if (obj == null) {
226             return false;
227         }
228 
229         MBDiscussionImpl mbDiscussion = null;
230 
231         try {
232             mbDiscussion = (MBDiscussionImpl)obj;
233         }
234         catch (ClassCastException cce) {
235             return false;
236         }
237 
238         long pk = mbDiscussion.getPrimaryKey();
239 
240         if (getPrimaryKey() == pk) {
241             return true;
242         }
243         else {
244             return false;
245         }
246     }
247 
248     public int hashCode() {
249         return (int)getPrimaryKey();
250     }
251 
252     private long _discussionId;
253     private long _classNameId;
254     private long _classPK;
255     private long _threadId;
256 }