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