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