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