1   /**
2    * Copyright (c) 2000-2009 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.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.PortletPreferences;
29  import com.liferay.portal.model.PortletPreferencesSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="PortletPreferencesModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>PortletPreferences</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portal.model.PortletPreferences
56   * @see com.liferay.portal.model.PortletPreferencesModel
57   * @see com.liferay.portal.model.impl.PortletPreferencesImpl
58   *
59   */
60  public class PortletPreferencesModelImpl extends BaseModelImpl<PortletPreferences> {
61      public static final String TABLE_NAME = "PortletPreferences";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "portletPreferencesId", new Integer(Types.BIGINT) },
64              
65  
66              { "ownerId", new Integer(Types.BIGINT) },
67              
68  
69              { "ownerType", new Integer(Types.INTEGER) },
70              
71  
72              { "plid", new Integer(Types.BIGINT) },
73              
74  
75              { "portletId", new Integer(Types.VARCHAR) },
76              
77  
78              { "preferences", new Integer(Types.CLOB) }
79          };
80      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)";
81      public static final String TABLE_SQL_DROP = "drop table PortletPreferences";
82      public static final String DATA_SOURCE = "liferayDataSource";
83      public static final String SESSION_FACTORY = "liferaySessionFactory";
84      public static final String TX_MANAGER = "liferayTransactionManager";
85      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.entity.cache.enabled.com.liferay.portal.model.PortletPreferences"),
87              true);
88      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
89                  "value.object.finder.cache.enabled.com.liferay.portal.model.PortletPreferences"),
90              true);
91  
92      public static PortletPreferences toModel(PortletPreferencesSoap soapModel) {
93          PortletPreferences model = new PortletPreferencesImpl();
94  
95          model.setPortletPreferencesId(soapModel.getPortletPreferencesId());
96          model.setOwnerId(soapModel.getOwnerId());
97          model.setOwnerType(soapModel.getOwnerType());
98          model.setPlid(soapModel.getPlid());
99          model.setPortletId(soapModel.getPortletId());
100         model.setPreferences(soapModel.getPreferences());
101 
102         return model;
103     }
104 
105     public static List<PortletPreferences> toModels(
106         PortletPreferencesSoap[] soapModels) {
107         List<PortletPreferences> models = new ArrayList<PortletPreferences>(soapModels.length);
108 
109         for (PortletPreferencesSoap soapModel : soapModels) {
110             models.add(toModel(soapModel));
111         }
112 
113         return models;
114     }
115 
116     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
117                 "lock.expiration.time.com.liferay.portal.model.PortletPreferences"));
118 
119     public PortletPreferencesModelImpl() {
120     }
121 
122     public long getPrimaryKey() {
123         return _portletPreferencesId;
124     }
125 
126     public void setPrimaryKey(long pk) {
127         setPortletPreferencesId(pk);
128     }
129 
130     public Serializable getPrimaryKeyObj() {
131         return new Long(_portletPreferencesId);
132     }
133 
134     public long getPortletPreferencesId() {
135         return _portletPreferencesId;
136     }
137 
138     public void setPortletPreferencesId(long portletPreferencesId) {
139         _portletPreferencesId = portletPreferencesId;
140     }
141 
142     public long getOwnerId() {
143         return _ownerId;
144     }
145 
146     public void setOwnerId(long ownerId) {
147         _ownerId = ownerId;
148 
149         if (!_setOriginalOwnerId) {
150             _setOriginalOwnerId = true;
151 
152             _originalOwnerId = ownerId;
153         }
154     }
155 
156     public long getOriginalOwnerId() {
157         return _originalOwnerId;
158     }
159 
160     public int getOwnerType() {
161         return _ownerType;
162     }
163 
164     public void setOwnerType(int ownerType) {
165         _ownerType = ownerType;
166 
167         if (!_setOriginalOwnerType) {
168             _setOriginalOwnerType = true;
169 
170             _originalOwnerType = ownerType;
171         }
172     }
173 
174     public int getOriginalOwnerType() {
175         return _originalOwnerType;
176     }
177 
178     public long getPlid() {
179         return _plid;
180     }
181 
182     public void setPlid(long plid) {
183         _plid = plid;
184 
185         if (!_setOriginalPlid) {
186             _setOriginalPlid = true;
187 
188             _originalPlid = plid;
189         }
190     }
191 
192     public long getOriginalPlid() {
193         return _originalPlid;
194     }
195 
196     public String getPortletId() {
197         return GetterUtil.getString(_portletId);
198     }
199 
200     public void setPortletId(String portletId) {
201         _portletId = portletId;
202 
203         if (_originalPortletId == null) {
204             _originalPortletId = portletId;
205         }
206     }
207 
208     public String getOriginalPortletId() {
209         return GetterUtil.getString(_originalPortletId);
210     }
211 
212     public String getPreferences() {
213         return GetterUtil.getString(_preferences);
214     }
215 
216     public void setPreferences(String preferences) {
217         _preferences = preferences;
218     }
219 
220     public PortletPreferences toEscapedModel() {
221         if (isEscapedModel()) {
222             return (PortletPreferences)this;
223         }
224         else {
225             PortletPreferences model = new PortletPreferencesImpl();
226 
227             model.setNew(isNew());
228             model.setEscapedModel(true);
229 
230             model.setPortletPreferencesId(getPortletPreferencesId());
231             model.setOwnerId(getOwnerId());
232             model.setOwnerType(getOwnerType());
233             model.setPlid(getPlid());
234             model.setPortletId(HtmlUtil.escape(getPortletId()));
235             model.setPreferences(HtmlUtil.escape(getPreferences()));
236 
237             model = (PortletPreferences)Proxy.newProxyInstance(PortletPreferences.class.getClassLoader(),
238                     new Class[] { PortletPreferences.class },
239                     new ReadOnlyBeanHandler(model));
240 
241             return model;
242         }
243     }
244 
245     public Object clone() {
246         PortletPreferencesImpl clone = new PortletPreferencesImpl();
247 
248         clone.setPortletPreferencesId(getPortletPreferencesId());
249         clone.setOwnerId(getOwnerId());
250         clone.setOwnerType(getOwnerType());
251         clone.setPlid(getPlid());
252         clone.setPortletId(getPortletId());
253         clone.setPreferences(getPreferences());
254 
255         return clone;
256     }
257 
258     public int compareTo(PortletPreferences portletPreferences) {
259         long pk = portletPreferences.getPrimaryKey();
260 
261         if (getPrimaryKey() < pk) {
262             return -1;
263         }
264         else if (getPrimaryKey() > pk) {
265             return 1;
266         }
267         else {
268             return 0;
269         }
270     }
271 
272     public boolean equals(Object obj) {
273         if (obj == null) {
274             return false;
275         }
276 
277         PortletPreferences portletPreferences = null;
278 
279         try {
280             portletPreferences = (PortletPreferences)obj;
281         }
282         catch (ClassCastException cce) {
283             return false;
284         }
285 
286         long pk = portletPreferences.getPrimaryKey();
287 
288         if (getPrimaryKey() == pk) {
289             return true;
290         }
291         else {
292             return false;
293         }
294     }
295 
296     public int hashCode() {
297         return (int)getPrimaryKey();
298     }
299 
300     public String toString() {
301         StringBuilder sb = new StringBuilder();
302 
303         sb.append("{portletPreferencesId=");
304         sb.append(getPortletPreferencesId());
305         sb.append(", ownerId=");
306         sb.append(getOwnerId());
307         sb.append(", ownerType=");
308         sb.append(getOwnerType());
309         sb.append(", plid=");
310         sb.append(getPlid());
311         sb.append(", portletId=");
312         sb.append(getPortletId());
313         sb.append(", preferences=");
314         sb.append(getPreferences());
315         sb.append("}");
316 
317         return sb.toString();
318     }
319 
320     public String toXmlString() {
321         StringBuilder sb = new StringBuilder();
322 
323         sb.append("<model><model-name>");
324         sb.append("com.liferay.portal.model.PortletPreferences");
325         sb.append("</model-name>");
326 
327         sb.append(
328             "<column><column-name>portletPreferencesId</column-name><column-value><![CDATA[");
329         sb.append(getPortletPreferencesId());
330         sb.append("]]></column-value></column>");
331         sb.append(
332             "<column><column-name>ownerId</column-name><column-value><![CDATA[");
333         sb.append(getOwnerId());
334         sb.append("]]></column-value></column>");
335         sb.append(
336             "<column><column-name>ownerType</column-name><column-value><![CDATA[");
337         sb.append(getOwnerType());
338         sb.append("]]></column-value></column>");
339         sb.append(
340             "<column><column-name>plid</column-name><column-value><![CDATA[");
341         sb.append(getPlid());
342         sb.append("]]></column-value></column>");
343         sb.append(
344             "<column><column-name>portletId</column-name><column-value><![CDATA[");
345         sb.append(getPortletId());
346         sb.append("]]></column-value></column>");
347         sb.append(
348             "<column><column-name>preferences</column-name><column-value><![CDATA[");
349         sb.append(getPreferences());
350         sb.append("]]></column-value></column>");
351 
352         sb.append("</model>");
353 
354         return sb.toString();
355     }
356 
357     private long _portletPreferencesId;
358     private long _ownerId;
359     private long _originalOwnerId;
360     private boolean _setOriginalOwnerId;
361     private int _ownerType;
362     private int _originalOwnerType;
363     private boolean _setOriginalOwnerType;
364     private long _plid;
365     private long _originalPlid;
366     private boolean _setOriginalPlid;
367     private String _portletId;
368     private String _originalPortletId;
369     private String _preferences;
370 }