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