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