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