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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
34  import com.liferay.portlet.messageboards.model.MBBan;
35  import com.liferay.portlet.messageboards.model.MBBanSoap;
36  
37  import java.io.Serializable;
38  
39  import java.lang.reflect.Proxy;
40  
41  import java.sql.Types;
42  
43  import java.util.ArrayList;
44  import java.util.Date;
45  import java.util.List;
46  
47  /**
48   * <a href="MBBanModelImpl.java.html"><b><i>View Source</i></b></a>
49   *
50   * <p>
51   * ServiceBuilder generated this class. Modifications in this class will be
52   * overwritten the next time is generated.
53   * </p>
54   *
55   * <p>
56   * This class is a model that represents the <code>MBBan</code> table
57   * in the database.
58   * </p>
59   *
60   * @author Brian Wing Shun Chan
61   *
62   * @see com.liferay.portlet.messageboards.model.MBBan
63   * @see com.liferay.portlet.messageboards.model.MBBanModel
64   * @see com.liferay.portlet.messageboards.model.impl.MBBanImpl
65   *
66   */
67  public class MBBanModelImpl extends BaseModelImpl<MBBan> {
68      public static final String TABLE_NAME = "MBBan";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "banId", new Integer(Types.BIGINT) },
71              
72  
73              { "groupId", new Integer(Types.BIGINT) },
74              
75  
76              { "companyId", new Integer(Types.BIGINT) },
77              
78  
79              { "userId", new Integer(Types.BIGINT) },
80              
81  
82              { "userName", new Integer(Types.VARCHAR) },
83              
84  
85              { "createDate", new Integer(Types.TIMESTAMP) },
86              
87  
88              { "modifiedDate", new Integer(Types.TIMESTAMP) },
89              
90  
91              { "banUserId", new Integer(Types.BIGINT) }
92          };
93      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)";
94      public static final String TABLE_SQL_DROP = "drop table MBBan";
95      public static final String DATA_SOURCE = "liferayDataSource";
96      public static final String SESSION_FACTORY = "liferaySessionFactory";
97      public static final String TX_MANAGER = "liferayTransactionManager";
98      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
99                  "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
100             true);
101     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
102                 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBBan"),
103             true);
104 
105     public static MBBan toModel(MBBanSoap soapModel) {
106         MBBan model = new MBBanImpl();
107 
108         model.setBanId(soapModel.getBanId());
109         model.setGroupId(soapModel.getGroupId());
110         model.setCompanyId(soapModel.getCompanyId());
111         model.setUserId(soapModel.getUserId());
112         model.setUserName(soapModel.getUserName());
113         model.setCreateDate(soapModel.getCreateDate());
114         model.setModifiedDate(soapModel.getModifiedDate());
115         model.setBanUserId(soapModel.getBanUserId());
116 
117         return model;
118     }
119 
120     public static List<MBBan> toModels(MBBanSoap[] soapModels) {
121         List<MBBan> models = new ArrayList<MBBan>(soapModels.length);
122 
123         for (MBBanSoap soapModel : soapModels) {
124             models.add(toModel(soapModel));
125         }
126 
127         return models;
128     }
129 
130     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
131                 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBBan"));
132 
133     public MBBanModelImpl() {
134     }
135 
136     public long getPrimaryKey() {
137         return _banId;
138     }
139 
140     public void setPrimaryKey(long pk) {
141         setBanId(pk);
142     }
143 
144     public Serializable getPrimaryKeyObj() {
145         return new Long(_banId);
146     }
147 
148     public long getBanId() {
149         return _banId;
150     }
151 
152     public void setBanId(long banId) {
153         _banId = banId;
154     }
155 
156     public long getGroupId() {
157         return _groupId;
158     }
159 
160     public void setGroupId(long groupId) {
161         _groupId = groupId;
162 
163         if (!_setOriginalGroupId) {
164             _setOriginalGroupId = true;
165 
166             _originalGroupId = groupId;
167         }
168     }
169 
170     public long getOriginalGroupId() {
171         return _originalGroupId;
172     }
173 
174     public long getCompanyId() {
175         return _companyId;
176     }
177 
178     public void setCompanyId(long companyId) {
179         _companyId = companyId;
180     }
181 
182     public long getUserId() {
183         return _userId;
184     }
185 
186     public void setUserId(long userId) {
187         _userId = userId;
188     }
189 
190     public String getUserUuid() throws SystemException {
191         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
192     }
193 
194     public void setUserUuid(String userUuid) {
195         _userUuid = userUuid;
196     }
197 
198     public String getUserName() {
199         return GetterUtil.getString(_userName);
200     }
201 
202     public void setUserName(String userName) {
203         _userName = userName;
204     }
205 
206     public Date getCreateDate() {
207         return _createDate;
208     }
209 
210     public void setCreateDate(Date createDate) {
211         _createDate = createDate;
212     }
213 
214     public Date getModifiedDate() {
215         return _modifiedDate;
216     }
217 
218     public void setModifiedDate(Date modifiedDate) {
219         _modifiedDate = modifiedDate;
220     }
221 
222     public long getBanUserId() {
223         return _banUserId;
224     }
225 
226     public void setBanUserId(long banUserId) {
227         _banUserId = banUserId;
228 
229         if (!_setOriginalBanUserId) {
230             _setOriginalBanUserId = true;
231 
232             _originalBanUserId = banUserId;
233         }
234     }
235 
236     public String getBanUserUuid() throws SystemException {
237         return PortalUtil.getUserValue(getBanUserId(), "uuid", _banUserUuid);
238     }
239 
240     public void setBanUserUuid(String banUserUuid) {
241         _banUserUuid = banUserUuid;
242     }
243 
244     public long getOriginalBanUserId() {
245         return _originalBanUserId;
246     }
247 
248     public MBBan toEscapedModel() {
249         if (isEscapedModel()) {
250             return (MBBan)this;
251         }
252         else {
253             MBBan model = new MBBanImpl();
254 
255             model.setNew(isNew());
256             model.setEscapedModel(true);
257 
258             model.setBanId(getBanId());
259             model.setGroupId(getGroupId());
260             model.setCompanyId(getCompanyId());
261             model.setUserId(getUserId());
262             model.setUserName(HtmlUtil.escape(getUserName()));
263             model.setCreateDate(getCreateDate());
264             model.setModifiedDate(getModifiedDate());
265             model.setBanUserId(getBanUserId());
266 
267             model = (MBBan)Proxy.newProxyInstance(MBBan.class.getClassLoader(),
268                     new Class[] { MBBan.class }, new ReadOnlyBeanHandler(model));
269 
270             return model;
271         }
272     }
273 
274     public ExpandoBridge getExpandoBridge() {
275         if (_expandoBridge == null) {
276             _expandoBridge = new ExpandoBridgeImpl(MBBan.class.getName(),
277                     getPrimaryKey());
278         }
279 
280         return _expandoBridge;
281     }
282 
283     public Object clone() {
284         MBBanImpl clone = new MBBanImpl();
285 
286         clone.setBanId(getBanId());
287         clone.setGroupId(getGroupId());
288         clone.setCompanyId(getCompanyId());
289         clone.setUserId(getUserId());
290         clone.setUserName(getUserName());
291         clone.setCreateDate(getCreateDate());
292         clone.setModifiedDate(getModifiedDate());
293         clone.setBanUserId(getBanUserId());
294 
295         return clone;
296     }
297 
298     public int compareTo(MBBan mbBan) {
299         long pk = mbBan.getPrimaryKey();
300 
301         if (getPrimaryKey() < pk) {
302             return -1;
303         }
304         else if (getPrimaryKey() > pk) {
305             return 1;
306         }
307         else {
308             return 0;
309         }
310     }
311 
312     public boolean equals(Object obj) {
313         if (obj == null) {
314             return false;
315         }
316 
317         MBBan mbBan = null;
318 
319         try {
320             mbBan = (MBBan)obj;
321         }
322         catch (ClassCastException cce) {
323             return false;
324         }
325 
326         long pk = mbBan.getPrimaryKey();
327 
328         if (getPrimaryKey() == pk) {
329             return true;
330         }
331         else {
332             return false;
333         }
334     }
335 
336     public int hashCode() {
337         return (int)getPrimaryKey();
338     }
339 
340     public String toString() {
341         StringBuilder sb = new StringBuilder();
342 
343         sb.append("{banId=");
344         sb.append(getBanId());
345         sb.append(", groupId=");
346         sb.append(getGroupId());
347         sb.append(", companyId=");
348         sb.append(getCompanyId());
349         sb.append(", userId=");
350         sb.append(getUserId());
351         sb.append(", userName=");
352         sb.append(getUserName());
353         sb.append(", createDate=");
354         sb.append(getCreateDate());
355         sb.append(", modifiedDate=");
356         sb.append(getModifiedDate());
357         sb.append(", banUserId=");
358         sb.append(getBanUserId());
359         sb.append("}");
360 
361         return sb.toString();
362     }
363 
364     public String toXmlString() {
365         StringBuilder sb = new StringBuilder();
366 
367         sb.append("<model><model-name>");
368         sb.append("com.liferay.portlet.messageboards.model.MBBan");
369         sb.append("</model-name>");
370 
371         sb.append(
372             "<column><column-name>banId</column-name><column-value><![CDATA[");
373         sb.append(getBanId());
374         sb.append("]]></column-value></column>");
375         sb.append(
376             "<column><column-name>groupId</column-name><column-value><![CDATA[");
377         sb.append(getGroupId());
378         sb.append("]]></column-value></column>");
379         sb.append(
380             "<column><column-name>companyId</column-name><column-value><![CDATA[");
381         sb.append(getCompanyId());
382         sb.append("]]></column-value></column>");
383         sb.append(
384             "<column><column-name>userId</column-name><column-value><![CDATA[");
385         sb.append(getUserId());
386         sb.append("]]></column-value></column>");
387         sb.append(
388             "<column><column-name>userName</column-name><column-value><![CDATA[");
389         sb.append(getUserName());
390         sb.append("]]></column-value></column>");
391         sb.append(
392             "<column><column-name>createDate</column-name><column-value><![CDATA[");
393         sb.append(getCreateDate());
394         sb.append("]]></column-value></column>");
395         sb.append(
396             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
397         sb.append(getModifiedDate());
398         sb.append("]]></column-value></column>");
399         sb.append(
400             "<column><column-name>banUserId</column-name><column-value><![CDATA[");
401         sb.append(getBanUserId());
402         sb.append("]]></column-value></column>");
403 
404         sb.append("</model>");
405 
406         return sb.toString();
407     }
408 
409     private long _banId;
410     private long _groupId;
411     private long _originalGroupId;
412     private boolean _setOriginalGroupId;
413     private long _companyId;
414     private long _userId;
415     private String _userUuid;
416     private String _userName;
417     private Date _createDate;
418     private Date _modifiedDate;
419     private long _banUserId;
420     private String _banUserUuid;
421     private long _originalBanUserId;
422     private boolean _setOriginalBanUserId;
423     private transient ExpandoBridge _expandoBridge;
424 }