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