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.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  import com.liferay.portal.util.PropsUtil;
31  
32  import com.liferay.portlet.blogs.model.BlogsEntry;
33  import com.liferay.portlet.blogs.model.BlogsEntrySoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.Date;
43  import java.util.List;
44  
45  /**
46   * <a href="BlogsEntryModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This class is a model that represents the <code>BlogsEntry</code> table
55   * in the database.
56   * </p>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   * @see com.liferay.portlet.blogs.service.model.BlogsEntry
61   * @see com.liferay.portlet.blogs.service.model.BlogsEntryModel
62   * @see com.liferay.portlet.blogs.service.model.impl.BlogsEntryImpl
63   *
64   */
65  public class BlogsEntryModelImpl extends BaseModelImpl {
66      public static final String TABLE_NAME = "BlogsEntry";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "uuid_", new Integer(Types.VARCHAR) },
69              
70  
71              { "entryId", 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              { "title", new Integer(Types.VARCHAR) },
93              
94  
95              { "urlTitle", new Integer(Types.VARCHAR) },
96              
97  
98              { "content", new Integer(Types.CLOB) },
99              
100 
101             { "displayDate", new Integer(Types.TIMESTAMP) }
102         };
103     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)";
104     public static final String TABLE_SQL_DROP = "drop table BlogsEntry";
105     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
106                 "value.object.finder.cache.enabled.com.liferay.portlet.blogs.model.BlogsEntry"),
107             true);
108 
109     public static BlogsEntry toModel(BlogsEntrySoap soapModel) {
110         BlogsEntry model = new BlogsEntryImpl();
111 
112         model.setUuid(soapModel.getUuid());
113         model.setEntryId(soapModel.getEntryId());
114         model.setGroupId(soapModel.getGroupId());
115         model.setCompanyId(soapModel.getCompanyId());
116         model.setUserId(soapModel.getUserId());
117         model.setUserName(soapModel.getUserName());
118         model.setCreateDate(soapModel.getCreateDate());
119         model.setModifiedDate(soapModel.getModifiedDate());
120         model.setTitle(soapModel.getTitle());
121         model.setUrlTitle(soapModel.getUrlTitle());
122         model.setContent(soapModel.getContent());
123         model.setDisplayDate(soapModel.getDisplayDate());
124 
125         return model;
126     }
127 
128     public static List<BlogsEntry> toModels(BlogsEntrySoap[] soapModels) {
129         List<BlogsEntry> models = new ArrayList<BlogsEntry>(soapModels.length);
130 
131         for (BlogsEntrySoap soapModel : soapModels) {
132             models.add(toModel(soapModel));
133         }
134 
135         return models;
136     }
137 
138     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
139                 "lock.expiration.time.com.liferay.portlet.blogs.model.BlogsEntry"));
140 
141     public BlogsEntryModelImpl() {
142     }
143 
144     public long getPrimaryKey() {
145         return _entryId;
146     }
147 
148     public void setPrimaryKey(long pk) {
149         setEntryId(pk);
150     }
151 
152     public Serializable getPrimaryKeyObj() {
153         return new Long(_entryId);
154     }
155 
156     public String getUuid() {
157         return GetterUtil.getString(_uuid);
158     }
159 
160     public void setUuid(String uuid) {
161         if ((uuid != null) && (uuid != _uuid)) {
162             _uuid = uuid;
163         }
164     }
165 
166     public long getEntryId() {
167         return _entryId;
168     }
169 
170     public void setEntryId(long entryId) {
171         if (entryId != _entryId) {
172             _entryId = entryId;
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 getTitle() {
246         return GetterUtil.getString(_title);
247     }
248 
249     public void setTitle(String title) {
250         if (((title == null) && (_title != null)) ||
251                 ((title != null) && (_title == null)) ||
252                 ((title != null) && (_title != null) && !title.equals(_title))) {
253             _title = title;
254         }
255     }
256 
257     public String getUrlTitle() {
258         return GetterUtil.getString(_urlTitle);
259     }
260 
261     public void setUrlTitle(String urlTitle) {
262         if (((urlTitle == null) && (_urlTitle != null)) ||
263                 ((urlTitle != null) && (_urlTitle == null)) ||
264                 ((urlTitle != null) && (_urlTitle != null) &&
265                 !urlTitle.equals(_urlTitle))) {
266             _urlTitle = urlTitle;
267         }
268     }
269 
270     public String getContent() {
271         return GetterUtil.getString(_content);
272     }
273 
274     public void setContent(String content) {
275         if (((content == null) && (_content != null)) ||
276                 ((content != null) && (_content == null)) ||
277                 ((content != null) && (_content != null) &&
278                 !content.equals(_content))) {
279             _content = content;
280         }
281     }
282 
283     public Date getDisplayDate() {
284         return _displayDate;
285     }
286 
287     public void setDisplayDate(Date displayDate) {
288         if (((displayDate == null) && (_displayDate != null)) ||
289                 ((displayDate != null) && (_displayDate == null)) ||
290                 ((displayDate != null) && (_displayDate != null) &&
291                 !displayDate.equals(_displayDate))) {
292             _displayDate = displayDate;
293         }
294     }
295 
296     public BlogsEntry toEscapedModel() {
297         if (isEscapedModel()) {
298             return (BlogsEntry)this;
299         }
300         else {
301             BlogsEntry model = new BlogsEntryImpl();
302 
303             model.setEscapedModel(true);
304 
305             model.setUuid(HtmlUtil.escape(getUuid()));
306             model.setEntryId(getEntryId());
307             model.setGroupId(getGroupId());
308             model.setCompanyId(getCompanyId());
309             model.setUserId(getUserId());
310             model.setUserName(HtmlUtil.escape(getUserName()));
311             model.setCreateDate(getCreateDate());
312             model.setModifiedDate(getModifiedDate());
313             model.setTitle(HtmlUtil.escape(getTitle()));
314             model.setUrlTitle(HtmlUtil.escape(getUrlTitle()));
315             model.setContent(HtmlUtil.escape(getContent()));
316             model.setDisplayDate(getDisplayDate());
317 
318             model = (BlogsEntry)Proxy.newProxyInstance(BlogsEntry.class.getClassLoader(),
319                     new Class[] { BlogsEntry.class },
320                     new ReadOnlyBeanHandler(model));
321 
322             return model;
323         }
324     }
325 
326     public Object clone() {
327         BlogsEntryImpl clone = new BlogsEntryImpl();
328 
329         clone.setUuid(getUuid());
330         clone.setEntryId(getEntryId());
331         clone.setGroupId(getGroupId());
332         clone.setCompanyId(getCompanyId());
333         clone.setUserId(getUserId());
334         clone.setUserName(getUserName());
335         clone.setCreateDate(getCreateDate());
336         clone.setModifiedDate(getModifiedDate());
337         clone.setTitle(getTitle());
338         clone.setUrlTitle(getUrlTitle());
339         clone.setContent(getContent());
340         clone.setDisplayDate(getDisplayDate());
341 
342         return clone;
343     }
344 
345     public int compareTo(Object obj) {
346         if (obj == null) {
347             return -1;
348         }
349 
350         BlogsEntryImpl blogsEntry = (BlogsEntryImpl)obj;
351 
352         int value = 0;
353 
354         value = DateUtil.compareTo(getDisplayDate(), blogsEntry.getDisplayDate());
355 
356         value = value * -1;
357 
358         if (value != 0) {
359             return value;
360         }
361 
362         return 0;
363     }
364 
365     public boolean equals(Object obj) {
366         if (obj == null) {
367             return false;
368         }
369 
370         BlogsEntryImpl blogsEntry = null;
371 
372         try {
373             blogsEntry = (BlogsEntryImpl)obj;
374         }
375         catch (ClassCastException cce) {
376             return false;
377         }
378 
379         long pk = blogsEntry.getPrimaryKey();
380 
381         if (getPrimaryKey() == pk) {
382             return true;
383         }
384         else {
385             return false;
386         }
387     }
388 
389     public int hashCode() {
390         return (int)getPrimaryKey();
391     }
392 
393     private String _uuid;
394     private long _entryId;
395     private long _groupId;
396     private long _companyId;
397     private long _userId;
398     private String _userName;
399     private Date _createDate;
400     private Date _modifiedDate;
401     private String _title;
402     private String _urlTitle;
403     private String _content;
404     private Date _displayDate;
405 }