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.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PortalUtil;
29  import com.liferay.portal.util.PropsUtil;
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.service.model.MBDiscussion
59   * @see com.liferay.portlet.messageboards.service.model.MBDiscussionModel
60   * @see com.liferay.portlet.messageboards.service.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 boolean CACHE_ENABLED = GetterUtil.getBoolean(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(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         return PortalUtil.getClassName(getClassNameId());
134     }
135 
136     public long getClassNameId() {
137         return _classNameId;
138     }
139 
140     public void setClassNameId(long classNameId) {
141         if (classNameId != _classNameId) {
142             _classNameId = classNameId;
143         }
144     }
145 
146     public long getClassPK() {
147         return _classPK;
148     }
149 
150     public void setClassPK(long classPK) {
151         if (classPK != _classPK) {
152             _classPK = classPK;
153         }
154     }
155 
156     public long getThreadId() {
157         return _threadId;
158     }
159 
160     public void setThreadId(long threadId) {
161         if (threadId != _threadId) {
162             _threadId = threadId;
163         }
164     }
165 
166     public MBDiscussion toEscapedModel() {
167         if (isEscapedModel()) {
168             return (MBDiscussion)this;
169         }
170         else {
171             MBDiscussion model = new MBDiscussionImpl();
172 
173             model.setEscapedModel(true);
174 
175             model.setDiscussionId(getDiscussionId());
176             model.setClassNameId(getClassNameId());
177             model.setClassPK(getClassPK());
178             model.setThreadId(getThreadId());
179 
180             model = (MBDiscussion)Proxy.newProxyInstance(MBDiscussion.class.getClassLoader(),
181                     new Class[] { MBDiscussion.class },
182                     new ReadOnlyBeanHandler(model));
183 
184             return model;
185         }
186     }
187 
188     public Object clone() {
189         MBDiscussionImpl clone = new MBDiscussionImpl();
190 
191         clone.setDiscussionId(getDiscussionId());
192         clone.setClassNameId(getClassNameId());
193         clone.setClassPK(getClassPK());
194         clone.setThreadId(getThreadId());
195 
196         return clone;
197     }
198 
199     public int compareTo(Object obj) {
200         if (obj == null) {
201             return -1;
202         }
203 
204         MBDiscussionImpl mbDiscussion = (MBDiscussionImpl)obj;
205 
206         long pk = mbDiscussion.getPrimaryKey();
207 
208         if (getPrimaryKey() < pk) {
209             return -1;
210         }
211         else if (getPrimaryKey() > pk) {
212             return 1;
213         }
214         else {
215             return 0;
216         }
217     }
218 
219     public boolean equals(Object obj) {
220         if (obj == null) {
221             return false;
222         }
223 
224         MBDiscussionImpl mbDiscussion = null;
225 
226         try {
227             mbDiscussion = (MBDiscussionImpl)obj;
228         }
229         catch (ClassCastException cce) {
230             return false;
231         }
232 
233         long pk = mbDiscussion.getPrimaryKey();
234 
235         if (getPrimaryKey() == pk) {
236             return true;
237         }
238         else {
239             return false;
240         }
241     }
242 
243     public int hashCode() {
244         return (int)getPrimaryKey();
245     }
246 
247     private long _discussionId;
248     private long _classNameId;
249     private long _classPK;
250     private long _threadId;
251 }