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