1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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.kernel.util.StringBundler;
30  import com.liferay.portal.model.impl.BaseModelImpl;
31  import com.liferay.portal.service.ServiceContext;
32  import com.liferay.portal.util.PortalUtil;
33  
34  import com.liferay.portlet.expando.model.ExpandoBridge;
35  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
36  import com.liferay.portlet.shopping.model.ShoppingCategory;
37  import com.liferay.portlet.shopping.model.ShoppingCategorySoap;
38  
39  import java.io.Serializable;
40  
41  import java.lang.reflect.Proxy;
42  
43  import java.sql.Types;
44  
45  import java.util.ArrayList;
46  import java.util.Date;
47  import java.util.List;
48  
49  /**
50   * <a href="ShoppingCategoryModelImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * <p>
58   * This interface is a model that represents the ShoppingCategory table in the
59   * database.
60   * </p>
61   *
62   * @author    Brian Wing Shun Chan
63   * @see       ShoppingCategoryImpl
64   * @see       com.liferay.portlet.shopping.model.ShoppingCategory
65   * @see       com.liferay.portlet.shopping.model.ShoppingCategoryModel
66   * @generated
67   */
68  public class ShoppingCategoryModelImpl extends BaseModelImpl<ShoppingCategory> {
69      public static final String TABLE_NAME = "ShoppingCategory";
70      public static final Object[][] TABLE_COLUMNS = {
71              { "categoryId", new Integer(Types.BIGINT) },
72              { "groupId", new Integer(Types.BIGINT) },
73              { "companyId", new Integer(Types.BIGINT) },
74              { "userId", new Integer(Types.BIGINT) },
75              { "userName", new Integer(Types.VARCHAR) },
76              { "createDate", new Integer(Types.TIMESTAMP) },
77              { "modifiedDate", new Integer(Types.TIMESTAMP) },
78              { "parentCategoryId", new Integer(Types.BIGINT) },
79              { "name", new Integer(Types.VARCHAR) },
80              { "description", new Integer(Types.VARCHAR) }
81          };
82      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)";
83      public static final String TABLE_SQL_DROP = "drop table ShoppingCategory";
84      public static final String ORDER_BY_JPQL = " ORDER BY shoppingCategory.parentCategoryId ASC, shoppingCategory.name ASC";
85      public static final String ORDER_BY_SQL = " ORDER BY ShoppingCategory.parentCategoryId ASC, ShoppingCategory.name ASC";
86      public static final String DATA_SOURCE = "liferayDataSource";
87      public static final String SESSION_FACTORY = "liferaySessionFactory";
88      public static final String TX_MANAGER = "liferayTransactionManager";
89      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.entity.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
91              true);
92      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.finder.cache.enabled.com.liferay.portlet.shopping.model.ShoppingCategory"),
94              true);
95  
96      public static ShoppingCategory toModel(ShoppingCategorySoap soapModel) {
97          ShoppingCategory model = new ShoppingCategoryImpl();
98  
99          model.setCategoryId(soapModel.getCategoryId());
100         model.setGroupId(soapModel.getGroupId());
101         model.setCompanyId(soapModel.getCompanyId());
102         model.setUserId(soapModel.getUserId());
103         model.setUserName(soapModel.getUserName());
104         model.setCreateDate(soapModel.getCreateDate());
105         model.setModifiedDate(soapModel.getModifiedDate());
106         model.setParentCategoryId(soapModel.getParentCategoryId());
107         model.setName(soapModel.getName());
108         model.setDescription(soapModel.getDescription());
109 
110         return model;
111     }
112 
113     public static List<ShoppingCategory> toModels(
114         ShoppingCategorySoap[] soapModels) {
115         List<ShoppingCategory> models = new ArrayList<ShoppingCategory>(soapModels.length);
116 
117         for (ShoppingCategorySoap soapModel : soapModels) {
118             models.add(toModel(soapModel));
119         }
120 
121         return models;
122     }
123 
124     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
125                 "lock.expiration.time.com.liferay.portlet.shopping.model.ShoppingCategory"));
126 
127     public ShoppingCategoryModelImpl() {
128     }
129 
130     public long getPrimaryKey() {
131         return _categoryId;
132     }
133 
134     public void setPrimaryKey(long pk) {
135         setCategoryId(pk);
136     }
137 
138     public Serializable getPrimaryKeyObj() {
139         return new Long(_categoryId);
140     }
141 
142     public long getCategoryId() {
143         return _categoryId;
144     }
145 
146     public void setCategoryId(long categoryId) {
147         _categoryId = categoryId;
148     }
149 
150     public long getGroupId() {
151         return _groupId;
152     }
153 
154     public void setGroupId(long groupId) {
155         _groupId = groupId;
156     }
157 
158     public long getCompanyId() {
159         return _companyId;
160     }
161 
162     public void setCompanyId(long companyId) {
163         _companyId = companyId;
164     }
165 
166     public long getUserId() {
167         return _userId;
168     }
169 
170     public void setUserId(long userId) {
171         _userId = userId;
172     }
173 
174     public String getUserUuid() throws SystemException {
175         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
176     }
177 
178     public void setUserUuid(String userUuid) {
179         _userUuid = userUuid;
180     }
181 
182     public String getUserName() {
183         return GetterUtil.getString(_userName);
184     }
185 
186     public void setUserName(String userName) {
187         _userName = userName;
188     }
189 
190     public Date getCreateDate() {
191         return _createDate;
192     }
193 
194     public void setCreateDate(Date createDate) {
195         _createDate = createDate;
196     }
197 
198     public Date getModifiedDate() {
199         return _modifiedDate;
200     }
201 
202     public void setModifiedDate(Date modifiedDate) {
203         _modifiedDate = modifiedDate;
204     }
205 
206     public long getParentCategoryId() {
207         return _parentCategoryId;
208     }
209 
210     public void setParentCategoryId(long parentCategoryId) {
211         _parentCategoryId = parentCategoryId;
212     }
213 
214     public String getName() {
215         return GetterUtil.getString(_name);
216     }
217 
218     public void setName(String name) {
219         _name = name;
220     }
221 
222     public String getDescription() {
223         return GetterUtil.getString(_description);
224     }
225 
226     public void setDescription(String description) {
227         _description = description;
228     }
229 
230     public ShoppingCategory toEscapedModel() {
231         if (isEscapedModel()) {
232             return (ShoppingCategory)this;
233         }
234         else {
235             ShoppingCategory model = new ShoppingCategoryImpl();
236 
237             model.setNew(isNew());
238             model.setEscapedModel(true);
239 
240             model.setCategoryId(getCategoryId());
241             model.setGroupId(getGroupId());
242             model.setCompanyId(getCompanyId());
243             model.setUserId(getUserId());
244             model.setUserName(HtmlUtil.escape(getUserName()));
245             model.setCreateDate(getCreateDate());
246             model.setModifiedDate(getModifiedDate());
247             model.setParentCategoryId(getParentCategoryId());
248             model.setName(HtmlUtil.escape(getName()));
249             model.setDescription(HtmlUtil.escape(getDescription()));
250 
251             model = (ShoppingCategory)Proxy.newProxyInstance(ShoppingCategory.class.getClassLoader(),
252                     new Class[] { ShoppingCategory.class },
253                     new ReadOnlyBeanHandler(model));
254 
255             return model;
256         }
257     }
258 
259     public ExpandoBridge getExpandoBridge() {
260         if (_expandoBridge == null) {
261             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(ShoppingCategory.class.getName(),
262                     getPrimaryKey());
263         }
264 
265         return _expandoBridge;
266     }
267 
268     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
269         getExpandoBridge().setAttributes(serviceContext);
270     }
271 
272     public Object clone() {
273         ShoppingCategoryImpl clone = new ShoppingCategoryImpl();
274 
275         clone.setCategoryId(getCategoryId());
276         clone.setGroupId(getGroupId());
277         clone.setCompanyId(getCompanyId());
278         clone.setUserId(getUserId());
279         clone.setUserName(getUserName());
280         clone.setCreateDate(getCreateDate());
281         clone.setModifiedDate(getModifiedDate());
282         clone.setParentCategoryId(getParentCategoryId());
283         clone.setName(getName());
284         clone.setDescription(getDescription());
285 
286         return clone;
287     }
288 
289     public int compareTo(ShoppingCategory shoppingCategory) {
290         int value = 0;
291 
292         if (getParentCategoryId() < shoppingCategory.getParentCategoryId()) {
293             value = -1;
294         }
295         else if (getParentCategoryId() > shoppingCategory.getParentCategoryId()) {
296             value = 1;
297         }
298         else {
299             value = 0;
300         }
301 
302         if (value != 0) {
303             return value;
304         }
305 
306         value = getName().toLowerCase()
307                     .compareTo(shoppingCategory.getName().toLowerCase());
308 
309         if (value != 0) {
310             return value;
311         }
312 
313         return 0;
314     }
315 
316     public boolean equals(Object obj) {
317         if (obj == null) {
318             return false;
319         }
320 
321         ShoppingCategory shoppingCategory = null;
322 
323         try {
324             shoppingCategory = (ShoppingCategory)obj;
325         }
326         catch (ClassCastException cce) {
327             return false;
328         }
329 
330         long pk = shoppingCategory.getPrimaryKey();
331 
332         if (getPrimaryKey() == pk) {
333             return true;
334         }
335         else {
336             return false;
337         }
338     }
339 
340     public int hashCode() {
341         return (int)getPrimaryKey();
342     }
343 
344     public String toString() {
345         StringBundler sb = new StringBundler(21);
346 
347         sb.append("{categoryId=");
348         sb.append(getCategoryId());
349         sb.append(", groupId=");
350         sb.append(getGroupId());
351         sb.append(", companyId=");
352         sb.append(getCompanyId());
353         sb.append(", userId=");
354         sb.append(getUserId());
355         sb.append(", userName=");
356         sb.append(getUserName());
357         sb.append(", createDate=");
358         sb.append(getCreateDate());
359         sb.append(", modifiedDate=");
360         sb.append(getModifiedDate());
361         sb.append(", parentCategoryId=");
362         sb.append(getParentCategoryId());
363         sb.append(", name=");
364         sb.append(getName());
365         sb.append(", description=");
366         sb.append(getDescription());
367         sb.append("}");
368 
369         return sb.toString();
370     }
371 
372     public String toXmlString() {
373         StringBundler sb = new StringBundler(34);
374 
375         sb.append("<model><model-name>");
376         sb.append("com.liferay.portlet.shopping.model.ShoppingCategory");
377         sb.append("</model-name>");
378 
379         sb.append(
380             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
381         sb.append(getCategoryId());
382         sb.append("]]></column-value></column>");
383         sb.append(
384             "<column><column-name>groupId</column-name><column-value><![CDATA[");
385         sb.append(getGroupId());
386         sb.append("]]></column-value></column>");
387         sb.append(
388             "<column><column-name>companyId</column-name><column-value><![CDATA[");
389         sb.append(getCompanyId());
390         sb.append("]]></column-value></column>");
391         sb.append(
392             "<column><column-name>userId</column-name><column-value><![CDATA[");
393         sb.append(getUserId());
394         sb.append("]]></column-value></column>");
395         sb.append(
396             "<column><column-name>userName</column-name><column-value><![CDATA[");
397         sb.append(getUserName());
398         sb.append("]]></column-value></column>");
399         sb.append(
400             "<column><column-name>createDate</column-name><column-value><![CDATA[");
401         sb.append(getCreateDate());
402         sb.append("]]></column-value></column>");
403         sb.append(
404             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
405         sb.append(getModifiedDate());
406         sb.append("]]></column-value></column>");
407         sb.append(
408             "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
409         sb.append(getParentCategoryId());
410         sb.append("]]></column-value></column>");
411         sb.append(
412             "<column><column-name>name</column-name><column-value><![CDATA[");
413         sb.append(getName());
414         sb.append("]]></column-value></column>");
415         sb.append(
416             "<column><column-name>description</column-name><column-value><![CDATA[");
417         sb.append(getDescription());
418         sb.append("]]></column-value></column>");
419 
420         sb.append("</model>");
421 
422         return sb.toString();
423     }
424 
425     private long _categoryId;
426     private long _groupId;
427     private long _companyId;
428     private long _userId;
429     private String _userUuid;
430     private String _userName;
431     private Date _createDate;
432     private Date _modifiedDate;
433     private long _parentCategoryId;
434     private String _name;
435     private String _description;
436     private transient ExpandoBridge _expandoBridge;
437 }