1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.model.impl.BaseModelImpl;
29  
30  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
32  import com.liferay.portlet.wiki.model.WikiPageResource;
33  import com.liferay.portlet.wiki.model.WikiPageResourceSoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.List;
43  
44  /**
45   * <a href="WikiPageResourceModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>WikiPageResource</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.wiki.model.WikiPageResource
60   * @see com.liferay.portlet.wiki.model.WikiPageResourceModel
61   * @see com.liferay.portlet.wiki.model.impl.WikiPageResourceImpl
62   *
63   */
64  public class WikiPageResourceModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "WikiPageResource";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "resourcePrimKey", new Integer(Types.BIGINT) },
68              
69  
70              { "nodeId", new Integer(Types.BIGINT) },
71              
72  
73              { "title", new Integer(Types.VARCHAR) }
74          };
75      public static final String TABLE_SQL_CREATE = "create table WikiPageResource (resourcePrimKey LONG not null primary key,nodeId LONG,title VARCHAR(75) null)";
76      public static final String TABLE_SQL_DROP = "drop table WikiPageResource";
77      public static final String DATA_SOURCE = "liferayDataSource";
78      public static final String SESSION_FACTORY = "liferaySessionFactory";
79      public static final String TX_MANAGER = "liferayTransactionManager";
80      public static final boolean 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         if (resourcePrimKey != _resourcePrimKey) {
129             _resourcePrimKey = resourcePrimKey;
130         }
131     }
132 
133     public long getNodeId() {
134         return _nodeId;
135     }
136 
137     public void setNodeId(long nodeId) {
138         if (nodeId != _nodeId) {
139             _nodeId = nodeId;
140         }
141     }
142 
143     public String getTitle() {
144         return GetterUtil.getString(_title);
145     }
146 
147     public void setTitle(String title) {
148         if (((title == null) && (_title != null)) ||
149                 ((title != null) && (_title == null)) ||
150                 ((title != null) && (_title != null) && !title.equals(_title))) {
151             _title = title;
152         }
153     }
154 
155     public WikiPageResource toEscapedModel() {
156         if (isEscapedModel()) {
157             return (WikiPageResource)this;
158         }
159         else {
160             WikiPageResource model = new WikiPageResourceImpl();
161 
162             model.setNew(isNew());
163             model.setEscapedModel(true);
164 
165             model.setResourcePrimKey(getResourcePrimKey());
166             model.setNodeId(getNodeId());
167             model.setTitle(HtmlUtil.escape(getTitle()));
168 
169             model = (WikiPageResource)Proxy.newProxyInstance(WikiPageResource.class.getClassLoader(),
170                     new Class[] { WikiPageResource.class },
171                     new ReadOnlyBeanHandler(model));
172 
173             return model;
174         }
175     }
176 
177     public ExpandoBridge getExpandoBridge() {
178         if (_expandoBridge == null) {
179             _expandoBridge = new ExpandoBridgeImpl(WikiPageResource.class.getName(),
180                     getPrimaryKey());
181         }
182 
183         return _expandoBridge;
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(Object obj) {
197         if (obj == null) {
198             return -1;
199         }
200 
201         WikiPageResourceImpl wikiPageResource = (WikiPageResourceImpl)obj;
202 
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         WikiPageResourceImpl wikiPageResource = null;
222 
223         try {
224             wikiPageResource = (WikiPageResourceImpl)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     private long _resourcePrimKey;
245     private long _nodeId;
246     private String _title;
247     private transient ExpandoBridge _expandoBridge;
248 }