1
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 import com.liferay.portal.util.PropsUtil;
31
32 import java.io.Serializable;
33
34 import java.lang.reflect.Proxy;
35
36 import java.sql.Types;
37
38 import java.util.ArrayList;
39 import java.util.List;
40
41
61 public class PortletPreferencesModelImpl extends BaseModelImpl {
62 public static final String TABLE_NAME = "PortletPreferences";
63 public static final Object[][] TABLE_COLUMNS = {
64 { "portletPreferencesId", new Integer(Types.BIGINT) },
65
66
67 { "ownerId", new Integer(Types.BIGINT) },
68
69
70 { "ownerType", new Integer(Types.INTEGER) },
71
72
73 { "plid", new Integer(Types.BIGINT) },
74
75
76 { "portletId", new Integer(Types.VARCHAR) },
77
78
79 { "preferences", new Integer(Types.CLOB) }
80 };
81 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)";
82 public static final String TABLE_SQL_DROP = "drop table PortletPreferences";
83 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
84 "value.object.finder.cache.enabled.com.liferay.portal.model.PortletPreferences"),
85 true);
86
87 public static PortletPreferences toModel(PortletPreferencesSoap soapModel) {
88 PortletPreferences model = new PortletPreferencesImpl();
89
90 model.setPortletPreferencesId(soapModel.getPortletPreferencesId());
91 model.setOwnerId(soapModel.getOwnerId());
92 model.setOwnerType(soapModel.getOwnerType());
93 model.setPlid(soapModel.getPlid());
94 model.setPortletId(soapModel.getPortletId());
95 model.setPreferences(soapModel.getPreferences());
96
97 return model;
98 }
99
100 public static List<PortletPreferences> toModels(
101 PortletPreferencesSoap[] soapModels) {
102 List<PortletPreferences> models = new ArrayList<PortletPreferences>(soapModels.length);
103
104 for (PortletPreferencesSoap soapModel : soapModels) {
105 models.add(toModel(soapModel));
106 }
107
108 return models;
109 }
110
111 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
112 "lock.expiration.time.com.liferay.portal.model.PortletPreferences"));
113
114 public PortletPreferencesModelImpl() {
115 }
116
117 public long getPrimaryKey() {
118 return _portletPreferencesId;
119 }
120
121 public void setPrimaryKey(long pk) {
122 setPortletPreferencesId(pk);
123 }
124
125 public Serializable getPrimaryKeyObj() {
126 return new Long(_portletPreferencesId);
127 }
128
129 public long getPortletPreferencesId() {
130 return _portletPreferencesId;
131 }
132
133 public void setPortletPreferencesId(long portletPreferencesId) {
134 if (portletPreferencesId != _portletPreferencesId) {
135 _portletPreferencesId = portletPreferencesId;
136 }
137 }
138
139 public long getOwnerId() {
140 return _ownerId;
141 }
142
143 public void setOwnerId(long ownerId) {
144 if (ownerId != _ownerId) {
145 _ownerId = ownerId;
146 }
147 }
148
149 public int getOwnerType() {
150 return _ownerType;
151 }
152
153 public void setOwnerType(int ownerType) {
154 if (ownerType != _ownerType) {
155 _ownerType = ownerType;
156 }
157 }
158
159 public long getPlid() {
160 return _plid;
161 }
162
163 public void setPlid(long plid) {
164 if (plid != _plid) {
165 _plid = plid;
166 }
167 }
168
169 public String getPortletId() {
170 return GetterUtil.getString(_portletId);
171 }
172
173 public void setPortletId(String portletId) {
174 if (((portletId == null) && (_portletId != null)) ||
175 ((portletId != null) && (_portletId == null)) ||
176 ((portletId != null) && (_portletId != null) &&
177 !portletId.equals(_portletId))) {
178 _portletId = portletId;
179 }
180 }
181
182 public String getPreferences() {
183 return GetterUtil.getString(_preferences);
184 }
185
186 public void setPreferences(String preferences) {
187 if (((preferences == null) && (_preferences != null)) ||
188 ((preferences != null) && (_preferences == null)) ||
189 ((preferences != null) && (_preferences != null) &&
190 !preferences.equals(_preferences))) {
191 _preferences = preferences;
192 }
193 }
194
195 public PortletPreferences toEscapedModel() {
196 if (isEscapedModel()) {
197 return (PortletPreferences)this;
198 }
199 else {
200 PortletPreferences model = new PortletPreferencesImpl();
201
202 model.setEscapedModel(true);
203
204 model.setPortletPreferencesId(getPortletPreferencesId());
205 model.setOwnerId(getOwnerId());
206 model.setOwnerType(getOwnerType());
207 model.setPlid(getPlid());
208 model.setPortletId(HtmlUtil.escape(getPortletId()));
209 model.setPreferences(HtmlUtil.escape(getPreferences()));
210
211 model = (PortletPreferences)Proxy.newProxyInstance(PortletPreferences.class.getClassLoader(),
212 new Class[] { PortletPreferences.class },
213 new ReadOnlyBeanHandler(model));
214
215 return model;
216 }
217 }
218
219 public Object clone() {
220 PortletPreferencesImpl clone = new PortletPreferencesImpl();
221
222 clone.setPortletPreferencesId(getPortletPreferencesId());
223 clone.setOwnerId(getOwnerId());
224 clone.setOwnerType(getOwnerType());
225 clone.setPlid(getPlid());
226 clone.setPortletId(getPortletId());
227 clone.setPreferences(getPreferences());
228
229 return clone;
230 }
231
232 public int compareTo(Object obj) {
233 if (obj == null) {
234 return -1;
235 }
236
237 PortletPreferencesImpl portletPreferences = (PortletPreferencesImpl)obj;
238
239 long pk = portletPreferences.getPrimaryKey();
240
241 if (getPrimaryKey() < pk) {
242 return -1;
243 }
244 else if (getPrimaryKey() > pk) {
245 return 1;
246 }
247 else {
248 return 0;
249 }
250 }
251
252 public boolean equals(Object obj) {
253 if (obj == null) {
254 return false;
255 }
256
257 PortletPreferencesImpl portletPreferences = null;
258
259 try {
260 portletPreferences = (PortletPreferencesImpl)obj;
261 }
262 catch (ClassCastException cce) {
263 return false;
264 }
265
266 long pk = portletPreferences.getPrimaryKey();
267
268 if (getPrimaryKey() == pk) {
269 return true;
270 }
271 else {
272 return false;
273 }
274 }
275
276 public int hashCode() {
277 return (int)getPrimaryKey();
278 }
279
280 private long _portletPreferencesId;
281 private long _ownerId;
282 private int _ownerType;
283 private long _plid;
284 private String _portletId;
285 private String _preferences;
286 }