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