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