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