1   /**
2    * Copyright (c) 2000-2009 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.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  
30  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
32  import com.liferay.portlet.messageboards.model.MBBan;
33  import com.liferay.portlet.messageboards.model.MBBanSoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.Date;
43  import java.util.List;
44  
45  /**
46   * <a href="MBBanModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This class is a model that represents the <code>MBBan</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.messageboards.model.MBBan
61   * @see com.liferay.portlet.messageboards.model.MBBanModel
62   * @see com.liferay.portlet.messageboards.model.impl.MBBanImpl
63   *
64   */
65  public class MBBanModelImpl extends BaseModelImpl {
66      public static final String TABLE_NAME = "MBBan";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "banId", new Integer(Types.BIGINT) },
69              
70  
71              { "groupId", new Integer(Types.BIGINT) },
72              
73  
74              { "companyId", new Integer(Types.BIGINT) },
75              
76  
77              { "userId", new Integer(Types.BIGINT) },
78              
79  
80              { "userName", new Integer(Types.VARCHAR) },
81              
82  
83              { "createDate", new Integer(Types.TIMESTAMP) },
84              
85  
86              { "modifiedDate", new Integer(Types.TIMESTAMP) },
87              
88  
89              { "banUserId", new Integer(Types.BIGINT) }
90          };
91      public static final String TABLE_SQL_CREATE = "create table MBBan (banId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,banUserId LONG)";
92      public static final String TABLE_SQL_DROP = "drop table MBBan";
93      public static final String DATA_SOURCE = "liferayDataSource";
94      public static final String SESSION_FACTORY = "liferaySessionFactory";
95      public static final String TX_MANAGER = "liferayTransactionManager";
96      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
97                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
98              true);
99  
100     public static MBBan toModel(MBBanSoap soapModel) {
101         MBBan model = new MBBanImpl();
102 
103         model.setBanId(soapModel.getBanId());
104         model.setGroupId(soapModel.getGroupId());
105         model.setCompanyId(soapModel.getCompanyId());
106         model.setUserId(soapModel.getUserId());
107         model.setUserName(soapModel.getUserName());
108         model.setCreateDate(soapModel.getCreateDate());
109         model.setModifiedDate(soapModel.getModifiedDate());
110         model.setBanUserId(soapModel.getBanUserId());
111 
112         return model;
113     }
114 
115     public static List<MBBan> toModels(MBBanSoap[] soapModels) {
116         List<MBBan> models = new ArrayList<MBBan>(soapModels.length);
117 
118         for (MBBanSoap soapModel : soapModels) {
119             models.add(toModel(soapModel));
120         }
121 
122         return models;
123     }
124 
125     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
126                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBBan"));
127 
128     public MBBanModelImpl() {
129     }
130 
131     public long getPrimaryKey() {
132         return _banId;
133     }
134 
135     public void setPrimaryKey(long pk) {
136         setBanId(pk);
137     }
138 
139     public Serializable getPrimaryKeyObj() {
140         return new Long(_banId);
141     }
142 
143     public long getBanId() {
144         return _banId;
145     }
146 
147     public void setBanId(long banId) {
148         if (banId != _banId) {
149             _banId = banId;
150         }
151     }
152 
153     public long getGroupId() {
154         return _groupId;
155     }
156 
157     public void setGroupId(long groupId) {
158         if (groupId != _groupId) {
159             _groupId = groupId;
160         }
161     }
162 
163     public long getCompanyId() {
164         return _companyId;
165     }
166 
167     public void setCompanyId(long companyId) {
168         if (companyId != _companyId) {
169             _companyId = companyId;
170         }
171     }
172 
173     public long getUserId() {
174         return _userId;
175     }
176 
177     public void setUserId(long userId) {
178         if (userId != _userId) {
179             _userId = userId;
180         }
181     }
182 
183     public String getUserName() {
184         return GetterUtil.getString(_userName);
185     }
186 
187     public void setUserName(String userName) {
188         if (((userName == null) && (_userName != null)) ||
189                 ((userName != null) && (_userName == null)) ||
190                 ((userName != null) && (_userName != null) &&
191                 !userName.equals(_userName))) {
192             _userName = userName;
193         }
194     }
195 
196     public Date getCreateDate() {
197         return _createDate;
198     }
199 
200     public void setCreateDate(Date createDate) {
201         if (((createDate == null) && (_createDate != null)) ||
202                 ((createDate != null) && (_createDate == null)) ||
203                 ((createDate != null) && (_createDate != null) &&
204                 !createDate.equals(_createDate))) {
205             _createDate = createDate;
206         }
207     }
208 
209     public Date getModifiedDate() {
210         return _modifiedDate;
211     }
212 
213     public void setModifiedDate(Date modifiedDate) {
214         if (((modifiedDate == null) && (_modifiedDate != null)) ||
215                 ((modifiedDate != null) && (_modifiedDate == null)) ||
216                 ((modifiedDate != null) && (_modifiedDate != null) &&
217                 !modifiedDate.equals(_modifiedDate))) {
218             _modifiedDate = modifiedDate;
219         }
220     }
221 
222     public long getBanUserId() {
223         return _banUserId;
224     }
225 
226     public void setBanUserId(long banUserId) {
227         if (banUserId != _banUserId) {
228             _banUserId = banUserId;
229         }
230     }
231 
232     public MBBan toEscapedModel() {
233         if (isEscapedModel()) {
234             return (MBBan)this;
235         }
236         else {
237             MBBan model = new MBBanImpl();
238 
239             model.setNew(isNew());
240             model.setEscapedModel(true);
241 
242             model.setBanId(getBanId());
243             model.setGroupId(getGroupId());
244             model.setCompanyId(getCompanyId());
245             model.setUserId(getUserId());
246             model.setUserName(HtmlUtil.escape(getUserName()));
247             model.setCreateDate(getCreateDate());
248             model.setModifiedDate(getModifiedDate());
249             model.setBanUserId(getBanUserId());
250 
251             model = (MBBan)Proxy.newProxyInstance(MBBan.class.getClassLoader(),
252                     new Class[] { MBBan.class }, new ReadOnlyBeanHandler(model));
253 
254             return model;
255         }
256     }
257 
258     public ExpandoBridge getExpandoBridge() {
259         if (_expandoBridge == null) {
260             _expandoBridge = new ExpandoBridgeImpl(MBBan.class.getName(),
261                     getPrimaryKey());
262         }
263 
264         return _expandoBridge;
265     }
266 
267     public Object clone() {
268         MBBanImpl clone = new MBBanImpl();
269 
270         clone.setBanId(getBanId());
271         clone.setGroupId(getGroupId());
272         clone.setCompanyId(getCompanyId());
273         clone.setUserId(getUserId());
274         clone.setUserName(getUserName());
275         clone.setCreateDate(getCreateDate());
276         clone.setModifiedDate(getModifiedDate());
277         clone.setBanUserId(getBanUserId());
278 
279         return clone;
280     }
281 
282     public int compareTo(Object obj) {
283         if (obj == null) {
284             return -1;
285         }
286 
287         MBBanImpl mbBan = (MBBanImpl)obj;
288 
289         long pk = mbBan.getPrimaryKey();
290 
291         if (getPrimaryKey() < pk) {
292             return -1;
293         }
294         else if (getPrimaryKey() > pk) {
295             return 1;
296         }
297         else {
298             return 0;
299         }
300     }
301 
302     public boolean equals(Object obj) {
303         if (obj == null) {
304             return false;
305         }
306 
307         MBBanImpl mbBan = null;
308 
309         try {
310             mbBan = (MBBanImpl)obj;
311         }
312         catch (ClassCastException cce) {
313             return false;
314         }
315 
316         long pk = mbBan.getPrimaryKey();
317 
318         if (getPrimaryKey() == pk) {
319             return true;
320         }
321         else {
322             return false;
323         }
324     }
325 
326     public int hashCode() {
327         return (int)getPrimaryKey();
328     }
329 
330     private long _banId;
331     private long _groupId;
332     private long _companyId;
333     private long _userId;
334     private String _userName;
335     private Date _createDate;
336     private Date _modifiedDate;
337     private long _banUserId;
338     private transient ExpandoBridge _expandoBridge;
339 }