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.model.WikiPageResource
58   * @see com.liferay.portlet.wiki.model.WikiPageResourceModel
59   * @see com.liferay.portlet.wiki.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.setNew(isNew());
161             model.setEscapedModel(true);
162 
163             model.setResourcePrimKey(getResourcePrimKey());
164             model.setNodeId(getNodeId());
165             model.setTitle(HtmlUtil.escape(getTitle()));
166 
167             model = (WikiPageResource)Proxy.newProxyInstance(WikiPageResource.class.getClassLoader(),
168                     new Class[] { WikiPageResource.class },
169                     new ReadOnlyBeanHandler(model));
170 
171             return model;
172         }
173     }
174 
175     public Object clone() {
176         WikiPageResourceImpl clone = new WikiPageResourceImpl();
177 
178         clone.setResourcePrimKey(getResourcePrimKey());
179         clone.setNodeId(getNodeId());
180         clone.setTitle(getTitle());
181 
182         return clone;
183     }
184 
185     public int compareTo(Object obj) {
186         if (obj == null) {
187             return -1;
188         }
189 
190         WikiPageResourceImpl wikiPageResource = (WikiPageResourceImpl)obj;
191 
192         long pk = wikiPageResource.getPrimaryKey();
193 
194         if (getPrimaryKey() < pk) {
195             return -1;
196         }
197         else if (getPrimaryKey() > pk) {
198             return 1;
199         }
200         else {
201             return 0;
202         }
203     }
204 
205     public boolean equals(Object obj) {
206         if (obj == null) {
207             return false;
208         }
209 
210         WikiPageResourceImpl wikiPageResource = null;
211 
212         try {
213             wikiPageResource = (WikiPageResourceImpl)obj;
214         }
215         catch (ClassCastException cce) {
216             return false;
217         }
218 
219         long pk = wikiPageResource.getPrimaryKey();
220 
221         if (getPrimaryKey() == pk) {
222             return true;
223         }
224         else {
225             return false;
226         }
227     }
228 
229     public int hashCode() {
230         return (int)getPrimaryKey();
231     }
232 
233     private long _resourcePrimKey;
234     private long _nodeId;
235     private String _title;
236 }