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