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.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
29  import com.liferay.portlet.wiki.model.WikiPageResource;
30  import com.liferay.portlet.wiki.model.WikiPageResourceSoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="WikiPageResourceModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>WikiPageResource</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portlet.wiki.model.WikiPageResource
57   * @see com.liferay.portlet.wiki.model.WikiPageResourceModel
58   * @see com.liferay.portlet.wiki.model.impl.WikiPageResourceImpl
59   *
60   */
61  public class WikiPageResourceModelImpl extends BaseModelImpl<WikiPageResource> {
62      public static final String TABLE_NAME = "WikiPageResource";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "resourcePrimKey", new Integer(Types.BIGINT) },
65              
66  
67              { "nodeId", new Integer(Types.BIGINT) },
68              
69  
70              { "title", new Integer(Types.VARCHAR) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table WikiPageResource (resourcePrimKey LONG not null primary key,nodeId LONG,title VARCHAR(75) null)";
73      public static final String TABLE_SQL_DROP = "drop table WikiPageResource";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.entity.cache.enabled.com.liferay.portlet.wiki.model.WikiPageResource"),
79              true);
80      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiPageResource"),
82              true);
83  
84      public static WikiPageResource toModel(WikiPageResourceSoap soapModel) {
85          WikiPageResource model = new WikiPageResourceImpl();
86  
87          model.setResourcePrimKey(soapModel.getResourcePrimKey());
88          model.setNodeId(soapModel.getNodeId());
89          model.setTitle(soapModel.getTitle());
90  
91          return model;
92      }
93  
94      public static List<WikiPageResource> toModels(
95          WikiPageResourceSoap[] soapModels) {
96          List<WikiPageResource> models = new ArrayList<WikiPageResource>(soapModels.length);
97  
98          for (WikiPageResourceSoap soapModel : soapModels) {
99              models.add(toModel(soapModel));
100         }
101 
102         return models;
103     }
104 
105     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                 "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPageResource"));
107 
108     public WikiPageResourceModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _resourcePrimKey;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setResourcePrimKey(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_resourcePrimKey);
121     }
122 
123     public long getResourcePrimKey() {
124         return _resourcePrimKey;
125     }
126 
127     public void setResourcePrimKey(long resourcePrimKey) {
128         _resourcePrimKey = resourcePrimKey;
129     }
130 
131     public long getNodeId() {
132         return _nodeId;
133     }
134 
135     public void setNodeId(long nodeId) {
136         _nodeId = nodeId;
137 
138         if (!_setOriginalNodeId) {
139             _setOriginalNodeId = true;
140 
141             _originalNodeId = nodeId;
142         }
143     }
144 
145     public long getOriginalNodeId() {
146         return _originalNodeId;
147     }
148 
149     public String getTitle() {
150         return GetterUtil.getString(_title);
151     }
152 
153     public void setTitle(String title) {
154         _title = title;
155 
156         if (_originalTitle == null) {
157             _originalTitle = title;
158         }
159     }
160 
161     public String getOriginalTitle() {
162         return GetterUtil.getString(_originalTitle);
163     }
164 
165     public WikiPageResource toEscapedModel() {
166         if (isEscapedModel()) {
167             return (WikiPageResource)this;
168         }
169         else {
170             WikiPageResource model = new WikiPageResourceImpl();
171 
172             model.setNew(isNew());
173             model.setEscapedModel(true);
174 
175             model.setResourcePrimKey(getResourcePrimKey());
176             model.setNodeId(getNodeId());
177             model.setTitle(HtmlUtil.escape(getTitle()));
178 
179             model = (WikiPageResource)Proxy.newProxyInstance(WikiPageResource.class.getClassLoader(),
180                     new Class[] { WikiPageResource.class },
181                     new ReadOnlyBeanHandler(model));
182 
183             return model;
184         }
185     }
186 
187     public ExpandoBridge getExpandoBridge() {
188         if (_expandoBridge == null) {
189             _expandoBridge = new ExpandoBridgeImpl(WikiPageResource.class.getName(),
190                     getPrimaryKey());
191         }
192 
193         return _expandoBridge;
194     }
195 
196     public Object clone() {
197         WikiPageResourceImpl clone = new WikiPageResourceImpl();
198 
199         clone.setResourcePrimKey(getResourcePrimKey());
200         clone.setNodeId(getNodeId());
201         clone.setTitle(getTitle());
202 
203         return clone;
204     }
205 
206     public int compareTo(WikiPageResource wikiPageResource) {
207         long pk = wikiPageResource.getPrimaryKey();
208 
209         if (getPrimaryKey() < pk) {
210             return -1;
211         }
212         else if (getPrimaryKey() > pk) {
213             return 1;
214         }
215         else {
216             return 0;
217         }
218     }
219 
220     public boolean equals(Object obj) {
221         if (obj == null) {
222             return false;
223         }
224 
225         WikiPageResource wikiPageResource = null;
226 
227         try {
228             wikiPageResource = (WikiPageResource)obj;
229         }
230         catch (ClassCastException cce) {
231             return false;
232         }
233 
234         long pk = wikiPageResource.getPrimaryKey();
235 
236         if (getPrimaryKey() == pk) {
237             return true;
238         }
239         else {
240             return false;
241         }
242     }
243 
244     public int hashCode() {
245         return (int)getPrimaryKey();
246     }
247 
248     public String toString() {
249         StringBuilder sb = new StringBuilder();
250 
251         sb.append("{resourcePrimKey=");
252         sb.append(getResourcePrimKey());
253         sb.append(", nodeId=");
254         sb.append(getNodeId());
255         sb.append(", title=");
256         sb.append(getTitle());
257         sb.append("}");
258 
259         return sb.toString();
260     }
261 
262     public String toXmlString() {
263         StringBuilder sb = new StringBuilder();
264 
265         sb.append("<model><model-name>");
266         sb.append("com.liferay.portlet.wiki.model.WikiPageResource");
267         sb.append("</model-name>");
268 
269         sb.append(
270             "<column><column-name>resourcePrimKey</column-name><column-value><![CDATA[");
271         sb.append(getResourcePrimKey());
272         sb.append("]]></column-value></column>");
273         sb.append(
274             "<column><column-name>nodeId</column-name><column-value><![CDATA[");
275         sb.append(getNodeId());
276         sb.append("]]></column-value></column>");
277         sb.append(
278             "<column><column-name>title</column-name><column-value><![CDATA[");
279         sb.append(getTitle());
280         sb.append("]]></column-value></column>");
281 
282         sb.append("</model>");
283 
284         return sb.toString();
285     }
286 
287     private long _resourcePrimKey;
288     private long _nodeId;
289     private long _originalNodeId;
290     private boolean _setOriginalNodeId;
291     private String _title;
292     private String _originalTitle;
293     private transient ExpandoBridge _expandoBridge;
294 }