1   /**
2    * Copyright (c) 2000-2007 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  /**
36   * <a href="WikiPageResourceModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>WikiPageResource</code> table
45   * in the database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portlet.wiki.service.model.WikiPageResource
51   * @see com.liferay.portlet.wiki.service.model.WikiPageResourceModel
52   * @see com.liferay.portlet.wiki.service.model.impl.WikiPageResourceImpl
53   *
54   */
55  public class WikiPageResourceModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "WikiPageResource";
57      public static Object[][] TABLE_COLUMNS = {
58              { "resourcePrimKey", new Integer(Types.BIGINT) },
59              { "nodeId", new Integer(Types.BIGINT) },
60              { "title", new Integer(Types.VARCHAR) }
61          };
62      public static String TABLE_SQL_CREATE = "create table WikiPageResource (resourcePrimKey LONG not null primary key,nodeId LONG,title VARCHAR(75) null)";
63      public static String TABLE_SQL_DROP = "drop table WikiPageResource";
64      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
65                  "xss.allow.com.liferay.portlet.wiki.model.WikiPageResource"),
66              XSS_ALLOW);
67      public static boolean XSS_ALLOW_TITLE = GetterUtil.getBoolean(PropsUtil.get(
68                  "xss.allow.com.liferay.portlet.wiki.model.WikiPageResource.title"),
69              XSS_ALLOW_BY_MODEL);
70      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
71                  "lock.expiration.time.com.liferay.portlet.wiki.model.WikiPageResourceModel"));
72  
73      public WikiPageResourceModelImpl() {
74      }
75  
76      public long getPrimaryKey() {
77          return _resourcePrimKey;
78      }
79  
80      public void setPrimaryKey(long pk) {
81          setResourcePrimKey(pk);
82      }
83  
84      public Serializable getPrimaryKeyObj() {
85          return new Long(_resourcePrimKey);
86      }
87  
88      public long getResourcePrimKey() {
89          return _resourcePrimKey;
90      }
91  
92      public void setResourcePrimKey(long resourcePrimKey) {
93          if (resourcePrimKey != _resourcePrimKey) {
94              _resourcePrimKey = resourcePrimKey;
95          }
96      }
97  
98      public long getNodeId() {
99          return _nodeId;
100     }
101 
102     public void setNodeId(long nodeId) {
103         if (nodeId != _nodeId) {
104             _nodeId = nodeId;
105         }
106     }
107 
108     public String getTitle() {
109         return GetterUtil.getString(_title);
110     }
111 
112     public void setTitle(String title) {
113         if (((title == null) && (_title != null)) ||
114                 ((title != null) && (_title == null)) ||
115                 ((title != null) && (_title != null) && !title.equals(_title))) {
116             if (!XSS_ALLOW_TITLE) {
117                 title = XSSUtil.strip(title);
118             }
119 
120             _title = title;
121         }
122     }
123 
124     public Object clone() {
125         WikiPageResourceImpl clone = new WikiPageResourceImpl();
126         clone.setResourcePrimKey(getResourcePrimKey());
127         clone.setNodeId(getNodeId());
128         clone.setTitle(getTitle());
129 
130         return clone;
131     }
132 
133     public int compareTo(Object obj) {
134         if (obj == null) {
135             return -1;
136         }
137 
138         WikiPageResourceImpl wikiPageResource = (WikiPageResourceImpl)obj;
139         long pk = wikiPageResource.getPrimaryKey();
140 
141         if (getPrimaryKey() < pk) {
142             return -1;
143         }
144         else if (getPrimaryKey() > pk) {
145             return 1;
146         }
147         else {
148             return 0;
149         }
150     }
151 
152     public boolean equals(Object obj) {
153         if (obj == null) {
154             return false;
155         }
156 
157         WikiPageResourceImpl wikiPageResource = null;
158 
159         try {
160             wikiPageResource = (WikiPageResourceImpl)obj;
161         }
162         catch (ClassCastException cce) {
163             return false;
164         }
165 
166         long pk = wikiPageResource.getPrimaryKey();
167 
168         if (getPrimaryKey() == pk) {
169             return true;
170         }
171         else {
172             return false;
173         }
174     }
175 
176     public int hashCode() {
177         return (int)getPrimaryKey();
178     }
179 
180     private long _resourcePrimKey;
181     private long _nodeId;
182     private String _title;
183 }