1
19
20 package com.liferay.portlet.shopping.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.impl.BaseModelImpl;
26
27 import com.liferay.portlet.expando.model.ExpandoBridge;
28 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
29 import com.liferay.portlet.shopping.model.ShoppingCategory;
30 import com.liferay.portlet.shopping.model.ShoppingCategorySoap;
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.Date;
40 import java.util.List;
41
42
62 public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory> {
63 public static final String TABLE_NAME = "ShoppingCategory";
64 public static final Object[][] TABLE_COLUMNS = {
65 { "categoryId", new Integer(Types.BIGINT) },
66
67
68 { "groupId", new Integer(Types.BIGINT) },
69
70
71 { "companyId", new Integer(Types.BIGINT) },
72
73
74 { "userId", new Integer(Types.BIGINT) },
75
76
77 { "userName", new Integer(Types.VARCHAR) },
78
79
80 { "createDate", new Integer(Types.TIMESTAMP) },
81
82
83 { "modifiedDate", new Integer(Types.TIMESTAMP) },
84
85
86 { "parentCategoryId", new Integer(Types.BIGINT) },
87
88
89 { "name", new Integer(Types.VARCHAR) },
90
91
92 { "description", new Integer(Types.VARCHAR) }
93 };
94 public static final String TABLE_SQL_CREATE = "create table ShoppingCategory (categoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentCategoryId LONG,name VARCHAR(75) null,description STRING null)";
95 public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
96 public static final String DATA_SOURCE = "liferayDataSource";
97 public static final String SESSION_FACTORY = "liferaySessionFactory";
98 public static final String TX_MANAGER = "liferayTransactionManager";
99 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
100 "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
101 true);
102 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
103 "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
104 true);
105
106 public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
107 ShoppingCategory model = new ShoppingCategoryImpl();
108
109 model.setCategoryId(soapModel.getCategoryId());
110 model.setGroupId(soapModel.getGroupId());
111 model.setCompanyId(soapModel.getCompanyId());
112 model.setUserId(soapModel.getUserId());
113 model.setUserName(soapModel.getUserName());
114 model.setCreateDate(soapModel.getCreateDate());
115 model.setModifiedDate(soapModel.getModifiedDate());
116 model.setParentCategoryId(soapModel.getParentCategoryId());
117 model.setName(soapModel.getName());
118 model.setDescription(soapModel.getDescription());
119
120 return model;
121 }
122
123 public static List<ShoppingCategory> toModels(
124 ShoppingCategorySoap[] soapModels) {
125 List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
126
127 for (ShoppingCategorySoap soapModel : soapModels) {
128 models.add(toModel(soapModel));
129 }
130
131 return models;
132 }
133
134 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
135 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
136
137 public ShoppingCategoryModelImpl() {
138 }
139
140 public long getPrimaryKey() {
141 return _categoryId;
142 }
143
144 public void setPrimaryKey(long pk) {
145 setCategoryId(pk);
146 }
147
148 public Serializable getPrimaryKeyObj() {
149 return new Long(_categoryId);
150 }
151
152 public long getCategoryId() {
153 return _categoryId;
154 }
155
156 public void setCategoryId(long categoryId) {
157 _categoryId = categoryId;
158 }
159
160 public long getGroupId() {
161 return _groupId;
162 }
163
164 public void setGroupId(long groupId) {
165 _groupId = groupId;
166 }
167
168 public long getCompanyId() {
169 return _companyId;
170 }
171
172 public void setCompanyId(long companyId) {
173 _companyId = companyId;
174 }
175
176 public long getUserId() {
177 return _userId;
178 }
179
180 public void setUserId(long userId) {
181 _userId = userId;
182 }
183
184 public String getUserName() {
185 return GetterUtil.getString(_userName);
186 }
187
188 public void setUserName(String userName) {
189 _userName = userName;
190 }
191
192 public Date getCreateDate() {
193 return _createDate;
194 }
195
196 public void setCreateDate(Date createDate) {
197 _createDate = createDate;
198 }
199
200 public Date getModifiedDate() {
201 return _modifiedDate;
202 }
203
204 public void setModifiedDate(Date modifiedDate) {
205 _modifiedDate = modifiedDate;
206 }
207
208 public long getParentCategoryId() {
209 return _parentCategoryId;
210 }
211
212 public void setParentCategoryId(long parentCategoryId) {
213 _parentCategoryId = parentCategoryId;
214 }
215
216 public String getName() {
217 return GetterUtil.getString(_name);
218 }
219
220 public void setName(String name) {
221 _name = name;
222 }
223
224 public String getDescription() {
225 return GetterUtil.getString(_description);
226 }
227
228 public void setDescription(String description) {
229 _description = description;
230 }
231
232 public ShoppingCategory toEscapedModel() {
233 if (isEscapedModel()) {
234 return (ShoppingCategory)this;
235 }
236 else {
237 ShoppingCategory model = new ShoppingCategoryImpl();
238
239 model.setNew(isNew());
240 model.setEscapedModel(true);
241
242 model.setCategoryId(getCategoryId());
243 model.setGroupId(getGroupId());
244 model.setCompanyId(getCompanyId());
245 model.setUserId(getUserId());
246 model.setUserName(HtmlUtil.escape(getUserName()));
247 model.setCreateDate(getCreateDate());
248 model.setModifiedDate(getModifiedDate());
249 model.setParentCategoryId(getParentCategoryId());
250 model.setName(HtmlUtil.escape(getName()));
251 model.setDescription(HtmlUtil.escape(getDescription()));
252
253 model = (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
254 new Class[] { ShoppingCategory.class },
255 new ReadOnlyBeanHandler(model));
256
257 return model;
258 }
259 }
260
261 public ExpandoBridge getExpandoBridge() {
262 if (_expandoBridge == null) {
263 _expandoBridge = new ExpandoBridgeImpl(ShoppingCategory.class.getName(),
264 getPrimaryKey());
265 }
266
267 return _expandoBridge;
268 }
269
270 public Object clone() {
271 ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
272
273 clone.setCategoryId(getCategoryId());
274 clone.setGroupId(getGroupId());
275 clone.setCompanyId(getCompanyId());
276 clone.setUserId(getUserId());
277 clone.setUserName(getUserName());
278 clone.setCreateDate(getCreateDate());
279 clone.setModifiedDate(getModifiedDate());
280 clone.setParentCategoryId(getParentCategoryId());
281 clone.setName(getName());
282 clone.setDescription(getDescription());
283
284 return clone;
285 }
286
287 public int compareTo(ShoppingCategory shoppingCategory) {
288 int value = 0;
289
290 if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
291 value = -1;
292 }
293 else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
294 value = 1;
295 }
296 else {
297 value = 0;
298 }
299
300 if (value != 0) {
301 return value;
302 }
303
304 value = getName().toLowerCase()
305 .compareTo(shoppingCategory.getName().toLowerCase());
306
307 if (value != 0) {
308 return value;
309 }
310
311 return 0;
312 }
313
314 public boolean equals(Object obj) {
315 if (obj == null) {
316 return false;
317 }
318
319 ShoppingCategory shoppingCategory = null;
320
321 try {
322 shoppingCategory = (ShoppingCategory)obj;
323 }
324 catch (ClassCastException cce) {
325 return false;
326 }
327
328 long pk = shoppingCategory.getPrimaryKey();
329
330 if (getPrimaryKey() == pk) {
331 return true;
332 }
333 else {
334 return false;
335 }
336 }
337
338 public int hashCode() {
339 return (int)getPrimaryKey();
340 }
341
342 public String toString() {
343 StringBuilder sb = new StringBuilder();
344
345 sb.append("{categoryId=");
346 sb.append(getCategoryId());
347 sb.append(", groupId=");
348 sb.append(getGroupId());
349 sb.append(", companyId=");
350 sb.append(getCompanyId());
351 sb.append(", userId=");
352 sb.append(getUserId());
353 sb.append(", userName=");
354 sb.append(getUserName());
355 sb.append(", createDate=");
356 sb.append(getCreateDate());
357 sb.append(", modifiedDate=");
358 sb.append(getModifiedDate());
359 sb.append(", parentCategoryId=");
360 sb.append(getParentCategoryId());
361 sb.append(", name=");
362 sb.append(getName());
363 sb.append(", description=");
364 sb.append(getDescription());
365 sb.append("}");
366
367 return sb.toString();
368 }
369
370 public String toXmlString() {
371 StringBuilder sb = new StringBuilder();
372
373 sb.append("<model><model-name>");
374 sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
375 sb.append("</model-name>");
376
377 sb.append(
378 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
379 sb.append(getCategoryId());
380 sb.append("]]></column-value></column>");
381 sb.append(
382 "<column><column-name>groupId</column-name><column-value><![CDATA[");
383 sb.append(getGroupId());
384 sb.append("]]></column-value></column>");
385 sb.append(
386 "<column><column-name>companyId</column-name><column-value><![CDATA[");
387 sb.append(getCompanyId());
388 sb.append("]]></column-value></column>");
389 sb.append(
390 "<column><column-name>userId</column-name><column-value><![CDATA[");
391 sb.append(getUserId());
392 sb.append("]]></column-value></column>");
393 sb.append(
394 "<column><column-name>userName</column-name><column-value><![CDATA[");
395 sb.append(getUserName());
396 sb.append("]]></column-value></column>");
397 sb.append(
398 "<column><column-name>createDate</column-name><column-value><![CDATA[");
399 sb.append(getCreateDate());
400 sb.append("]]></column-value></column>");
401 sb.append(
402 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
403 sb.append(getModifiedDate());
404 sb.append("]]></column-value></column>");
405 sb.append(
406 "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
407 sb.append(getParentCategoryId());
408 sb.append("]]></column-value></column>");
409 sb.append(
410 "<column><column-name>name</column-name><column-value><![CDATA[");
411 sb.append(getName());
412 sb.append("]]></column-value></column>");
413 sb.append(
414 "<column><column-name>description</column-name><column-value><![CDATA[");
415 sb.append(getDescription());
416 sb.append("]]></column-value></column>");
417
418 sb.append("</model>");
419
420 return sb.toString();
421 }
422
423 private long _categoryId;
424 private long _groupId;
425 private long _companyId;
426 private long _userId;
427 private String _userName;
428 private Date _createDate;
429 private Date _modifiedDate;
430 private long _parentCategoryId;
431 private String _name;
432 private String _description;
433 private transient ExpandoBridge _expandoBridge;
434 }