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.kernel.util.StringBundler;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.service.ServiceContext;
31  
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
34  import com.liferay.portlet.wiki.model.WikiPageResource;
35  import com.liferay.portlet.wiki.model.WikiPageResourceSoap;
36  
37  import java.io.Serializable;
38  
39  import java.lang.reflect.Proxy;
40  
41  import java.sql.Types;
42  
43  import java.util.ArrayList;
44  import java.util.List;
45  
46  /**
47   * <a href="WikiPageResourceModelImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * <p>
50   * ServiceBuilder generated this class. Modifications in this class will be
51   * overwritten the next time is generated.
52   * </p>
53   *
54   * <p>
55   * This interface is a model that represents the WikiPageResource table in the
56   * database.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       WikiPageResourceImpl
61   * @see       com.liferay.portlet.wiki.model.WikiPageResource
62   * @see       com.liferay.portlet.wiki.model.WikiPageResourceModel
63   * @generated
64   */
65  public class WikiPageResourceModelImpl extends BaseModelImpl<WikiPageResource> {
66      public static final String TABLE_NAME = "WikiPageResource";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "resourcePrimKey", new Integer(Types.BIGINT) },
69              { "nodeId", new Integer(Types.BIGINT) },
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(255) 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 = ExpandoBridgeFactoryUtil.getExpandoBridge(WikiPageResource.class.getName(),
190                     getResourcePrimKey());
191         }
192 
193         return _expandoBridge;
194     }
195 
196     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
197         getExpandoBridge().setAttributes(serviceContext);
198     }
199 
200     public Object clone() {
201         WikiPageResourceImpl clone = new WikiPageResourceImpl();
202 
203         clone.setResourcePrimKey(getResourcePrimKey());
204         clone.setNodeId(getNodeId());
205         clone.setTitle(getTitle());
206 
207         return clone;
208     }
209 
210     public int compareTo(WikiPageResource wikiPageResource) {
211         long pk = wikiPageResource.getPrimaryKey();
212 
213         if (getPrimaryKey() < pk) {
214             return -1;
215         }
216         else if (getPrimaryKey() > pk) {
217             return 1;
218         }
219         else {
220             return 0;
221         }
222     }
223 
224     public boolean equals(Object obj) {
225         if (obj == null) {
226             return false;
227         }
228 
229         WikiPageResource wikiPageResource = null;
230 
231         try {
232             wikiPageResource = (WikiPageResource)obj;
233         }
234         catch (ClassCastException cce) {
235             return false;
236         }
237 
238         long pk = wikiPageResource.getPrimaryKey();
239 
240         if (getPrimaryKey() == pk) {
241             return true;
242         }
243         else {
244             return false;
245         }
246     }
247 
248     public int hashCode() {
249         return (int)getPrimaryKey();
250     }
251 
252     public String toString() {
253         StringBundler sb = new StringBundler(7);
254 
255         sb.append("{resourcePrimKey=");
256         sb.append(getResourcePrimKey());
257         sb.append(", nodeId=");
258         sb.append(getNodeId());
259         sb.append(", title=");
260         sb.append(getTitle());
261         sb.append("}");
262 
263         return sb.toString();
264     }
265 
266     public String toXmlString() {
267         StringBundler sb = new StringBundler(13);
268 
269         sb.append("<model><model-name>");
270         sb.append("com.liferay.portlet.wiki.model.WikiPageResource");
271         sb.append("</model-name>");
272 
273         sb.append(
274             "<column><column-name>resourcePrimKey</column-name><column-value><![CDATA[");
275         sb.append(getResourcePrimKey());
276         sb.append("]]></column-value></column>");
277         sb.append(
278             "<column><column-name>nodeId</column-name><column-value><![CDATA[");
279         sb.append(getNodeId());
280         sb.append("]]></column-value></column>");
281         sb.append(
282             "<column><column-name>title</column-name><column-value><![CDATA[");
283         sb.append(getTitle());
284         sb.append("]]></column-value></column>");
285 
286         sb.append("</model>");
287 
288         return sb.toString();
289     }
290 
291     private long _resourcePrimKey;
292     private long _nodeId;
293     private long _originalNodeId;
294     private boolean _setOriginalNodeId;
295     private String _title;
296     private String _originalTitle;
297     private transient ExpandoBridge _expandoBridge;
298 }