1   /**
2    * Copyright (c) 2000-2007 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.util.DateUtil;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.XSSUtil;
31  
32  import java.io.Serializable;
33  
34  import java.sql.Types;
35  
36  import java.util.Date;
37  
38  /**
39   * <a href="BlogsEntryModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be overwritten
43   * the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>BlogsEntry</code> table in the
48   * database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portlet.blogs.service.model.BlogsEntry
54   * @see com.liferay.portlet.blogs.service.model.BlogsEntryModel
55   * @see com.liferay.portlet.blogs.service.model.impl.BlogsEntryImpl
56   *
57   */
58  public class BlogsEntryModelImpl extends BaseModelImpl {
59      public static String TABLE_NAME = "BlogsEntry";
60      public static Object[][] TABLE_COLUMNS = {
61              { "entryId", new Integer(Types.BIGINT) },
62              { "groupId", new Integer(Types.BIGINT) },
63              { "companyId", new Integer(Types.BIGINT) },
64              { "userId", new Integer(Types.BIGINT) },
65              { "userName", new Integer(Types.VARCHAR) },
66              { "createDate", new Integer(Types.TIMESTAMP) },
67              { "modifiedDate", new Integer(Types.TIMESTAMP) },
68              { "categoryId", new Integer(Types.BIGINT) },
69              { "title", new Integer(Types.VARCHAR) },
70              { "urlTitle", new Integer(Types.VARCHAR) },
71              { "content", new Integer(Types.CLOB) },
72              { "displayDate", new Integer(Types.TIMESTAMP) }
73          };
74      public static String TABLE_SQL_CREATE = "create table BlogsEntry (entryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,categoryId LONG,title VARCHAR(150) null,urlTitle VARCHAR(150) null,content TEXT null,displayDate DATE null)";
75      public static String TABLE_SQL_DROP = "drop table BlogsEntry";
76      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
77                  "xss.allow.com.liferay.portlet.blogs.model.BlogsEntry"),
78              XSS_ALLOW);
79      public static boolean XSS_ALLOW_USERNAME = GetterUtil.getBoolean(PropsUtil.get(
80                  "xss.allow.com.liferay.portlet.blogs.model.BlogsEntry.userName"),
81              XSS_ALLOW_BY_MODEL);
82      public static boolean XSS_ALLOW_TITLE = GetterUtil.getBoolean(PropsUtil.get(
83                  "xss.allow.com.liferay.portlet.blogs.model.BlogsEntry.title"),
84              XSS_ALLOW_BY_MODEL);
85      public static boolean XSS_ALLOW_URLTITLE = GetterUtil.getBoolean(PropsUtil.get(
86                  "xss.allow.com.liferay.portlet.blogs.model.BlogsEntry.urlTitle"),
87              XSS_ALLOW_BY_MODEL);
88      public static boolean XSS_ALLOW_CONTENT = GetterUtil.getBoolean(PropsUtil.get(
89                  "xss.allow.com.liferay.portlet.blogs.model.BlogsEntry.content"),
90              XSS_ALLOW_BY_MODEL);
91      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
92                  "lock.expiration.time.com.liferay.portlet.blogs.model.BlogsEntryModel"));
93  
94      public BlogsEntryModelImpl() {
95      }
96  
97      public long getPrimaryKey() {
98          return _entryId;
99      }
100 
101     public void setPrimaryKey(long pk) {
102         setEntryId(pk);
103     }
104 
105     public Serializable getPrimaryKeyObj() {
106         return new Long(_entryId);
107     }
108 
109     public long getEntryId() {
110         return _entryId;
111     }
112 
113     public void setEntryId(long entryId) {
114         if (entryId != _entryId) {
115             _entryId = entryId;
116         }
117     }
118 
119     public long getGroupId() {
120         return _groupId;
121     }
122 
123     public void setGroupId(long groupId) {
124         if (groupId != _groupId) {
125             _groupId = groupId;
126         }
127     }
128 
129     public long getCompanyId() {
130         return _companyId;
131     }
132 
133     public void setCompanyId(long companyId) {
134         if (companyId != _companyId) {
135             _companyId = companyId;
136         }
137     }
138 
139     public long getUserId() {
140         return _userId;
141     }
142 
143     public void setUserId(long userId) {
144         if (userId != _userId) {
145             _userId = userId;
146         }
147     }
148 
149     public String getUserName() {
150         return GetterUtil.getString(_userName);
151     }
152 
153     public void setUserName(String userName) {
154         if (((userName == null) && (_userName != null)) ||
155                 ((userName != null) && (_userName == null)) ||
156                 ((userName != null) && (_userName != null) &&
157                 !userName.equals(_userName))) {
158             if (!XSS_ALLOW_USERNAME) {
159                 userName = XSSUtil.strip(userName);
160             }
161 
162             _userName = userName;
163         }
164     }
165 
166     public Date getCreateDate() {
167         return _createDate;
168     }
169 
170     public void setCreateDate(Date createDate) {
171         if (((createDate == null) && (_createDate != null)) ||
172                 ((createDate != null) && (_createDate == null)) ||
173                 ((createDate != null) && (_createDate != null) &&
174                 !createDate.equals(_createDate))) {
175             _createDate = createDate;
176         }
177     }
178 
179     public Date getModifiedDate() {
180         return _modifiedDate;
181     }
182 
183     public void setModifiedDate(Date modifiedDate) {
184         if (((modifiedDate == null) && (_modifiedDate != null)) ||
185                 ((modifiedDate != null) && (_modifiedDate == null)) ||
186                 ((modifiedDate != null) && (_modifiedDate != null) &&
187                 !modifiedDate.equals(_modifiedDate))) {
188             _modifiedDate = modifiedDate;
189         }
190     }
191 
192     public long getCategoryId() {
193         return _categoryId;
194     }
195 
196     public void setCategoryId(long categoryId) {
197         if (categoryId != _categoryId) {
198             _categoryId = categoryId;
199         }
200     }
201 
202     public String getTitle() {
203         return GetterUtil.getString(_title);
204     }
205 
206     public void setTitle(String title) {
207         if (((title == null) && (_title != null)) ||
208                 ((title != null) && (_title == null)) ||
209                 ((title != null) && (_title != null) && !title.equals(_title))) {
210             if (!XSS_ALLOW_TITLE) {
211                 title = XSSUtil.strip(title);
212             }
213 
214             _title = title;
215         }
216     }
217 
218     public String getUrlTitle() {
219         return GetterUtil.getString(_urlTitle);
220     }
221 
222     public void setUrlTitle(String urlTitle) {
223         if (((urlTitle == null) && (_urlTitle != null)) ||
224                 ((urlTitle != null) && (_urlTitle == null)) ||
225                 ((urlTitle != null) && (_urlTitle != null) &&
226                 !urlTitle.equals(_urlTitle))) {
227             if (!XSS_ALLOW_URLTITLE) {
228                 urlTitle = XSSUtil.strip(urlTitle);
229             }
230 
231             _urlTitle = urlTitle;
232         }
233     }
234 
235     public String getContent() {
236         return GetterUtil.getString(_content);
237     }
238 
239     public void setContent(String content) {
240         if (((content == null) && (_content != null)) ||
241                 ((content != null) && (_content == null)) ||
242                 ((content != null) && (_content != null) &&
243                 !content.equals(_content))) {
244             if (!XSS_ALLOW_CONTENT) {
245                 content = XSSUtil.strip(content);
246             }
247 
248             _content = content;
249         }
250     }
251 
252     public Date getDisplayDate() {
253         return _displayDate;
254     }
255 
256     public void setDisplayDate(Date displayDate) {
257         if (((displayDate == null) && (_displayDate != null)) ||
258                 ((displayDate != null) && (_displayDate == null)) ||
259                 ((displayDate != null) && (_displayDate != null) &&
260                 !displayDate.equals(_displayDate))) {
261             _displayDate = displayDate;
262         }
263     }
264 
265     public Object clone() {
266         BlogsEntryImpl clone = new BlogsEntryImpl();
267         clone.setEntryId(getEntryId());
268         clone.setGroupId(getGroupId());
269         clone.setCompanyId(getCompanyId());
270         clone.setUserId(getUserId());
271         clone.setUserName(getUserName());
272         clone.setCreateDate(getCreateDate());
273         clone.setModifiedDate(getModifiedDate());
274         clone.setCategoryId(getCategoryId());
275         clone.setTitle(getTitle());
276         clone.setUrlTitle(getUrlTitle());
277         clone.setContent(getContent());
278         clone.setDisplayDate(getDisplayDate());
279 
280         return clone;
281     }
282 
283     public int compareTo(Object obj) {
284         if (obj == null) {
285             return -1;
286         }
287 
288         BlogsEntryImpl blogsEntry = (BlogsEntryImpl)obj;
289         int value = 0;
290         value = DateUtil.compareTo(getDisplayDate(), blogsEntry.getDisplayDate());
291         value = value * -1;
292 
293         if (value != 0) {
294             return value;
295         }
296 
297         return 0;
298     }
299 
300     public boolean equals(Object obj) {
301         if (obj == null) {
302             return false;
303         }
304 
305         BlogsEntryImpl blogsEntry = null;
306 
307         try {
308             blogsEntry = (BlogsEntryImpl)obj;
309         }
310         catch (ClassCastException cce) {
311             return false;
312         }
313 
314         long pk = blogsEntry.getPrimaryKey();
315 
316         if (getPrimaryKey() == pk) {
317             return true;
318         }
319         else {
320             return false;
321         }
322     }
323 
324     public int hashCode() {
325         return (int)getPrimaryKey();
326     }
327 
328     private long _entryId;
329     private long _groupId;
330     private long _companyId;
331     private long _userId;
332     private String _userName;
333     private Date _createDate;
334     private Date _modifiedDate;
335     private long _categoryId;
336     private String _title;
337     private String _urlTitle;
338     private String _content;
339     private Date _displayDate;
340 }