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.announcements.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.announcements.model.AnnouncementsEntry;
34  import com.liferay.portlet.announcements.model.AnnouncementsEntrySoap;
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="AnnouncementsEntryModelImpl.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>AnnouncementsEntry</code> table
56   * in the database.
57   * </p>
58   *
59   * @author Brian Wing Shun Chan
60   *
61   * @see com.liferay.portlet.announcements.model.AnnouncementsEntry
62   * @see com.liferay.portlet.announcements.model.AnnouncementsEntryModel
63   * @see com.liferay.portlet.announcements.model.impl.AnnouncementsEntryImpl
64   *
65   */
66  public class AnnouncementsEntryModelImpl extends BaseModelImpl {
67      public static final String TABLE_NAME = "AnnouncementsEntry";
68      public static final Object[][] TABLE_COLUMNS = {
69              { "uuid_", new Integer(Types.VARCHAR) },
70              
71  
72              { "entryId", 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.BIGINT) },
94              
95  
96              { "title", new Integer(Types.VARCHAR) },
97              
98  
99              { "content", new Integer(Types.VARCHAR) },
100             
101 
102             { "url", new Integer(Types.VARCHAR) },
103             
104 
105             { "type_", new Integer(Types.VARCHAR) },
106             
107 
108             { "displayDate", new Integer(Types.TIMESTAMP) },
109             
110 
111             { "expirationDate", new Integer(Types.TIMESTAMP) },
112             
113 
114             { "priority", new Integer(Types.INTEGER) },
115             
116 
117             { "alert", new Integer(Types.BOOLEAN) }
118         };
119     public static final String TABLE_SQL_CREATE = "create table AnnouncementsEntry (uuid_ VARCHAR(75) null,entryId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,title VARCHAR(75) null,content STRING null,url STRING null,type_ VARCHAR(75) null,displayDate DATE null,expirationDate DATE null,priority INTEGER,alert BOOLEAN)";
120     public static final String TABLE_SQL_DROP = "drop table AnnouncementsEntry";
121     public static final String DATA_SOURCE = "liferayDataSource";
122     public static final String SESSION_FACTORY = "liferaySessionFactory";
123     public static final String TX_MANAGER = "liferayTransactionManager";
124     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
125                 "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsEntry"),
126             true);
127 
128     public static AnnouncementsEntry toModel(AnnouncementsEntrySoap soapModel) {
129         AnnouncementsEntry model = new AnnouncementsEntryImpl();
130 
131         model.setUuid(soapModel.getUuid());
132         model.setEntryId(soapModel.getEntryId());
133         model.setCompanyId(soapModel.getCompanyId());
134         model.setUserId(soapModel.getUserId());
135         model.setUserName(soapModel.getUserName());
136         model.setCreateDate(soapModel.getCreateDate());
137         model.setModifiedDate(soapModel.getModifiedDate());
138         model.setClassNameId(soapModel.getClassNameId());
139         model.setClassPK(soapModel.getClassPK());
140         model.setTitle(soapModel.getTitle());
141         model.setContent(soapModel.getContent());
142         model.setUrl(soapModel.getUrl());
143         model.setType(soapModel.getType());
144         model.setDisplayDate(soapModel.getDisplayDate());
145         model.setExpirationDate(soapModel.getExpirationDate());
146         model.setPriority(soapModel.getPriority());
147         model.setAlert(soapModel.getAlert());
148 
149         return model;
150     }
151 
152     public static List<AnnouncementsEntry> toModels(
153         AnnouncementsEntrySoap[] soapModels) {
154         List<AnnouncementsEntry> models = new ArrayList<AnnouncementsEntry>(soapModels.length);
155 
156         for (AnnouncementsEntrySoap soapModel : soapModels) {
157             models.add(toModel(soapModel));
158         }
159 
160         return models;
161     }
162 
163     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
164                 "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsEntry"));
165 
166     public AnnouncementsEntryModelImpl() {
167     }
168 
169     public long getPrimaryKey() {
170         return _entryId;
171     }
172 
173     public void setPrimaryKey(long pk) {
174         setEntryId(pk);
175     }
176 
177     public Serializable getPrimaryKeyObj() {
178         return new Long(_entryId);
179     }
180 
181     public String getUuid() {
182         return GetterUtil.getString(_uuid);
183     }
184 
185     public void setUuid(String uuid) {
186         if ((uuid != null) && (uuid != _uuid)) {
187             _uuid = uuid;
188         }
189     }
190 
191     public long getEntryId() {
192         return _entryId;
193     }
194 
195     public void setEntryId(long entryId) {
196         if (entryId != _entryId) {
197             _entryId = entryId;
198         }
199     }
200 
201     public long getCompanyId() {
202         return _companyId;
203     }
204 
205     public void setCompanyId(long companyId) {
206         if (companyId != _companyId) {
207             _companyId = companyId;
208         }
209     }
210 
211     public long getUserId() {
212         return _userId;
213     }
214 
215     public void setUserId(long userId) {
216         if (userId != _userId) {
217             _userId = userId;
218         }
219     }
220 
221     public String getUserName() {
222         return GetterUtil.getString(_userName);
223     }
224 
225     public void setUserName(String userName) {
226         if (((userName == null) && (_userName != null)) ||
227                 ((userName != null) && (_userName == null)) ||
228                 ((userName != null) && (_userName != null) &&
229                 !userName.equals(_userName))) {
230             _userName = userName;
231         }
232     }
233 
234     public Date getCreateDate() {
235         return _createDate;
236     }
237 
238     public void setCreateDate(Date createDate) {
239         if (((createDate == null) && (_createDate != null)) ||
240                 ((createDate != null) && (_createDate == null)) ||
241                 ((createDate != null) && (_createDate != null) &&
242                 !createDate.equals(_createDate))) {
243             _createDate = createDate;
244         }
245     }
246 
247     public Date getModifiedDate() {
248         return _modifiedDate;
249     }
250 
251     public void setModifiedDate(Date modifiedDate) {
252         if (((modifiedDate == null) && (_modifiedDate != null)) ||
253                 ((modifiedDate != null) && (_modifiedDate == null)) ||
254                 ((modifiedDate != null) && (_modifiedDate != null) &&
255                 !modifiedDate.equals(_modifiedDate))) {
256             _modifiedDate = modifiedDate;
257         }
258     }
259 
260     public String getClassName() {
261         if (getClassNameId() <= 0) {
262             return StringPool.BLANK;
263         }
264 
265         return PortalUtil.getClassName(getClassNameId());
266     }
267 
268     public long getClassNameId() {
269         return _classNameId;
270     }
271 
272     public void setClassNameId(long classNameId) {
273         if (classNameId != _classNameId) {
274             _classNameId = classNameId;
275         }
276     }
277 
278     public long getClassPK() {
279         return _classPK;
280     }
281 
282     public void setClassPK(long classPK) {
283         if (classPK != _classPK) {
284             _classPK = classPK;
285         }
286     }
287 
288     public String getTitle() {
289         return GetterUtil.getString(_title);
290     }
291 
292     public void setTitle(String title) {
293         if (((title == null) && (_title != null)) ||
294                 ((title != null) && (_title == null)) ||
295                 ((title != null) && (_title != null) && !title.equals(_title))) {
296             _title = title;
297         }
298     }
299 
300     public String getContent() {
301         return GetterUtil.getString(_content);
302     }
303 
304     public void setContent(String content) {
305         if (((content == null) && (_content != null)) ||
306                 ((content != null) && (_content == null)) ||
307                 ((content != null) && (_content != null) &&
308                 !content.equals(_content))) {
309             _content = content;
310         }
311     }
312 
313     public String getUrl() {
314         return GetterUtil.getString(_url);
315     }
316 
317     public void setUrl(String url) {
318         if (((url == null) && (_url != null)) ||
319                 ((url != null) && (_url == null)) ||
320                 ((url != null) && (_url != null) && !url.equals(_url))) {
321             _url = url;
322         }
323     }
324 
325     public String getType() {
326         return GetterUtil.getString(_type);
327     }
328 
329     public void setType(String type) {
330         if (((type == null) && (_type != null)) ||
331                 ((type != null) && (_type == null)) ||
332                 ((type != null) && (_type != null) && !type.equals(_type))) {
333             _type = type;
334         }
335     }
336 
337     public Date getDisplayDate() {
338         return _displayDate;
339     }
340 
341     public void setDisplayDate(Date displayDate) {
342         if (((displayDate == null) && (_displayDate != null)) ||
343                 ((displayDate != null) && (_displayDate == null)) ||
344                 ((displayDate != null) && (_displayDate != null) &&
345                 !displayDate.equals(_displayDate))) {
346             _displayDate = displayDate;
347         }
348     }
349 
350     public Date getExpirationDate() {
351         return _expirationDate;
352     }
353 
354     public void setExpirationDate(Date expirationDate) {
355         if (((expirationDate == null) && (_expirationDate != null)) ||
356                 ((expirationDate != null) && (_expirationDate == null)) ||
357                 ((expirationDate != null) && (_expirationDate != null) &&
358                 !expirationDate.equals(_expirationDate))) {
359             _expirationDate = expirationDate;
360         }
361     }
362 
363     public int getPriority() {
364         return _priority;
365     }
366 
367     public void setPriority(int priority) {
368         if (priority != _priority) {
369             _priority = priority;
370         }
371     }
372 
373     public boolean getAlert() {
374         return _alert;
375     }
376 
377     public boolean isAlert() {
378         return _alert;
379     }
380 
381     public void setAlert(boolean alert) {
382         if (alert != _alert) {
383             _alert = alert;
384         }
385     }
386 
387     public AnnouncementsEntry toEscapedModel() {
388         if (isEscapedModel()) {
389             return (AnnouncementsEntry)this;
390         }
391         else {
392             AnnouncementsEntry model = new AnnouncementsEntryImpl();
393 
394             model.setNew(isNew());
395             model.setEscapedModel(true);
396 
397             model.setUuid(HtmlUtil.escape(getUuid()));
398             model.setEntryId(getEntryId());
399             model.setCompanyId(getCompanyId());
400             model.setUserId(getUserId());
401             model.setUserName(HtmlUtil.escape(getUserName()));
402             model.setCreateDate(getCreateDate());
403             model.setModifiedDate(getModifiedDate());
404             model.setClassNameId(getClassNameId());
405             model.setClassPK(getClassPK());
406             model.setTitle(HtmlUtil.escape(getTitle()));
407             model.setContent(HtmlUtil.escape(getContent()));
408             model.setUrl(HtmlUtil.escape(getUrl()));
409             model.setType(HtmlUtil.escape(getType()));
410             model.setDisplayDate(getDisplayDate());
411             model.setExpirationDate(getExpirationDate());
412             model.setPriority(getPriority());
413             model.setAlert(getAlert());
414 
415             model = (AnnouncementsEntry)Proxy.newProxyInstance(AnnouncementsEntry.class.getClassLoader(),
416                     new Class[] { AnnouncementsEntry.class },
417                     new ReadOnlyBeanHandler(model));
418 
419             return model;
420         }
421     }
422 
423     public Object clone() {
424         AnnouncementsEntryImpl clone = new AnnouncementsEntryImpl();
425 
426         clone.setUuid(getUuid());
427         clone.setEntryId(getEntryId());
428         clone.setCompanyId(getCompanyId());
429         clone.setUserId(getUserId());
430         clone.setUserName(getUserName());
431         clone.setCreateDate(getCreateDate());
432         clone.setModifiedDate(getModifiedDate());
433         clone.setClassNameId(getClassNameId());
434         clone.setClassPK(getClassPK());
435         clone.setTitle(getTitle());
436         clone.setContent(getContent());
437         clone.setUrl(getUrl());
438         clone.setType(getType());
439         clone.setDisplayDate(getDisplayDate());
440         clone.setExpirationDate(getExpirationDate());
441         clone.setPriority(getPriority());
442         clone.setAlert(getAlert());
443 
444         return clone;
445     }
446 
447     public int compareTo(Object obj) {
448         if (obj == null) {
449             return -1;
450         }
451 
452         AnnouncementsEntryImpl announcementsEntry = (AnnouncementsEntryImpl)obj;
453 
454         int value = 0;
455 
456         if (getPriority() < announcementsEntry.getPriority()) {
457             value = -1;
458         }
459         else if (getPriority() > announcementsEntry.getPriority()) {
460             value = 1;
461         }
462         else {
463             value = 0;
464         }
465 
466         if (value != 0) {
467             return value;
468         }
469 
470         value = DateUtil.compareTo(getModifiedDate(),
471                 announcementsEntry.getModifiedDate());
472 
473         if (value != 0) {
474             return value;
475         }
476 
477         return 0;
478     }
479 
480     public boolean equals(Object obj) {
481         if (obj == null) {
482             return false;
483         }
484 
485         AnnouncementsEntryImpl announcementsEntry = null;
486 
487         try {
488             announcementsEntry = (AnnouncementsEntryImpl)obj;
489         }
490         catch (ClassCastException cce) {
491             return false;
492         }
493 
494         long pk = announcementsEntry.getPrimaryKey();
495 
496         if (getPrimaryKey() == pk) {
497             return true;
498         }
499         else {
500             return false;
501         }
502     }
503 
504     public int hashCode() {
505         return (int)getPrimaryKey();
506     }
507 
508     private String _uuid;
509     private long _entryId;
510     private long _companyId;
511     private long _userId;
512     private String _userName;
513     private Date _createDate;
514     private Date _modifiedDate;
515     private long _classNameId;
516     private long _classPK;
517     private String _title;
518     private String _content;
519     private String _url;
520     private String _type;
521     private Date _displayDate;
522     private Date _expirationDate;
523     private int _priority;
524     private boolean _alert;
525 }