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