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