1   /**
2    * Copyright (c) 2000-2008 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.wiki.model.WikiPageResource;
31  import com.liferay.portlet.wiki.model.WikiPageResourceSoap;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  
42  /**
43   * <a href="WikiPageResourceModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>WikiPageResource</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.wiki.service.model.WikiPageResource
58   * @see com.liferay.portlet.wiki.service.model.WikiPageResourceModel
59   * @see com.liferay.portlet.wiki.service.model.impl.WikiPageResourceImpl
60   *
61   */
62  public class WikiPageResourceModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "WikiPageResource";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "resourcePrimKey", new Integer(Types.BIGINT) },
66              
67  
68              { "nodeId", new Integer(Types.BIGINT) },
69              
70  
71              { "title", new Integer(Types.VARCHAR) }
72          };
73      public static final String TABLE_SQL_CREATE = "create table WikiPageResource (resourcePrimKey LONG not null primary key,nodeId LONG,title VARCHAR(75) null)";
74      public static final String TABLE_SQL_DROP = "drop table WikiPageResource";
75      public static final String DATA_SOURCE = "liferayDataSource";
76      public static final String SESSION_FACTORY = "liferaySessionFactory";
77      public static final String TX_MANAGER = "liferayTransactionManager";
78      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portlet.wiki.model.WikiPageResource"),
80              true);
81  
82      public static WikiPageResource toModel(WikiPageResourceSoap soapModel) {
83          WikiPageResource model = new WikiPageResourceImpl();
84  
85          model.setResourcePrimKey(soapModel.getResourcePrimKey());
86          model.setNodeId(soapModel.getNodeId());
87          model.setTitle(soapModel.getTitle());
88  
89          return model;
90      }
91  
92      public static List<WikiPageResource> toModels(
93          WikiPageResourceSoap[] soapModels) {
94          List<WikiPageResource> models = new ArrayList<WikiPageResource>(soapModels.length);
95  
96          for (WikiPageResourceSoap soapModel : soapModels) {
97              models.add(toModel(soapModel));
98          }
99  
100         return models;
101     }
102 
103     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
104                 "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPageResource"));
105 
106     public WikiPageResourceModelImpl() {
107     }
108 
109     public long getPrimaryKey() {
110         return _resourcePrimKey;
111     }
112 
113     public void setPrimaryKey(long pk) {
114         setResourcePrimKey(pk);
115     }
116 
117     public Serializable getPrimaryKeyObj() {
118         return new Long(_resourcePrimKey);
119     }
120 
121     public long getResourcePrimKey() {
122         return _resourcePrimKey;
123     }
124 
125     public void setResourcePrimKey(long resourcePrimKey) {
126         if (resourcePrimKey != _resourcePrimKey) {
127             _resourcePrimKey = resourcePrimKey;
128         }
129     }
130 
131     public long getNodeId() {
132         return _nodeId;
133     }
134 
135     public void setNodeId(long nodeId) {
136         if (nodeId != _nodeId) {
137             _nodeId = nodeId;
138         }
139     }
140 
141     public String getTitle() {
142         return GetterUtil.getString(_title);
143     }
144 
145     public void setTitle(String title) {
146         if (((title == null) && (_title != null)) ||
147                 ((title != null) && (_title == null)) ||
148                 ((title != null) && (_title != null) && !title.equals(_title))) {
149             _title = title;
150         }
151     }
152 
153     public WikiPageResource toEscapedModel() {
154         if (isEscapedModel()) {
155             return (WikiPageResource)this;
156         }
157         else {
158             WikiPageResource model = new WikiPageResourceImpl();
159 
160             model.setEscapedModel(true);
161 
162             model.setResourcePrimKey(getResourcePrimKey());
163             model.setNodeId(getNodeId());
164             model.setTitle(HtmlUtil.escape(getTitle()));
165 
166             model = (WikiPageResource)Proxy.newProxyInstance(WikiPageResource.class.getClassLoader(),
167                     new Class[] { WikiPageResource.class },
168                     new ReadOnlyBeanHandler(model));
169 
170             return model;
171         }
172     }
173 
174     public Object clone() {
175         WikiPageResourceImpl clone = new WikiPageResourceImpl();
176 
177         clone.setResourcePrimKey(getResourcePrimKey());
178         clone.setNodeId(getNodeId());
179         clone.setTitle(getTitle());
180 
181         return clone;
182     }
183 
184     public int compareTo(Object obj) {
185         if (obj == null) {
186             return -1;
187         }
188 
189         WikiPageResourceImpl wikiPageResource = (WikiPageResourceImpl)obj;
190 
191         long pk = wikiPageResource.getPrimaryKey();
192 
193         if (getPrimaryKey() < pk) {
194             return -1;
195         }
196         else if (getPrimaryKey() > pk) {
197             return 1;
198         }
199         else {
200             return 0;
201         }
202     }
203 
204     public boolean equals(Object obj) {
205         if (obj == null) {
206             return false;
207         }
208 
209         WikiPageResourceImpl wikiPageResource = null;
210 
211         try {
212             wikiPageResource = (WikiPageResourceImpl)obj;
213         }
214         catch (ClassCastException cce) {
215             return false;
216         }
217 
218         long pk = wikiPageResource.getPrimaryKey();
219 
220         if (getPrimaryKey() == pk) {
221             return true;
222         }
223         else {
224             return false;
225         }
226     }
227 
228     public int hashCode() {
229         return (int)getPrimaryKey();
230     }
231 
232     private long _resourcePrimKey;
233     private long _nodeId;
234     private String _title;
235 }