001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.shopping.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    import com.liferay.portlet.shopping.model.ShoppingCategory;
029    import com.liferay.portlet.shopping.model.ShoppingCategoryModel;
030    import com.liferay.portlet.shopping.model.ShoppingCategorySoap;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * <p>
044     * This interface is a model that represents the ShoppingCategory table in the
045     * database.
046     * </p>
047     *
048     * @author    Brian Wing Shun Chan
049     * @see       ShoppingCategoryImpl
050     * @see       com.liferay.portlet.shopping.model.ShoppingCategory
051     * @see       com.liferay.portlet.shopping.model.ShoppingCategoryModel
052     * @generated
053     */
054    public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory>
055            implements ShoppingCategoryModel {
056            public static final String TABLE_NAME = "ShoppingCategory";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "categoryId", new Integer(Types.BIGINT) },
059                            { "groupId", new Integer(Types.BIGINT) },
060                            { "companyId", new Integer(Types.BIGINT) },
061                            { "userId", new Integer(Types.BIGINT) },
062                            { "userName", new Integer(Types.VARCHAR) },
063                            { "createDate", new Integer(Types.TIMESTAMP) },
064                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
065                            { "parentCategoryId", new Integer(Types.BIGINT) },
066                            { "name", new Integer(Types.VARCHAR) },
067                            { "description", new Integer(Types.VARCHAR) }
068                    };
069            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)";
070            public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
071            public static final String ORDER_BY_JPQL = " ORDER BY shoppingCategory.parentCategoryId ASC, shoppingCategory.name ASC";
072            public static final String ORDER_BY_SQL = " ORDER BY ShoppingCategory.parentCategoryId ASC, ShoppingCategory.name ASC";
073            public static final String DATA_SOURCE = "liferayDataSource";
074            public static final String SESSION_FACTORY = "liferaySessionFactory";
075            public static final String TX_MANAGER = "liferayTransactionManager";
076            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
078                            true);
079            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
081                            true);
082    
083            public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
084                    ShoppingCategory model = new ShoppingCategoryImpl();
085    
086                    model.setCategoryId(soapModel.getCategoryId());
087                    model.setGroupId(soapModel.getGroupId());
088                    model.setCompanyId(soapModel.getCompanyId());
089                    model.setUserId(soapModel.getUserId());
090                    model.setUserName(soapModel.getUserName());
091                    model.setCreateDate(soapModel.getCreateDate());
092                    model.setModifiedDate(soapModel.getModifiedDate());
093                    model.setParentCategoryId(soapModel.getParentCategoryId());
094                    model.setName(soapModel.getName());
095                    model.setDescription(soapModel.getDescription());
096    
097                    return model;
098            }
099    
100            public static List<ShoppingCategory> toModels(
101                    ShoppingCategorySoap[] soapModels) {
102                    List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
103    
104                    for (ShoppingCategorySoap soapModel : soapModels) {
105                            models.add(toModel(soapModel));
106                    }
107    
108                    return models;
109            }
110    
111            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
112                                    "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
113    
114            public ShoppingCategoryModelImpl() {
115            }
116    
117            public long getPrimaryKey() {
118                    return _categoryId;
119            }
120    
121            public void setPrimaryKey(long pk) {
122                    setCategoryId(pk);
123            }
124    
125            public Serializable getPrimaryKeyObj() {
126                    return new Long(_categoryId);
127            }
128    
129            public long getCategoryId() {
130                    return _categoryId;
131            }
132    
133            public void setCategoryId(long categoryId) {
134                    _categoryId = categoryId;
135            }
136    
137            public long getGroupId() {
138                    return _groupId;
139            }
140    
141            public void setGroupId(long groupId) {
142                    _groupId = groupId;
143            }
144    
145            public long getCompanyId() {
146                    return _companyId;
147            }
148    
149            public void setCompanyId(long companyId) {
150                    _companyId = companyId;
151            }
152    
153            public long getUserId() {
154                    return _userId;
155            }
156    
157            public void setUserId(long userId) {
158                    _userId = userId;
159            }
160    
161            public String getUserUuid() throws SystemException {
162                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
163            }
164    
165            public void setUserUuid(String userUuid) {
166                    _userUuid = userUuid;
167            }
168    
169            public String getUserName() {
170                    if (_userName == null) {
171                            return StringPool.BLANK;
172                    }
173                    else {
174                            return _userName;
175                    }
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                    if (_name == null) {
208                            return StringPool.BLANK;
209                    }
210                    else {
211                            return _name;
212                    }
213            }
214    
215            public void setName(String name) {
216                    _name = name;
217            }
218    
219            public String getDescription() {
220                    if (_description == null) {
221                            return StringPool.BLANK;
222                    }
223                    else {
224                            return _description;
225                    }
226            }
227    
228            public void setDescription(String description) {
229                    _description = description;
230            }
231    
232            public ShoppingCategory toEscapedModel() {
233                    if (isEscapedModel()) {
234                            return (ShoppingCategory)this;
235                    }
236                    else {
237                            return (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
238                                    new Class[] { ShoppingCategory.class },
239                                    new AutoEscapeBeanHandler(this));
240                    }
241            }
242    
243            public ExpandoBridge getExpandoBridge() {
244                    if (_expandoBridge == null) {
245                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
246                                            ShoppingCategory.class.getName(), getPrimaryKey());
247                    }
248    
249                    return _expandoBridge;
250            }
251    
252            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
253                    getExpandoBridge().setAttributes(serviceContext);
254            }
255    
256            public Object clone() {
257                    ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
258    
259                    clone.setCategoryId(getCategoryId());
260                    clone.setGroupId(getGroupId());
261                    clone.setCompanyId(getCompanyId());
262                    clone.setUserId(getUserId());
263                    clone.setUserName(getUserName());
264                    clone.setCreateDate(getCreateDate());
265                    clone.setModifiedDate(getModifiedDate());
266                    clone.setParentCategoryId(getParentCategoryId());
267                    clone.setName(getName());
268                    clone.setDescription(getDescription());
269    
270                    return clone;
271            }
272    
273            public int compareTo(ShoppingCategory shoppingCategory) {
274                    int value = 0;
275    
276                    if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
277                            value = -1;
278                    }
279                    else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
280                            value = 1;
281                    }
282                    else {
283                            value = 0;
284                    }
285    
286                    if (value != 0) {
287                            return value;
288                    }
289    
290                    value = getName().toLowerCase()
291                                            .compareTo(shoppingCategory.getName().toLowerCase());
292    
293                    if (value != 0) {
294                            return value;
295                    }
296    
297                    return 0;
298            }
299    
300            public boolean equals(Object obj) {
301                    if (obj == null) {
302                            return false;
303                    }
304    
305                    ShoppingCategory shoppingCategory = null;
306    
307                    try {
308                            shoppingCategory = (ShoppingCategory)obj;
309                    }
310                    catch (ClassCastException cce) {
311                            return false;
312                    }
313    
314                    long pk = shoppingCategory.getPrimaryKey();
315    
316                    if (getPrimaryKey() == pk) {
317                            return true;
318                    }
319                    else {
320                            return false;
321                    }
322            }
323    
324            public int hashCode() {
325                    return (int)getPrimaryKey();
326            }
327    
328            public String toString() {
329                    StringBundler sb = new StringBundler(21);
330    
331                    sb.append("{categoryId=");
332                    sb.append(getCategoryId());
333                    sb.append(", groupId=");
334                    sb.append(getGroupId());
335                    sb.append(", companyId=");
336                    sb.append(getCompanyId());
337                    sb.append(", userId=");
338                    sb.append(getUserId());
339                    sb.append(", userName=");
340                    sb.append(getUserName());
341                    sb.append(", createDate=");
342                    sb.append(getCreateDate());
343                    sb.append(", modifiedDate=");
344                    sb.append(getModifiedDate());
345                    sb.append(", parentCategoryId=");
346                    sb.append(getParentCategoryId());
347                    sb.append(", name=");
348                    sb.append(getName());
349                    sb.append(", description=");
350                    sb.append(getDescription());
351                    sb.append("}");
352    
353                    return sb.toString();
354            }
355    
356            public String toXmlString() {
357                    StringBundler sb = new StringBundler(34);
358    
359                    sb.append("<model><model-name>");
360                    sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
361                    sb.append("</model-name>");
362    
363                    sb.append(
364                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
365                    sb.append(getCategoryId());
366                    sb.append("]]></column-value></column>");
367                    sb.append(
368                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
369                    sb.append(getGroupId());
370                    sb.append("]]></column-value></column>");
371                    sb.append(
372                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
373                    sb.append(getCompanyId());
374                    sb.append("]]></column-value></column>");
375                    sb.append(
376                            "<column><column-name>userId</column-name><column-value><![CDATA[");
377                    sb.append(getUserId());
378                    sb.append("]]></column-value></column>");
379                    sb.append(
380                            "<column><column-name>userName</column-name><column-value><![CDATA[");
381                    sb.append(getUserName());
382                    sb.append("]]></column-value></column>");
383                    sb.append(
384                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
385                    sb.append(getCreateDate());
386                    sb.append("]]></column-value></column>");
387                    sb.append(
388                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
389                    sb.append(getModifiedDate());
390                    sb.append("]]></column-value></column>");
391                    sb.append(
392                            "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
393                    sb.append(getParentCategoryId());
394                    sb.append("]]></column-value></column>");
395                    sb.append(
396                            "<column><column-name>name</column-name><column-value><![CDATA[");
397                    sb.append(getName());
398                    sb.append("]]></column-value></column>");
399                    sb.append(
400                            "<column><column-name>description</column-name><column-value><![CDATA[");
401                    sb.append(getDescription());
402                    sb.append("]]></column-value></column>");
403    
404                    sb.append("</model>");
405    
406                    return sb.toString();
407            }
408    
409            private long _categoryId;
410            private long _groupId;
411            private long _companyId;
412            private long _userId;
413            private String _userUuid;
414            private String _userName;
415            private Date _createDate;
416            private Date _modifiedDate;
417            private long _parentCategoryId;
418            private String _name;
419            private String _description;
420            private transient ExpandoBridge _expandoBridge;
421    }