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  
30  import com.liferay.portlet.messageboards.model.MBDiscussion;
31  import com.liferay.portlet.messageboards.model.MBDiscussionSoap;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  
42  /**
43   * <a href="MBDiscussionModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>MBDiscussion</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.messageboards.service.model.MBDiscussion
58   * @see com.liferay.portlet.messageboards.service.model.MBDiscussionModel
59   * @see com.liferay.portlet.messageboards.service.model.impl.MBDiscussionImpl
60   *
61   */
62  public class MBDiscussionModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "MBDiscussion";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "discussionId", new Integer(Types.BIGINT) },
66              
67  
68              { "classNameId", new Integer(Types.BIGINT) },
69              
70  
71              { "classPK", new Integer(Types.BIGINT) },
72              
73  
74              { "threadId", new Integer(Types.BIGINT) }
75          };
76      public static final String TABLE_SQL_CREATE = "create table MBDiscussion (discussionId LONG not null primary key,classNameId LONG,classPK LONG,threadId LONG)";
77      public static final String TABLE_SQL_DROP = "drop table MBDiscussion";
78      public static final String DATA_SOURCE = "liferayDataSource";
79      public static final String SESSION_FACTORY = "liferaySessionFactory";
80      public static final String TX_MANAGER = "liferayTransactionManager";
81      public static final boolean 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         if (discussionId != _discussionId) {
130             _discussionId = discussionId;
131         }
132     }
133 
134     public String getClassName() {
135         return PortalUtil.getClassName(getClassNameId());
136     }
137 
138     public long getClassNameId() {
139         return _classNameId;
140     }
141 
142     public void setClassNameId(long classNameId) {
143         if (classNameId != _classNameId) {
144             _classNameId = classNameId;
145         }
146     }
147 
148     public long getClassPK() {
149         return _classPK;
150     }
151 
152     public void setClassPK(long classPK) {
153         if (classPK != _classPK) {
154             _classPK = classPK;
155         }
156     }
157 
158     public long getThreadId() {
159         return _threadId;
160     }
161 
162     public void setThreadId(long threadId) {
163         if (threadId != _threadId) {
164             _threadId = threadId;
165         }
166     }
167 
168     public MBDiscussion toEscapedModel() {
169         if (isEscapedModel()) {
170             return (MBDiscussion)this;
171         }
172         else {
173             MBDiscussion model = new MBDiscussionImpl();
174 
175             model.setEscapedModel(true);
176 
177             model.setDiscussionId(getDiscussionId());
178             model.setClassNameId(getClassNameId());
179             model.setClassPK(getClassPK());
180             model.setThreadId(getThreadId());
181 
182             model = (MBDiscussion)Proxy.newProxyInstance(MBDiscussion.class.getClassLoader(),
183                     new Class[] { MBDiscussion.class },
184                     new ReadOnlyBeanHandler(model));
185 
186             return model;
187         }
188     }
189 
190     public Object clone() {
191         MBDiscussionImpl clone = new MBDiscussionImpl();
192 
193         clone.setDiscussionId(getDiscussionId());
194         clone.setClassNameId(getClassNameId());
195         clone.setClassPK(getClassPK());
196         clone.setThreadId(getThreadId());
197 
198         return clone;
199     }
200 
201     public int compareTo(Object obj) {
202         if (obj == null) {
203             return -1;
204         }
205 
206         MBDiscussionImpl mbDiscussion = (MBDiscussionImpl)obj;
207 
208         long pk = mbDiscussion.getPrimaryKey();
209 
210         if (getPrimaryKey() < pk) {
211             return -1;
212         }
213         else if (getPrimaryKey() > pk) {
214             return 1;
215         }
216         else {
217             return 0;
218         }
219     }
220 
221     public boolean equals(Object obj) {
222         if (obj == null) {
223             return false;
224         }
225 
226         MBDiscussionImpl mbDiscussion = null;
227 
228         try {
229             mbDiscussion = (MBDiscussionImpl)obj;
230         }
231         catch (ClassCastException cce) {
232             return false;
233         }
234 
235         long pk = mbDiscussion.getPrimaryKey();
236 
237         if (getPrimaryKey() == pk) {
238             return true;
239         }
240         else {
241             return false;
242         }
243     }
244 
245     public int hashCode() {
246         return (int)getPrimaryKey();
247     }
248 
249     private long _discussionId;
250     private long _classNameId;
251     private long _classPK;
252     private long _threadId;
253 }