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