001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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     * The base model implementation for the ShoppingCategory service. Represents a row in the "ShoppingCategory" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portlet.shopping.model.ShoppingCategoryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ShoppingCategoryImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a shopping category model instance should use the {@link com.liferay.portlet.shopping.model.ShoppingCategory} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see ShoppingCategoryImpl
055     * @see com.liferay.portlet.shopping.model.ShoppingCategory
056     * @see com.liferay.portlet.shopping.model.ShoppingCategoryModel
057     * @generated
058     */
059    public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory>
060            implements ShoppingCategoryModel {
061            public static final String TABLE_NAME = "ShoppingCategory";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "categoryId", new Integer(Types.BIGINT) },
064                            { "groupId", new Integer(Types.BIGINT) },
065                            { "companyId", new Integer(Types.BIGINT) },
066                            { "userId", new Integer(Types.BIGINT) },
067                            { "userName", new Integer(Types.VARCHAR) },
068                            { "createDate", new Integer(Types.TIMESTAMP) },
069                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
070                            { "parentCategoryId", new Integer(Types.BIGINT) },
071                            { "name", new Integer(Types.VARCHAR) },
072                            { "description", new Integer(Types.VARCHAR) }
073                    };
074            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)";
075            public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
076            public static final String ORDER_BY_JPQL = " ORDER BY shoppingCategory.parentCategoryId ASC, shoppingCategory.name ASC";
077            public static final String ORDER_BY_SQL = " ORDER BY ShoppingCategory.parentCategoryId ASC, ShoppingCategory.name ASC";
078            public static final String DATA_SOURCE = "liferayDataSource";
079            public static final String SESSION_FACTORY = "liferaySessionFactory";
080            public static final String TX_MANAGER = "liferayTransactionManager";
081            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
083                            true);
084            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085                                    "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
086                            true);
087    
088            /**
089             * Converts the soap model instance into a normal model instance.
090             *
091             * @param soapModel the soap model instance to convert
092             * @return the normal model instance
093             */
094            public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
095                    ShoppingCategory model = new ShoppingCategoryImpl();
096    
097                    model.setCategoryId(soapModel.getCategoryId());
098                    model.setGroupId(soapModel.getGroupId());
099                    model.setCompanyId(soapModel.getCompanyId());
100                    model.setUserId(soapModel.getUserId());
101                    model.setUserName(soapModel.getUserName());
102                    model.setCreateDate(soapModel.getCreateDate());
103                    model.setModifiedDate(soapModel.getModifiedDate());
104                    model.setParentCategoryId(soapModel.getParentCategoryId());
105                    model.setName(soapModel.getName());
106                    model.setDescription(soapModel.getDescription());
107    
108                    return model;
109            }
110    
111            /**
112             * Converts the soap model instances into normal model instances.
113             *
114             * @param soapModels the soap model instances to convert
115             * @return the normal model instances
116             */
117            public static List<ShoppingCategory> toModels(
118                    ShoppingCategorySoap[] soapModels) {
119                    List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
120    
121                    for (ShoppingCategorySoap soapModel : soapModels) {
122                            models.add(toModel(soapModel));
123                    }
124    
125                    return models;
126            }
127    
128            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
129                                    "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
130    
131            public ShoppingCategoryModelImpl() {
132            }
133    
134            public long getPrimaryKey() {
135                    return _categoryId;
136            }
137    
138            public void setPrimaryKey(long pk) {
139                    setCategoryId(pk);
140            }
141    
142            public Serializable getPrimaryKeyObj() {
143                    return new Long(_categoryId);
144            }
145    
146            public long getCategoryId() {
147                    return _categoryId;
148            }
149    
150            public void setCategoryId(long categoryId) {
151                    _categoryId = categoryId;
152            }
153    
154            public long getGroupId() {
155                    return _groupId;
156            }
157    
158            public void setGroupId(long groupId) {
159                    _groupId = groupId;
160            }
161    
162            public long getCompanyId() {
163                    return _companyId;
164            }
165    
166            public void setCompanyId(long companyId) {
167                    _companyId = companyId;
168            }
169    
170            public long getUserId() {
171                    return _userId;
172            }
173    
174            public void setUserId(long userId) {
175                    _userId = userId;
176            }
177    
178            public String getUserUuid() throws SystemException {
179                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
180            }
181    
182            public void setUserUuid(String userUuid) {
183                    _userUuid = userUuid;
184            }
185    
186            public String getUserName() {
187                    if (_userName == null) {
188                            return StringPool.BLANK;
189                    }
190                    else {
191                            return _userName;
192                    }
193            }
194    
195            public void setUserName(String userName) {
196                    _userName = userName;
197            }
198    
199            public Date getCreateDate() {
200                    return _createDate;
201            }
202    
203            public void setCreateDate(Date createDate) {
204                    _createDate = createDate;
205            }
206    
207            public Date getModifiedDate() {
208                    return _modifiedDate;
209            }
210    
211            public void setModifiedDate(Date modifiedDate) {
212                    _modifiedDate = modifiedDate;
213            }
214    
215            public long getParentCategoryId() {
216                    return _parentCategoryId;
217            }
218    
219            public void setParentCategoryId(long parentCategoryId) {
220                    _parentCategoryId = parentCategoryId;
221            }
222    
223            public String getName() {
224                    if (_name == null) {
225                            return StringPool.BLANK;
226                    }
227                    else {
228                            return _name;
229                    }
230            }
231    
232            public void setName(String name) {
233                    _name = name;
234            }
235    
236            public String getDescription() {
237                    if (_description == null) {
238                            return StringPool.BLANK;
239                    }
240                    else {
241                            return _description;
242                    }
243            }
244    
245            public void setDescription(String description) {
246                    _description = description;
247            }
248    
249            public ShoppingCategory toEscapedModel() {
250                    if (isEscapedModel()) {
251                            return (ShoppingCategory)this;
252                    }
253                    else {
254                            return (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
255                                    new Class[] { ShoppingCategory.class },
256                                    new AutoEscapeBeanHandler(this));
257                    }
258            }
259    
260            public ExpandoBridge getExpandoBridge() {
261                    if (_expandoBridge == null) {
262                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
263                                            ShoppingCategory.class.getName(), getPrimaryKey());
264                    }
265    
266                    return _expandoBridge;
267            }
268    
269            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
270                    getExpandoBridge().setAttributes(serviceContext);
271            }
272    
273            public Object clone() {
274                    ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
275    
276                    clone.setCategoryId(getCategoryId());
277                    clone.setGroupId(getGroupId());
278                    clone.setCompanyId(getCompanyId());
279                    clone.setUserId(getUserId());
280                    clone.setUserName(getUserName());
281                    clone.setCreateDate(getCreateDate());
282                    clone.setModifiedDate(getModifiedDate());
283                    clone.setParentCategoryId(getParentCategoryId());
284                    clone.setName(getName());
285                    clone.setDescription(getDescription());
286    
287                    return clone;
288            }
289    
290            public int compareTo(ShoppingCategory shoppingCategory) {
291                    int value = 0;
292    
293                    if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
294                            value = -1;
295                    }
296                    else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
297                            value = 1;
298                    }
299                    else {
300                            value = 0;
301                    }
302    
303                    if (value != 0) {
304                            return value;
305                    }
306    
307                    value = getName().toLowerCase()
308                                            .compareTo(shoppingCategory.getName().toLowerCase());
309    
310                    if (value != 0) {
311                            return value;
312                    }
313    
314                    return 0;
315            }
316    
317            public boolean equals(Object obj) {
318                    if (obj == null) {
319                            return false;
320                    }
321    
322                    ShoppingCategory shoppingCategory = null;
323    
324                    try {
325                            shoppingCategory = (ShoppingCategory)obj;
326                    }
327                    catch (ClassCastException cce) {
328                            return false;
329                    }
330    
331                    long pk = shoppingCategory.getPrimaryKey();
332    
333                    if (getPrimaryKey() == pk) {
334                            return true;
335                    }
336                    else {
337                            return false;
338                    }
339            }
340    
341            public int hashCode() {
342                    return (int)getPrimaryKey();
343            }
344    
345            public String toString() {
346                    StringBundler sb = new StringBundler(21);
347    
348                    sb.append("{categoryId=");
349                    sb.append(getCategoryId());
350                    sb.append(", groupId=");
351                    sb.append(getGroupId());
352                    sb.append(", companyId=");
353                    sb.append(getCompanyId());
354                    sb.append(", userId=");
355                    sb.append(getUserId());
356                    sb.append(", userName=");
357                    sb.append(getUserName());
358                    sb.append(", createDate=");
359                    sb.append(getCreateDate());
360                    sb.append(", modifiedDate=");
361                    sb.append(getModifiedDate());
362                    sb.append(", parentCategoryId=");
363                    sb.append(getParentCategoryId());
364                    sb.append(", name=");
365                    sb.append(getName());
366                    sb.append(", description=");
367                    sb.append(getDescription());
368                    sb.append("}");
369    
370                    return sb.toString();
371            }
372    
373            public String toXmlString() {
374                    StringBundler sb = new StringBundler(34);
375    
376                    sb.append("<model><model-name>");
377                    sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
378                    sb.append("</model-name>");
379    
380                    sb.append(
381                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
382                    sb.append(getCategoryId());
383                    sb.append("]]></column-value></column>");
384                    sb.append(
385                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
386                    sb.append(getGroupId());
387                    sb.append("]]></column-value></column>");
388                    sb.append(
389                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
390                    sb.append(getCompanyId());
391                    sb.append("]]></column-value></column>");
392                    sb.append(
393                            "<column><column-name>userId</column-name><column-value><![CDATA[");
394                    sb.append(getUserId());
395                    sb.append("]]></column-value></column>");
396                    sb.append(
397                            "<column><column-name>userName</column-name><column-value><![CDATA[");
398                    sb.append(getUserName());
399                    sb.append("]]></column-value></column>");
400                    sb.append(
401                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
402                    sb.append(getCreateDate());
403                    sb.append("]]></column-value></column>");
404                    sb.append(
405                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
406                    sb.append(getModifiedDate());
407                    sb.append("]]></column-value></column>");
408                    sb.append(
409                            "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
410                    sb.append(getParentCategoryId());
411                    sb.append("]]></column-value></column>");
412                    sb.append(
413                            "<column><column-name>name</column-name><column-value><![CDATA[");
414                    sb.append(getName());
415                    sb.append("]]></column-value></column>");
416                    sb.append(
417                            "<column><column-name>description</column-name><column-value><![CDATA[");
418                    sb.append(getDescription());
419                    sb.append("]]></column-value></column>");
420    
421                    sb.append("</model>");
422    
423                    return sb.toString();
424            }
425    
426            private long _categoryId;
427            private long _groupId;
428            private long _companyId;
429            private long _userId;
430            private String _userUuid;
431            private String _userName;
432            private Date _createDate;
433            private Date _modifiedDate;
434            private long _parentCategoryId;
435            private String _name;
436            private String _description;
437            private transient ExpandoBridge _expandoBridge;
438    }