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.portal.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="PortletPreferencesModelImpl.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>PortletPreferences</code> table
45   * in the database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portal.service.model.PortletPreferences
51   * @see com.liferay.portal.service.model.PortletPreferencesModel
52   * @see com.liferay.portal.service.model.impl.PortletPreferencesImpl
53   *
54   */
55  public class PortletPreferencesModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "PortletPreferences";
57      public static Object[][] TABLE_COLUMNS = {
58              { "portletPreferencesId", new Integer(Types.BIGINT) },
59              { "ownerId", new Integer(Types.BIGINT) },
60              { "ownerType", new Integer(Types.INTEGER) },
61              { "plid", new Integer(Types.BIGINT) },
62              { "portletId", new Integer(Types.VARCHAR) },
63              { "preferences", new Integer(Types.CLOB) }
64          };
65      public static String TABLE_SQL_CREATE = "create table PortletPreferences (portletPreferencesId LONG not null primary key,ownerId LONG,ownerType INTEGER,plid LONG,portletId VARCHAR(200) null,preferences TEXT null)";
66      public static String TABLE_SQL_DROP = "drop table PortletPreferences";
67      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
68                  "xss.allow.com.liferay.portal.model.PortletPreferences"),
69              XSS_ALLOW);
70      public static boolean XSS_ALLOW_PORTLETID = GetterUtil.getBoolean(PropsUtil.get(
71                  "xss.allow.com.liferay.portal.model.PortletPreferences.portletId"),
72              XSS_ALLOW_BY_MODEL);
73      public static boolean XSS_ALLOW_PREFERENCES = GetterUtil.getBoolean(PropsUtil.get(
74                  "xss.allow.com.liferay.portal.model.PortletPreferences.preferences"),
75              XSS_ALLOW_BY_MODEL);
76      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
77                  "lock.expiration.time.com.liferay.portal.model.PortletPreferencesModel"));
78  
79      public PortletPreferencesModelImpl() {
80      }
81  
82      public long getPrimaryKey() {
83          return _portletPreferencesId;
84      }
85  
86      public void setPrimaryKey(long pk) {
87          setPortletPreferencesId(pk);
88      }
89  
90      public Serializable getPrimaryKeyObj() {
91          return new Long(_portletPreferencesId);
92      }
93  
94      public long getPortletPreferencesId() {
95          return _portletPreferencesId;
96      }
97  
98      public void setPortletPreferencesId(long portletPreferencesId) {
99          if (portletPreferencesId != _portletPreferencesId) {
100             _portletPreferencesId = portletPreferencesId;
101         }
102     }
103 
104     public long getOwnerId() {
105         return _ownerId;
106     }
107 
108     public void setOwnerId(long ownerId) {
109         if (ownerId != _ownerId) {
110             _ownerId = ownerId;
111         }
112     }
113 
114     public int getOwnerType() {
115         return _ownerType;
116     }
117 
118     public void setOwnerType(int ownerType) {
119         if (ownerType != _ownerType) {
120             _ownerType = ownerType;
121         }
122     }
123 
124     public long getPlid() {
125         return _plid;
126     }
127 
128     public void setPlid(long plid) {
129         if (plid != _plid) {
130             _plid = plid;
131         }
132     }
133 
134     public String getPortletId() {
135         return GetterUtil.getString(_portletId);
136     }
137 
138     public void setPortletId(String portletId) {
139         if (((portletId == null) && (_portletId != null)) ||
140                 ((portletId != null) && (_portletId == null)) ||
141                 ((portletId != null) && (_portletId != null) &&
142                 !portletId.equals(_portletId))) {
143             if (!XSS_ALLOW_PORTLETID) {
144                 portletId = XSSUtil.strip(portletId);
145             }
146 
147             _portletId = portletId;
148         }
149     }
150 
151     public String getPreferences() {
152         return GetterUtil.getString(_preferences);
153     }
154 
155     public void setPreferences(String preferences) {
156         if (((preferences == null) && (_preferences != null)) ||
157                 ((preferences != null) && (_preferences == null)) ||
158                 ((preferences != null) && (_preferences != null) &&
159                 !preferences.equals(_preferences))) {
160             if (!XSS_ALLOW_PREFERENCES) {
161                 preferences = XSSUtil.strip(preferences);
162             }
163 
164             _preferences = preferences;
165         }
166     }
167 
168     public Object clone() {
169         PortletPreferencesImpl clone = new PortletPreferencesImpl();
170         clone.setPortletPreferencesId(getPortletPreferencesId());
171         clone.setOwnerId(getOwnerId());
172         clone.setOwnerType(getOwnerType());
173         clone.setPlid(getPlid());
174         clone.setPortletId(getPortletId());
175         clone.setPreferences(getPreferences());
176 
177         return clone;
178     }
179 
180     public int compareTo(Object obj) {
181         if (obj == null) {
182             return -1;
183         }
184 
185         PortletPreferencesImpl portletPreferences = (PortletPreferencesImpl)obj;
186         long pk = portletPreferences.getPrimaryKey();
187 
188         if (getPrimaryKey() < pk) {
189             return -1;
190         }
191         else if (getPrimaryKey() > pk) {
192             return 1;
193         }
194         else {
195             return 0;
196         }
197     }
198 
199     public boolean equals(Object obj) {
200         if (obj == null) {
201             return false;
202         }
203 
204         PortletPreferencesImpl portletPreferences = null;
205 
206         try {
207             portletPreferences = (PortletPreferencesImpl)obj;
208         }
209         catch (ClassCastException cce) {
210             return false;
211         }
212 
213         long pk = portletPreferences.getPrimaryKey();
214 
215         if (getPrimaryKey() == pk) {
216             return true;
217         }
218         else {
219             return false;
220         }
221     }
222 
223     public int hashCode() {
224         return (int)getPrimaryKey();
225     }
226 
227     private long _portletPreferencesId;
228     private long _ownerId;
229     private int _ownerType;
230     private long _plid;
231     private String _portletId;
232     private String _preferences;
233 }