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