1
22
23 package com.liferay.portlet.expando.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.kernel.util.StringPool;
29 import com.liferay.portal.model.impl.BaseModelImpl;
30 import com.liferay.portal.util.PortalUtil;
31
32 import com.liferay.portlet.expando.model.ExpandoValue;
33 import com.liferay.portlet.expando.model.ExpandoValueSoap;
34
35 import java.io.Serializable;
36
37 import java.lang.reflect.Proxy;
38
39 import java.sql.Types;
40
41 import java.util.ArrayList;
42 import java.util.List;
43
44
64 public class ExpandoValueModelImpl extends BaseModelImpl {
65 public static final String TABLE_NAME = "ExpandoValue";
66 public static final Object[][] TABLE_COLUMNS = {
67 { "valueId", new Integer(Types.BIGINT) },
68
69
70 { "tableId", new Integer(Types.BIGINT) },
71
72
73 { "columnId", new Integer(Types.BIGINT) },
74
75
76 { "rowId_", new Integer(Types.BIGINT) },
77
78
79 { "classNameId", new Integer(Types.BIGINT) },
80
81
82 { "classPK", new Integer(Types.BIGINT) },
83
84
85 { "data_", new Integer(Types.VARCHAR) }
86 };
87 public static final String TABLE_SQL_CREATE = "create table ExpandoValue (valueId LONG not null primary key,tableId LONG,columnId LONG,rowId_ LONG,classNameId LONG,classPK LONG,data_ STRING null)";
88 public static final String TABLE_SQL_DROP = "drop table ExpandoValue";
89 public static final String DATA_SOURCE = "liferayDataSource";
90 public static final String SESSION_FACTORY = "liferaySessionFactory";
91 public static final String TX_MANAGER = "liferayTransactionManager";
92 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93 "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
94 true);
95
96 public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
97 ExpandoValue model = new ExpandoValueImpl();
98
99 model.setValueId(soapModel.getValueId());
100 model.setTableId(soapModel.getTableId());
101 model.setColumnId(soapModel.getColumnId());
102 model.setRowId(soapModel.getRowId());
103 model.setClassNameId(soapModel.getClassNameId());
104 model.setClassPK(soapModel.getClassPK());
105 model.setData(soapModel.getData());
106
107 return model;
108 }
109
110 public static List<ExpandoValue> toModels(ExpandoValueSoap[] soapModels) {
111 List<ExpandoValue> models = new ArrayList<ExpandoValue>(soapModels.length);
112
113 for (ExpandoValueSoap soapModel : soapModels) {
114 models.add(toModel(soapModel));
115 }
116
117 return models;
118 }
119
120 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
121 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoValue"));
122
123 public ExpandoValueModelImpl() {
124 }
125
126 public long getPrimaryKey() {
127 return _valueId;
128 }
129
130 public void setPrimaryKey(long pk) {
131 setValueId(pk);
132 }
133
134 public Serializable getPrimaryKeyObj() {
135 return new Long(_valueId);
136 }
137
138 public long getValueId() {
139 return _valueId;
140 }
141
142 public void setValueId(long valueId) {
143 if (valueId != _valueId) {
144 _valueId = valueId;
145 }
146 }
147
148 public long getTableId() {
149 return _tableId;
150 }
151
152 public void setTableId(long tableId) {
153 if (tableId != _tableId) {
154 _tableId = tableId;
155 }
156 }
157
158 public long getColumnId() {
159 return _columnId;
160 }
161
162 public void setColumnId(long columnId) {
163 if (columnId != _columnId) {
164 _columnId = columnId;
165 }
166 }
167
168 public long getRowId() {
169 return _rowId;
170 }
171
172 public void setRowId(long rowId) {
173 if (rowId != _rowId) {
174 _rowId = rowId;
175 }
176 }
177
178 public String getClassName() {
179 if (getClassNameId() <= 0) {
180 return StringPool.BLANK;
181 }
182
183 return PortalUtil.getClassName(getClassNameId());
184 }
185
186 public long getClassNameId() {
187 return _classNameId;
188 }
189
190 public void setClassNameId(long classNameId) {
191 if (classNameId != _classNameId) {
192 _classNameId = classNameId;
193 }
194 }
195
196 public long getClassPK() {
197 return _classPK;
198 }
199
200 public void setClassPK(long classPK) {
201 if (classPK != _classPK) {
202 _classPK = classPK;
203 }
204 }
205
206 public String getData() {
207 return GetterUtil.getString(_data);
208 }
209
210 public void setData(String data) {
211 if (((data == null) && (_data != null)) ||
212 ((data != null) && (_data == null)) ||
213 ((data != null) && (_data != null) && !data.equals(_data))) {
214 _data = data;
215 }
216 }
217
218 public ExpandoValue toEscapedModel() {
219 if (isEscapedModel()) {
220 return (ExpandoValue)this;
221 }
222 else {
223 ExpandoValue model = new ExpandoValueImpl();
224
225 model.setNew(isNew());
226 model.setEscapedModel(true);
227
228 model.setValueId(getValueId());
229 model.setTableId(getTableId());
230 model.setColumnId(getColumnId());
231 model.setRowId(getRowId());
232 model.setClassNameId(getClassNameId());
233 model.setClassPK(getClassPK());
234 model.setData(HtmlUtil.escape(getData()));
235
236 model = (ExpandoValue)Proxy.newProxyInstance(ExpandoValue.class.getClassLoader(),
237 new Class[] { ExpandoValue.class },
238 new ReadOnlyBeanHandler(model));
239
240 return model;
241 }
242 }
243
244 public Object clone() {
245 ExpandoValueImpl clone = new ExpandoValueImpl();
246
247 clone.setValueId(getValueId());
248 clone.setTableId(getTableId());
249 clone.setColumnId(getColumnId());
250 clone.setRowId(getRowId());
251 clone.setClassNameId(getClassNameId());
252 clone.setClassPK(getClassPK());
253 clone.setData(getData());
254
255 return clone;
256 }
257
258 public int compareTo(Object obj) {
259 if (obj == null) {
260 return -1;
261 }
262
263 ExpandoValueImpl expandoValue = (ExpandoValueImpl)obj;
264
265 int value = 0;
266
267 if (getTableId() < expandoValue.getTableId()) {
268 value = -1;
269 }
270 else if (getTableId() > expandoValue.getTableId()) {
271 value = 1;
272 }
273 else {
274 value = 0;
275 }
276
277 if (value != 0) {
278 return value;
279 }
280
281 if (getRowId() < expandoValue.getRowId()) {
282 value = -1;
283 }
284 else if (getRowId() > expandoValue.getRowId()) {
285 value = 1;
286 }
287 else {
288 value = 0;
289 }
290
291 if (value != 0) {
292 return value;
293 }
294
295 if (getColumnId() < expandoValue.getColumnId()) {
296 value = -1;
297 }
298 else if (getColumnId() > expandoValue.getColumnId()) {
299 value = 1;
300 }
301 else {
302 value = 0;
303 }
304
305 if (value != 0) {
306 return value;
307 }
308
309 return 0;
310 }
311
312 public boolean equals(Object obj) {
313 if (obj == null) {
314 return false;
315 }
316
317 ExpandoValueImpl expandoValue = null;
318
319 try {
320 expandoValue = (ExpandoValueImpl)obj;
321 }
322 catch (ClassCastException cce) {
323 return false;
324 }
325
326 long pk = expandoValue.getPrimaryKey();
327
328 if (getPrimaryKey() == pk) {
329 return true;
330 }
331 else {
332 return false;
333 }
334 }
335
336 public int hashCode() {
337 return (int)getPrimaryKey();
338 }
339
340 private long _valueId;
341 private long _tableId;
342 private long _columnId;
343 private long _rowId;
344 private long _classNameId;
345 private long _classPK;
346 private String _data;
347 }