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.WikiPageResource;
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  /**
41   * <a href="WikiPageResourceModelImpl.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>WikiPageResource</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.wiki.service.model.WikiPageResource
56   * @see com.liferay.portlet.wiki.service.model.WikiPageResourceModel
57   * @see com.liferay.portlet.wiki.service.model.impl.WikiPageResourceImpl
58   *
59   */
60  public class WikiPageResourceModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "WikiPageResource";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "resourcePrimKey", new Integer(Types.BIGINT) },
64              
65  
66              { "nodeId", new Integer(Types.BIGINT) },
67              
68  
69              { "title", new Integer(Types.VARCHAR) }
70          };
71      public static final String TABLE_SQL_CREATE = "create table WikiPageResource (resourcePrimKey LONG not null primary key,nodeId LONG,title VARCHAR(75) null)";
72      public static final String TABLE_SQL_DROP = "drop table WikiPageResource";
73      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
74                  "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiPageResource"),
75              true);
76      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
77                  "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPageResource"));
78  
79      public WikiPageResourceModelImpl() {
80      }
81  
82      public long getPrimaryKey() {
83          return _resourcePrimKey;
84      }
85  
86      public void setPrimaryKey(long pk) {
87          setResourcePrimKey(pk);
88      }
89  
90      public Serializable getPrimaryKeyObj() {
91          return new Long(_resourcePrimKey);
92      }
93  
94      public long getResourcePrimKey() {
95          return _resourcePrimKey;
96      }
97  
98      public void setResourcePrimKey(long resourcePrimKey) {
99          if (resourcePrimKey != _resourcePrimKey) {
100             _resourcePrimKey = resourcePrimKey;
101         }
102     }
103 
104     public long getNodeId() {
105         return _nodeId;
106     }
107 
108     public void setNodeId(long nodeId) {
109         if (nodeId != _nodeId) {
110             _nodeId = nodeId;
111         }
112     }
113 
114     public String getTitle() {
115         return GetterUtil.getString(_title);
116     }
117 
118     public void setTitle(String title) {
119         if (((title == null) && (_title != null)) ||
120                 ((title != null) && (_title == null)) ||
121                 ((title != null) && (_title != null) && !title.equals(_title))) {
122             _title = title;
123         }
124     }
125 
126     public WikiPageResource toEscapedModel() {
127         if (isEscapedModel()) {
128             return (WikiPageResource)this;
129         }
130         else {
131             WikiPageResource model = new WikiPageResourceImpl();
132 
133             model.setEscapedModel(true);
134 
135             model.setResourcePrimKey(getResourcePrimKey());
136             model.setNodeId(getNodeId());
137             model.setTitle(Html.escape(getTitle()));
138 
139             model = (WikiPageResource)Proxy.newProxyInstance(WikiPageResource.class.getClassLoader(),
140                     new Class[] { WikiPageResource.class },
141                     new ReadOnlyBeanHandler(model));
142 
143             return model;
144         }
145     }
146 
147     public Object clone() {
148         WikiPageResourceImpl clone = new WikiPageResourceImpl();
149 
150         clone.setResourcePrimKey(getResourcePrimKey());
151         clone.setNodeId(getNodeId());
152         clone.setTitle(getTitle());
153 
154         return clone;
155     }
156 
157     public int compareTo(Object obj) {
158         if (obj == null) {
159             return -1;
160         }
161 
162         WikiPageResourceImpl wikiPageResource = (WikiPageResourceImpl)obj;
163 
164         long pk = wikiPageResource.getPrimaryKey();
165 
166         if (getPrimaryKey() < pk) {
167             return -1;
168         }
169         else if (getPrimaryKey() > pk) {
170             return 1;
171         }
172         else {
173             return 0;
174         }
175     }
176 
177     public boolean equals(Object obj) {
178         if (obj == null) {
179             return false;
180         }
181 
182         WikiPageResourceImpl wikiPageResource = null;
183 
184         try {
185             wikiPageResource = (WikiPageResourceImpl)obj;
186         }
187         catch (ClassCastException cce) {
188             return false;
189         }
190 
191         long pk = wikiPageResource.getPrimaryKey();
192 
193         if (getPrimaryKey() == pk) {
194             return true;
195         }
196         else {
197             return false;
198         }
199     }
200 
201     public int hashCode() {
202         return (int)getPrimaryKey();
203     }
204 
205     private long _resourcePrimKey;
206     private long _nodeId;
207     private String _title;
208 }