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.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.MembershipRequest;
30  import com.liferay.portal.model.MembershipRequestSoap;
31  import com.liferay.portal.util.PropsUtil;
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.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="MembershipRequestModelImpl.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>MembershipRequest</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.service.model.MembershipRequest
59   * @see com.liferay.portal.service.model.MembershipRequestModel
60   * @see com.liferay.portal.service.model.impl.MembershipRequestImpl
61   *
62   */
63  public class MembershipRequestModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "MembershipRequest";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "membershipRequestId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "userId", new Integer(Types.BIGINT) },
73              
74  
75              { "createDate", new Integer(Types.TIMESTAMP) },
76              
77  
78              { "groupId", new Integer(Types.BIGINT) },
79              
80  
81              { "comments", new Integer(Types.VARCHAR) },
82              
83  
84              { "replyComments", new Integer(Types.VARCHAR) },
85              
86  
87              { "replyDate", new Integer(Types.TIMESTAMP) },
88              
89  
90              { "replierUserId", new Integer(Types.BIGINT) },
91              
92  
93              { "statusId", new Integer(Types.INTEGER) }
94          };
95      public static final String TABLE_SQL_CREATE = "create table MembershipRequest (membershipRequestId LONG not null primary key,companyId LONG,userId LONG,createDate DATE null,groupId LONG,comments STRING null,replyComments STRING null,replyDate DATE null,replierUserId LONG,statusId INTEGER)";
96      public static final String TABLE_SQL_DROP = "drop table MembershipRequest";
97      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
98                  "value.object.finder.cache.enabled.com.liferay.portal.model.MembershipRequest"),
99              true);
100 
101     public static MembershipRequest toModel(MembershipRequestSoap soapModel) {
102         MembershipRequest model = new MembershipRequestImpl();
103 
104         model.setMembershipRequestId(soapModel.getMembershipRequestId());
105         model.setCompanyId(soapModel.getCompanyId());
106         model.setUserId(soapModel.getUserId());
107         model.setCreateDate(soapModel.getCreateDate());
108         model.setGroupId(soapModel.getGroupId());
109         model.setComments(soapModel.getComments());
110         model.setReplyComments(soapModel.getReplyComments());
111         model.setReplyDate(soapModel.getReplyDate());
112         model.setReplierUserId(soapModel.getReplierUserId());
113         model.setStatusId(soapModel.getStatusId());
114 
115         return model;
116     }
117 
118     public static List<MembershipRequest> toModels(
119         MembershipRequestSoap[] soapModels) {
120         List<MembershipRequest> models = new ArrayList<MembershipRequest>(soapModels.length);
121 
122         for (MembershipRequestSoap soapModel : soapModels) {
123             models.add(toModel(soapModel));
124         }
125 
126         return models;
127     }
128 
129     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
130                 "lock.expiration.time.com.liferay.portal.model.MembershipRequest"));
131 
132     public MembershipRequestModelImpl() {
133     }
134 
135     public long getPrimaryKey() {
136         return _membershipRequestId;
137     }
138 
139     public void setPrimaryKey(long pk) {
140         setMembershipRequestId(pk);
141     }
142 
143     public Serializable getPrimaryKeyObj() {
144         return new Long(_membershipRequestId);
145     }
146 
147     public long getMembershipRequestId() {
148         return _membershipRequestId;
149     }
150 
151     public void setMembershipRequestId(long membershipRequestId) {
152         if (membershipRequestId != _membershipRequestId) {
153             _membershipRequestId = membershipRequestId;
154         }
155     }
156 
157     public long getCompanyId() {
158         return _companyId;
159     }
160 
161     public void setCompanyId(long companyId) {
162         if (companyId != _companyId) {
163             _companyId = companyId;
164         }
165     }
166 
167     public long getUserId() {
168         return _userId;
169     }
170 
171     public void setUserId(long userId) {
172         if (userId != _userId) {
173             _userId = userId;
174         }
175     }
176 
177     public Date getCreateDate() {
178         return _createDate;
179     }
180 
181     public void setCreateDate(Date createDate) {
182         if (((createDate == null) && (_createDate != null)) ||
183                 ((createDate != null) && (_createDate == null)) ||
184                 ((createDate != null) && (_createDate != null) &&
185                 !createDate.equals(_createDate))) {
186             _createDate = createDate;
187         }
188     }
189 
190     public long getGroupId() {
191         return _groupId;
192     }
193 
194     public void setGroupId(long groupId) {
195         if (groupId != _groupId) {
196             _groupId = groupId;
197         }
198     }
199 
200     public String getComments() {
201         return GetterUtil.getString(_comments);
202     }
203 
204     public void setComments(String comments) {
205         if (((comments == null) && (_comments != null)) ||
206                 ((comments != null) && (_comments == null)) ||
207                 ((comments != null) && (_comments != null) &&
208                 !comments.equals(_comments))) {
209             _comments = comments;
210         }
211     }
212 
213     public String getReplyComments() {
214         return GetterUtil.getString(_replyComments);
215     }
216 
217     public void setReplyComments(String replyComments) {
218         if (((replyComments == null) && (_replyComments != null)) ||
219                 ((replyComments != null) && (_replyComments == null)) ||
220                 ((replyComments != null) && (_replyComments != null) &&
221                 !replyComments.equals(_replyComments))) {
222             _replyComments = replyComments;
223         }
224     }
225 
226     public Date getReplyDate() {
227         return _replyDate;
228     }
229 
230     public void setReplyDate(Date replyDate) {
231         if (((replyDate == null) && (_replyDate != null)) ||
232                 ((replyDate != null) && (_replyDate == null)) ||
233                 ((replyDate != null) && (_replyDate != null) &&
234                 !replyDate.equals(_replyDate))) {
235             _replyDate = replyDate;
236         }
237     }
238 
239     public long getReplierUserId() {
240         return _replierUserId;
241     }
242 
243     public void setReplierUserId(long replierUserId) {
244         if (replierUserId != _replierUserId) {
245             _replierUserId = replierUserId;
246         }
247     }
248 
249     public int getStatusId() {
250         return _statusId;
251     }
252 
253     public void setStatusId(int statusId) {
254         if (statusId != _statusId) {
255             _statusId = statusId;
256         }
257     }
258 
259     public MembershipRequest toEscapedModel() {
260         if (isEscapedModel()) {
261             return (MembershipRequest)this;
262         }
263         else {
264             MembershipRequest model = new MembershipRequestImpl();
265 
266             model.setEscapedModel(true);
267 
268             model.setMembershipRequestId(getMembershipRequestId());
269             model.setCompanyId(getCompanyId());
270             model.setUserId(getUserId());
271             model.setCreateDate(getCreateDate());
272             model.setGroupId(getGroupId());
273             model.setComments(HtmlUtil.escape(getComments()));
274             model.setReplyComments(HtmlUtil.escape(getReplyComments()));
275             model.setReplyDate(getReplyDate());
276             model.setReplierUserId(getReplierUserId());
277             model.setStatusId(getStatusId());
278 
279             model = (MembershipRequest)Proxy.newProxyInstance(MembershipRequest.class.getClassLoader(),
280                     new Class[] { MembershipRequest.class },
281                     new ReadOnlyBeanHandler(model));
282 
283             return model;
284         }
285     }
286 
287     public Object clone() {
288         MembershipRequestImpl clone = new MembershipRequestImpl();
289 
290         clone.setMembershipRequestId(getMembershipRequestId());
291         clone.setCompanyId(getCompanyId());
292         clone.setUserId(getUserId());
293         clone.setCreateDate(getCreateDate());
294         clone.setGroupId(getGroupId());
295         clone.setComments(getComments());
296         clone.setReplyComments(getReplyComments());
297         clone.setReplyDate(getReplyDate());
298         clone.setReplierUserId(getReplierUserId());
299         clone.setStatusId(getStatusId());
300 
301         return clone;
302     }
303 
304     public int compareTo(Object obj) {
305         if (obj == null) {
306             return -1;
307         }
308 
309         MembershipRequestImpl membershipRequest = (MembershipRequestImpl)obj;
310 
311         int value = 0;
312 
313         value = DateUtil.compareTo(getCreateDate(),
314                 membershipRequest.getCreateDate());
315 
316         value = value * -1;
317 
318         if (value != 0) {
319             return value;
320         }
321 
322         return 0;
323     }
324 
325     public boolean equals(Object obj) {
326         if (obj == null) {
327             return false;
328         }
329 
330         MembershipRequestImpl membershipRequest = null;
331 
332         try {
333             membershipRequest = (MembershipRequestImpl)obj;
334         }
335         catch (ClassCastException cce) {
336             return false;
337         }
338 
339         long pk = membershipRequest.getPrimaryKey();
340 
341         if (getPrimaryKey() == pk) {
342             return true;
343         }
344         else {
345             return false;
346         }
347     }
348 
349     public int hashCode() {
350         return (int)getPrimaryKey();
351     }
352 
353     private long _membershipRequestId;
354     private long _companyId;
355     private long _userId;
356     private Date _createDate;
357     private long _groupId;
358     private String _comments;
359     private String _replyComments;
360     private Date _replyDate;
361     private long _replierUserId;
362     private int _statusId;
363 }