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.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.PortletPreferences;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="PortletPreferencesModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>PortletPreferences</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.PortletPreferences
54   * @see com.liferay.portal.service.model.PortletPreferencesModel
55   * @see com.liferay.portal.service.model.impl.PortletPreferencesImpl
56   *
57   */
58  public class PortletPreferencesModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "PortletPreferences";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "portletPreferencesId", new Integer(Types.BIGINT) },
62              
63  
64              { "ownerId", new Integer(Types.BIGINT) },
65              
66  
67              { "ownerType", new Integer(Types.INTEGER) },
68              
69  
70              { "plid", new Integer(Types.BIGINT) },
71              
72  
73              { "portletId", new Integer(Types.VARCHAR) },
74              
75  
76              { "preferences", new Integer(Types.CLOB) }
77          };
78      public static final 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)";
79      public static final String TABLE_SQL_DROP = "drop table PortletPreferences";
80      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portal.model.PortletPreferences"),
82              true);
83      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
84                  "lock.expiration.time.com.liferay.portal.model.PortletPreferences"));
85  
86      public PortletPreferencesModelImpl() {
87      }
88  
89      public long getPrimaryKey() {
90          return _portletPreferencesId;
91      }
92  
93      public void setPrimaryKey(long pk) {
94          setPortletPreferencesId(pk);
95      }
96  
97      public Serializable getPrimaryKeyObj() {
98          return new Long(_portletPreferencesId);
99      }
100 
101     public long getPortletPreferencesId() {
102         return _portletPreferencesId;
103     }
104 
105     public void setPortletPreferencesId(long portletPreferencesId) {
106         if (portletPreferencesId != _portletPreferencesId) {
107             _portletPreferencesId = portletPreferencesId;
108         }
109     }
110 
111     public long getOwnerId() {
112         return _ownerId;
113     }
114 
115     public void setOwnerId(long ownerId) {
116         if (ownerId != _ownerId) {
117             _ownerId = ownerId;
118         }
119     }
120 
121     public int getOwnerType() {
122         return _ownerType;
123     }
124 
125     public void setOwnerType(int ownerType) {
126         if (ownerType != _ownerType) {
127             _ownerType = ownerType;
128         }
129     }
130 
131     public long getPlid() {
132         return _plid;
133     }
134 
135     public void setPlid(long plid) {
136         if (plid != _plid) {
137             _plid = plid;
138         }
139     }
140 
141     public String getPortletId() {
142         return GetterUtil.getString(_portletId);
143     }
144 
145     public void setPortletId(String portletId) {
146         if (((portletId == null) && (_portletId != null)) ||
147                 ((portletId != null) && (_portletId == null)) ||
148                 ((portletId != null) && (_portletId != null) &&
149                 !portletId.equals(_portletId))) {
150             _portletId = portletId;
151         }
152     }
153 
154     public String getPreferences() {
155         return GetterUtil.getString(_preferences);
156     }
157 
158     public void setPreferences(String preferences) {
159         if (((preferences == null) && (_preferences != null)) ||
160                 ((preferences != null) && (_preferences == null)) ||
161                 ((preferences != null) && (_preferences != null) &&
162                 !preferences.equals(_preferences))) {
163             _preferences = preferences;
164         }
165     }
166 
167     public PortletPreferences toEscapedModel() {
168         if (isEscapedModel()) {
169             return (PortletPreferences)this;
170         }
171         else {
172             PortletPreferences model = new PortletPreferencesImpl();
173 
174             model.setEscapedModel(true);
175 
176             model.setPortletPreferencesId(getPortletPreferencesId());
177             model.setOwnerId(getOwnerId());
178             model.setOwnerType(getOwnerType());
179             model.setPlid(getPlid());
180             model.setPortletId(Html.escape(getPortletId()));
181             model.setPreferences(Html.escape(getPreferences()));
182 
183             model = (PortletPreferences)Proxy.newProxyInstance(PortletPreferences.class.getClassLoader(),
184                     new Class[] { PortletPreferences.class },
185                     new ReadOnlyBeanHandler(model));
186 
187             return model;
188         }
189     }
190 
191     public Object clone() {
192         PortletPreferencesImpl clone = new PortletPreferencesImpl();
193 
194         clone.setPortletPreferencesId(getPortletPreferencesId());
195         clone.setOwnerId(getOwnerId());
196         clone.setOwnerType(getOwnerType());
197         clone.setPlid(getPlid());
198         clone.setPortletId(getPortletId());
199         clone.setPreferences(getPreferences());
200 
201         return clone;
202     }
203 
204     public int compareTo(Object obj) {
205         if (obj == null) {
206             return -1;
207         }
208 
209         PortletPreferencesImpl portletPreferences = (PortletPreferencesImpl)obj;
210 
211         long pk = portletPreferences.getPrimaryKey();
212 
213         if (getPrimaryKey() < pk) {
214             return -1;
215         }
216         else if (getPrimaryKey() > pk) {
217             return 1;
218         }
219         else {
220             return 0;
221         }
222     }
223 
224     public boolean equals(Object obj) {
225         if (obj == null) {
226             return false;
227         }
228 
229         PortletPreferencesImpl portletPreferences = null;
230 
231         try {
232             portletPreferences = (PortletPreferencesImpl)obj;
233         }
234         catch (ClassCastException cce) {
235             return false;
236         }
237 
238         long pk = portletPreferences.getPrimaryKey();
239 
240         if (getPrimaryKey() == pk) {
241             return true;
242         }
243         else {
244             return false;
245         }
246     }
247 
248     public int hashCode() {
249         return (int)getPrimaryKey();
250     }
251 
252     private long _portletPreferencesId;
253     private long _ownerId;
254     private int _ownerType;
255     private long _plid;
256     private String _portletId;
257     private String _preferences;
258 }