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