001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.model.impl;
022:
023: import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
024: import com.liferay.portal.kernel.util.GetterUtil;
025: import com.liferay.portal.model.PortletPreferences;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.util.Html;
029:
030: import java.io.Serializable;
031:
032: import java.lang.reflect.Proxy;
033:
034: import java.sql.Types;
035:
036: /**
037: * <a href="PortletPreferencesModelImpl.java.html"><b><i>View Source</i></b></a>
038: *
039: * <p>
040: * ServiceBuilder generated this class. Modifications in this class will be
041: * overwritten the next time is generated.
042: * </p>
043: *
044: * <p>
045: * This class is a model that represents the <code>PortletPreferences</code> table
046: * in the database.
047: * </p>
048: *
049: * @author Brian Wing Shun Chan
050: *
051: * @see com.liferay.portal.service.model.PortletPreferences
052: * @see com.liferay.portal.service.model.PortletPreferencesModel
053: * @see com.liferay.portal.service.model.impl.PortletPreferencesImpl
054: *
055: */
056: public class PortletPreferencesModelImpl extends BaseModelImpl {
057: public static final String TABLE_NAME = "PortletPreferences";
058: public static final Object[][] TABLE_COLUMNS = {
059: { "portletPreferencesId", new Integer(Types.BIGINT) },
060:
061: { "ownerId", new Integer(Types.BIGINT) },
062:
063: { "ownerType", new Integer(Types.INTEGER) },
064:
065: { "plid", new Integer(Types.BIGINT) },
066:
067: { "portletId", new Integer(Types.VARCHAR) },
068:
069: { "preferences", new Integer(Types.CLOB) } };
070: 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)";
071: public static final String TABLE_SQL_DROP = "drop table PortletPreferences";
072: public static final boolean CACHE_ENABLED = GetterUtil
073: .getBoolean(
074: PropsUtil
075: .get("value.object.finder.cache.enabled.com.liferay.portal.model.PortletPreferences"),
076: true);
077: public static final long LOCK_EXPIRATION_TIME = GetterUtil
078: .getLong(PropsUtil
079: .get("lock.expiration.time.com.liferay.portal.model.PortletPreferences"));
080:
081: public PortletPreferencesModelImpl() {
082: }
083:
084: public long getPrimaryKey() {
085: return _portletPreferencesId;
086: }
087:
088: public void setPrimaryKey(long pk) {
089: setPortletPreferencesId(pk);
090: }
091:
092: public Serializable getPrimaryKeyObj() {
093: return new Long(_portletPreferencesId);
094: }
095:
096: public long getPortletPreferencesId() {
097: return _portletPreferencesId;
098: }
099:
100: public void setPortletPreferencesId(long portletPreferencesId) {
101: if (portletPreferencesId != _portletPreferencesId) {
102: _portletPreferencesId = portletPreferencesId;
103: }
104: }
105:
106: public long getOwnerId() {
107: return _ownerId;
108: }
109:
110: public void setOwnerId(long ownerId) {
111: if (ownerId != _ownerId) {
112: _ownerId = ownerId;
113: }
114: }
115:
116: public int getOwnerType() {
117: return _ownerType;
118: }
119:
120: public void setOwnerType(int ownerType) {
121: if (ownerType != _ownerType) {
122: _ownerType = ownerType;
123: }
124: }
125:
126: public long getPlid() {
127: return _plid;
128: }
129:
130: public void setPlid(long plid) {
131: if (plid != _plid) {
132: _plid = plid;
133: }
134: }
135:
136: public String getPortletId() {
137: return GetterUtil.getString(_portletId);
138: }
139:
140: public void setPortletId(String portletId) {
141: if (((portletId == null) && (_portletId != null))
142: || ((portletId != null) && (_portletId == null))
143: || ((portletId != null) && (_portletId != null) && !portletId
144: .equals(_portletId))) {
145: _portletId = portletId;
146: }
147: }
148:
149: public String getPreferences() {
150: return GetterUtil.getString(_preferences);
151: }
152:
153: public void setPreferences(String preferences) {
154: if (((preferences == null) && (_preferences != null))
155: || ((preferences != null) && (_preferences == null))
156: || ((preferences != null) && (_preferences != null) && !preferences
157: .equals(_preferences))) {
158: _preferences = preferences;
159: }
160: }
161:
162: public PortletPreferences toEscapedModel() {
163: if (isEscapedModel()) {
164: return (PortletPreferences) this ;
165: } else {
166: PortletPreferences model = new PortletPreferencesImpl();
167:
168: model.setEscapedModel(true);
169:
170: model.setPortletPreferencesId(getPortletPreferencesId());
171: model.setOwnerId(getOwnerId());
172: model.setOwnerType(getOwnerType());
173: model.setPlid(getPlid());
174: model.setPortletId(Html.escape(getPortletId()));
175: model.setPreferences(Html.escape(getPreferences()));
176:
177: model = (PortletPreferences) Proxy.newProxyInstance(
178: PortletPreferences.class.getClassLoader(),
179: new Class[] { PortletPreferences.class },
180: new ReadOnlyBeanHandler(model));
181:
182: return model;
183: }
184: }
185:
186: public Object clone() {
187: PortletPreferencesImpl clone = new PortletPreferencesImpl();
188:
189: clone.setPortletPreferencesId(getPortletPreferencesId());
190: clone.setOwnerId(getOwnerId());
191: clone.setOwnerType(getOwnerType());
192: clone.setPlid(getPlid());
193: clone.setPortletId(getPortletId());
194: clone.setPreferences(getPreferences());
195:
196: return clone;
197: }
198:
199: public int compareTo(Object obj) {
200: if (obj == null) {
201: return -1;
202: }
203:
204: PortletPreferencesImpl portletPreferences = (PortletPreferencesImpl) obj;
205:
206: long pk = portletPreferences.getPrimaryKey();
207:
208: if (getPrimaryKey() < pk) {
209: return -1;
210: } else if (getPrimaryKey() > pk) {
211: return 1;
212: } else {
213: return 0;
214: }
215: }
216:
217: public boolean equals(Object obj) {
218: if (obj == null) {
219: return false;
220: }
221:
222: PortletPreferencesImpl portletPreferences = null;
223:
224: try {
225: portletPreferences = (PortletPreferencesImpl) obj;
226: } catch (ClassCastException cce) {
227: return false;
228: }
229:
230: long pk = portletPreferences.getPrimaryKey();
231:
232: if (getPrimaryKey() == pk) {
233: return true;
234: } else {
235: return false;
236: }
237: }
238:
239: public int hashCode() {
240: return (int) getPrimaryKey();
241: }
242:
243: private long _portletPreferencesId;
244: private long _ownerId;
245: private int _ownerType;
246: private long _plid;
247: private String _portletId;
248: private String _preferences;
249: }
|