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