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