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