1
19
20 package com.liferay.portal.model.impl;
21
22 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23 import com.liferay.portal.kernel.util.GetterUtil;
24 import com.liferay.portal.kernel.util.HtmlUtil;
25 import com.liferay.portal.model.PortletPreferences;
26 import com.liferay.portal.model.PortletPreferencesSoap;
27
28 import java.io.Serializable;
29
30 import java.lang.reflect.Proxy;
31
32 import java.sql.Types;
33
34 import java.util.ArrayList;
35 import java.util.List;
36
37
57 public class PortletPreferencesModelImpl extends BaseModelImpl {
58 public static final String TABLE_NAME = "PortletPreferences";
59 public static final Object[][] TABLE_COLUMNS = {
60 { "portletPreferencesId", new Integer(Types.BIGINT) },
61
62
63 { "ownerId", new Integer(Types.BIGINT) },
64
65
66 { "ownerType", new Integer(Types.INTEGER) },
67
68
69 { "plid", new Integer(Types.BIGINT) },
70
71
72 { "portletId", new Integer(Types.VARCHAR) },
73
74
75 { "preferences", new Integer(Types.CLOB) }
76 };
77 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)";
78 public static final String TABLE_SQL_DROP = "drop table PortletPreferences";
79 public static final String DATA_SOURCE = "liferayDataSource";
80 public static final String SESSION_FACTORY = "liferaySessionFactory";
81 public static final String TX_MANAGER = "liferayTransactionManager";
82 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83 "value.object.finder.cache.enabled.com.liferay.portal.model.PortletPreferences"),
84 true);
85
86 public static PortletPreferences toModel(PortletPreferencesSoap soapModel) {
87 PortletPreferences model = new PortletPreferencesImpl();
88
89 model.setPortletPreferencesId(soapModel.getPortletPreferencesId());
90 model.setOwnerId(soapModel.getOwnerId());
91 model.setOwnerType(soapModel.getOwnerType());
92 model.setPlid(soapModel.getPlid());
93 model.setPortletId(soapModel.getPortletId());
94 model.setPreferences(soapModel.getPreferences());
95
96 return model;
97 }
98
99 public static List<PortletPreferences> toModels(
100 PortletPreferencesSoap[] soapModels) {
101 List<PortletPreferences> models = new ArrayList<PortletPreferences>(soapModels.length);
102
103 for (PortletPreferencesSoap soapModel : soapModels) {
104 models.add(toModel(soapModel));
105 }
106
107 return models;
108 }
109
110 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111 "lock.expiration.time.com.liferay.portal.model.PortletPreferences"));
112
113 public PortletPreferencesModelImpl() {
114 }
115
116 public long getPrimaryKey() {
117 return _portletPreferencesId;
118 }
119
120 public void setPrimaryKey(long pk) {
121 setPortletPreferencesId(pk);
122 }
123
124 public Serializable getPrimaryKeyObj() {
125 return new Long(_portletPreferencesId);
126 }
127
128 public long getPortletPreferencesId() {
129 return _portletPreferencesId;
130 }
131
132 public void setPortletPreferencesId(long portletPreferencesId) {
133 if (portletPreferencesId != _portletPreferencesId) {
134 _portletPreferencesId = portletPreferencesId;
135 }
136 }
137
138 public long getOwnerId() {
139 return _ownerId;
140 }
141
142 public void setOwnerId(long ownerId) {
143 if (ownerId != _ownerId) {
144 _ownerId = ownerId;
145 }
146 }
147
148 public int getOwnerType() {
149 return _ownerType;
150 }
151
152 public void setOwnerType(int ownerType) {
153 if (ownerType != _ownerType) {
154 _ownerType = ownerType;
155 }
156 }
157
158 public long getPlid() {
159 return _plid;
160 }
161
162 public void setPlid(long plid) {
163 if (plid != _plid) {
164 _plid = plid;
165 }
166 }
167
168 public String getPortletId() {
169 return GetterUtil.getString(_portletId);
170 }
171
172 public void setPortletId(String portletId) {
173 if (((portletId == null) && (_portletId != null)) ||
174 ((portletId != null) && (_portletId == null)) ||
175 ((portletId != null) && (_portletId != null) &&
176 !portletId.equals(_portletId))) {
177 _portletId = portletId;
178 }
179 }
180
181 public String getPreferences() {
182 return GetterUtil.getString(_preferences);
183 }
184
185 public void setPreferences(String preferences) {
186 if (((preferences == null) && (_preferences != null)) ||
187 ((preferences != null) && (_preferences == null)) ||
188 ((preferences != null) && (_preferences != null) &&
189 !preferences.equals(_preferences))) {
190 _preferences = preferences;
191 }
192 }
193
194 public PortletPreferences toEscapedModel() {
195 if (isEscapedModel()) {
196 return (PortletPreferences)this;
197 }
198 else {
199 PortletPreferences model = new PortletPreferencesImpl();
200
201 model.setNew(isNew());
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 }