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