1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.wiki.model.WikiPageResource;
31  import com.liferay.portlet.wiki.model.WikiPageResourceSoap;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  
42  /**
43   * <a href="WikiPageResourceModelImpl.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 interface is a model that represents the WikiPageResource table in the
52   * database.
53   * </p>
54   *
55   * @author    Brian Wing Shun Chan
56   * @see       WikiPageResourceImpl
57   * @see       com.liferay.portlet.wiki.model.WikiPageResource
58   * @see       com.liferay.portlet.wiki.model.WikiPageResourceModel
59   * @generated
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              { "nodeId", new Integer(Types.BIGINT) },
66              { "title", new Integer(Types.VARCHAR) }
67          };
68      public static final String TABLE_SQL_CREATE = "create table WikiPageResource (resourcePrimKey LONG not null primary key,nodeId LONG,title VARCHAR(255) null)";
69      public static final String TABLE_SQL_DROP = "drop table WikiPageResource";
70      public static final String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.entity.cache.enabled.com.liferay.portlet.wiki.model.WikiPageResource"),
75              true);
76      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiPageResource"),
78              true);
79  
80      public static WikiPageResource toModel(WikiPageResourceSoap soapModel) {
81          WikiPageResource model = new WikiPageResourceImpl();
82  
83          model.setResourcePrimKey(soapModel.getResourcePrimKey());
84          model.setNodeId(soapModel.getNodeId());
85          model.setTitle(soapModel.getTitle());
86  
87          return model;
88      }
89  
90      public static List<WikiPageResource> toModels(
91          WikiPageResourceSoap[] soapModels) {
92          List<WikiPageResource> models = new ArrayList<WikiPageResource>(soapModels.length);
93  
94          for (WikiPageResourceSoap soapModel : soapModels) {
95              models.add(toModel(soapModel));
96          }
97  
98          return models;
99      }
100 
101     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
102                 "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPageResource"));
103 
104     public WikiPageResourceModelImpl() {
105     }
106 
107     public long getPrimaryKey() {
108         return _resourcePrimKey;
109     }
110 
111     public void setPrimaryKey(long pk) {
112         setResourcePrimKey(pk);
113     }
114 
115     public Serializable getPrimaryKeyObj() {
116         return new Long(_resourcePrimKey);
117     }
118 
119     public long getResourcePrimKey() {
120         return _resourcePrimKey;
121     }
122 
123     public void setResourcePrimKey(long resourcePrimKey) {
124         _resourcePrimKey = resourcePrimKey;
125     }
126 
127     public long getNodeId() {
128         return _nodeId;
129     }
130 
131     public void setNodeId(long nodeId) {
132         _nodeId = nodeId;
133 
134         if (!_setOriginalNodeId) {
135             _setOriginalNodeId = true;
136 
137             _originalNodeId = nodeId;
138         }
139     }
140 
141     public long getOriginalNodeId() {
142         return _originalNodeId;
143     }
144 
145     public String getTitle() {
146         return GetterUtil.getString(_title);
147     }
148 
149     public void setTitle(String title) {
150         _title = title;
151 
152         if (_originalTitle == null) {
153             _originalTitle = title;
154         }
155     }
156 
157     public String getOriginalTitle() {
158         return GetterUtil.getString(_originalTitle);
159     }
160 
161     public WikiPageResource toEscapedModel() {
162         if (isEscapedModel()) {
163             return (WikiPageResource)this;
164         }
165         else {
166             WikiPageResource model = new WikiPageResourceImpl();
167 
168             model.setNew(isNew());
169             model.setEscapedModel(true);
170 
171             model.setResourcePrimKey(getResourcePrimKey());
172             model.setNodeId(getNodeId());
173             model.setTitle(HtmlUtil.escape(getTitle()));
174 
175             model = (WikiPageResource)Proxy.newProxyInstance(WikiPageResource.class.getClassLoader(),
176                     new Class[] { WikiPageResource.class },
177                     new ReadOnlyBeanHandler(model));
178 
179             return model;
180         }
181     }
182 
183     public Object clone() {
184         WikiPageResourceImpl clone = new WikiPageResourceImpl();
185 
186         clone.setResourcePrimKey(getResourcePrimKey());
187         clone.setNodeId(getNodeId());
188         clone.setTitle(getTitle());
189 
190         return clone;
191     }
192 
193     public int compareTo(WikiPageResource wikiPageResource) {
194         long pk = wikiPageResource.getPrimaryKey();
195 
196         if (getPrimaryKey() < pk) {
197             return -1;
198         }
199         else if (getPrimaryKey() > pk) {
200             return 1;
201         }
202         else {
203             return 0;
204         }
205     }
206 
207     public boolean equals(Object obj) {
208         if (obj == null) {
209             return false;
210         }
211 
212         WikiPageResource wikiPageResource = null;
213 
214         try {
215             wikiPageResource = (WikiPageResource)obj;
216         }
217         catch (ClassCastException cce) {
218             return false;
219         }
220 
221         long pk = wikiPageResource.getPrimaryKey();
222 
223         if (getPrimaryKey() == pk) {
224             return true;
225         }
226         else {
227             return false;
228         }
229     }
230 
231     public int hashCode() {
232         return (int)getPrimaryKey();
233     }
234 
235     public String toString() {
236         StringBuilder sb = new StringBuilder();
237 
238         sb.append("{resourcePrimKey=");
239         sb.append(getResourcePrimKey());
240         sb.append(", nodeId=");
241         sb.append(getNodeId());
242         sb.append(", title=");
243         sb.append(getTitle());
244         sb.append("}");
245 
246         return sb.toString();
247     }
248 
249     public String toXmlString() {
250         StringBuilder sb = new StringBuilder();
251 
252         sb.append("<model><model-name>");
253         sb.append("com.liferay.portlet.wiki.model.WikiPageResource");
254         sb.append("</model-name>");
255 
256         sb.append(
257             "<column><column-name>resourcePrimKey</column-name><column-value><![CDATA[");
258         sb.append(getResourcePrimKey());
259         sb.append("]]></column-value></column>");
260         sb.append(
261             "<column><column-name>nodeId</column-name><column-value><![CDATA[");
262         sb.append(getNodeId());
263         sb.append("]]></column-value></column>");
264         sb.append(
265             "<column><column-name>title</column-name><column-value><![CDATA[");
266         sb.append(getTitle());
267         sb.append("]]></column-value></column>");
268 
269         sb.append("</model>");
270 
271         return sb.toString();
272     }
273 
274     private long _resourcePrimKey;
275     private long _nodeId;
276     private long _originalNodeId;
277     private boolean _setOriginalNodeId;
278     private String _title;
279     private String _originalTitle;
280 }