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.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
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         if (_title == null) {
143             return StringPool.BLANK;
144         }
145         else {
146             return _title;
147         }
148     }
149 
150     public void setTitle(String title) {
151         _title = title;
152 
153         if (_originalTitle == null) {
154             _originalTitle = title;
155         }
156     }
157 
158     public String getOriginalTitle() {
159         return GetterUtil.getString(_originalTitle);
160     }
161 
162     public WikiPageResource toEscapedModel() {
163         if (isEscapedModel()) {
164             return (WikiPageResource)this;
165         }
166         else {
167             return (WikiPageResource)Proxy.newProxyInstance(WikiPageResource.class.getClassLoader(),
168                 new Class[] { WikiPageResource.class },
169                 new AutoEscapeBeanHandler(this));
170         }
171     }
172 
173     public ExpandoBridge getExpandoBridge() {
174         if (_expandoBridge == null) {
175             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(WikiPageResource.class.getName(),
176                     getResourcePrimKey());
177         }
178 
179         return _expandoBridge;
180     }
181 
182     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
183         getExpandoBridge().setAttributes(serviceContext);
184     }
185 
186     public Object clone() {
187         WikiPageResourceImpl clone = new WikiPageResourceImpl();
188 
189         clone.setResourcePrimKey(getResourcePrimKey());
190         clone.setNodeId(getNodeId());
191         clone.setTitle(getTitle());
192 
193         return clone;
194     }
195 
196     public int compareTo(WikiPageResource wikiPageResource) {
197         long pk = wikiPageResource.getPrimaryKey();
198 
199         if (getPrimaryKey() < pk) {
200             return -1;
201         }
202         else if (getPrimaryKey() > pk) {
203             return 1;
204         }
205         else {
206             return 0;
207         }
208     }
209 
210     public boolean equals(Object obj) {
211         if (obj == null) {
212             return false;
213         }
214 
215         WikiPageResource wikiPageResource = null;
216 
217         try {
218             wikiPageResource = (WikiPageResource)obj;
219         }
220         catch (ClassCastException cce) {
221             return false;
222         }
223 
224         long pk = wikiPageResource.getPrimaryKey();
225 
226         if (getPrimaryKey() == pk) {
227             return true;
228         }
229         else {
230             return false;
231         }
232     }
233 
234     public int hashCode() {
235         return (int)getPrimaryKey();
236     }
237 
238     public String toString() {
239         StringBundler sb = new StringBundler(7);
240 
241         sb.append("{resourcePrimKey=");
242         sb.append(getResourcePrimKey());
243         sb.append(", nodeId=");
244         sb.append(getNodeId());
245         sb.append(", title=");
246         sb.append(getTitle());
247         sb.append("}");
248 
249         return sb.toString();
250     }
251 
252     public String toXmlString() {
253         StringBundler sb = new StringBundler(13);
254 
255         sb.append("<model><model-name>");
256         sb.append("com.liferay.portlet.wiki.model.WikiPageResource");
257         sb.append("</model-name>");
258 
259         sb.append(
260             "<column><column-name>resourcePrimKey</column-name><column-value><![CDATA[");
261         sb.append(getResourcePrimKey());
262         sb.append("]]></column-value></column>");
263         sb.append(
264             "<column><column-name>nodeId</column-name><column-value><![CDATA[");
265         sb.append(getNodeId());
266         sb.append("]]></column-value></column>");
267         sb.append(
268             "<column><column-name>title</column-name><column-value><![CDATA[");
269         sb.append(getTitle());
270         sb.append("]]></column-value></column>");
271 
272         sb.append("</model>");
273 
274         return sb.toString();
275     }
276 
277     private long _resourcePrimKey;
278     private long _nodeId;
279     private long _originalNodeId;
280     private boolean _setOriginalNodeId;
281     private String _title;
282     private String _originalTitle;
283     private transient ExpandoBridge _expandoBridge;
284 }