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