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