1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.asset.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.language.LanguageUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.HtmlUtil;
22  import com.liferay.portal.kernel.util.LocaleUtil;
23  import com.liferay.portal.kernel.util.LocalizationUtil;
24  import com.liferay.portal.kernel.util.StringBundler;
25  import com.liferay.portal.kernel.util.StringPool;
26  import com.liferay.portal.kernel.util.Validator;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.service.ServiceContext;
29  import com.liferay.portal.util.PortalUtil;
30  
31  import com.liferay.portlet.asset.model.AssetCategory;
32  import com.liferay.portlet.asset.model.AssetCategorySoap;
33  import com.liferay.portlet.expando.model.ExpandoBridge;
34  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
35  
36  import java.io.Serializable;
37  
38  import java.lang.reflect.Proxy;
39  
40  import java.sql.Types;
41  
42  import java.util.ArrayList;
43  import java.util.Date;
44  import java.util.List;
45  import java.util.Locale;
46  import java.util.Map;
47  
48  /**
49   * <a href="AssetCategoryModelImpl.java.html"><b><i>View Source</i></b></a>
50   *
51   * <p>
52   * ServiceBuilder generated this class. Modifications in this class will be
53   * overwritten the next time is generated.
54   * </p>
55   *
56   * <p>
57   * This interface is a model that represents the AssetCategory table in the
58   * database.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       AssetCategoryImpl
63   * @see       com.liferay.portlet.asset.model.AssetCategory
64   * @see       com.liferay.portlet.asset.model.AssetCategoryModel
65   * @generated
66   */
67  public class AssetCategoryModelImpl extends BaseModelImpl<AssetCategory> {
68      public static final String TABLE_NAME = "AssetCategory";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "uuid_", new Integer(Types.VARCHAR) },
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              { "leftCategoryId", new Integer(Types.BIGINT) },
80              { "rightCategoryId", new Integer(Types.BIGINT) },
81              { "name", new Integer(Types.VARCHAR) },
82              { "title", new Integer(Types.VARCHAR) },
83              { "vocabularyId", new Integer(Types.BIGINT) }
84          };
85      public static final String TABLE_SQL_CREATE = "create table AssetCategory (uuid_ VARCHAR(75) null,categoryId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentCategoryId LONG,leftCategoryId LONG,rightCategoryId LONG,name VARCHAR(75) null,title STRING null,vocabularyId LONG)";
86      public static final String TABLE_SQL_DROP = "drop table AssetCategory";
87      public static final String ORDER_BY_JPQL = " ORDER BY assetCategory.name ASC";
88      public static final String ORDER_BY_SQL = " ORDER BY AssetCategory.name ASC";
89      public static final String DATA_SOURCE = "liferayDataSource";
90      public static final String SESSION_FACTORY = "liferaySessionFactory";
91      public static final String TX_MANAGER = "liferayTransactionManager";
92      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetCategory"),
94              true);
95      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetCategory"),
97              true);
98  
99      public static AssetCategory toModel(AssetCategorySoap soapModel) {
100         AssetCategory model = new AssetCategoryImpl();
101 
102         model.setUuid(soapModel.getUuid());
103         model.setCategoryId(soapModel.getCategoryId());
104         model.setGroupId(soapModel.getGroupId());
105         model.setCompanyId(soapModel.getCompanyId());
106         model.setUserId(soapModel.getUserId());
107         model.setUserName(soapModel.getUserName());
108         model.setCreateDate(soapModel.getCreateDate());
109         model.setModifiedDate(soapModel.getModifiedDate());
110         model.setParentCategoryId(soapModel.getParentCategoryId());
111         model.setLeftCategoryId(soapModel.getLeftCategoryId());
112         model.setRightCategoryId(soapModel.getRightCategoryId());
113         model.setName(soapModel.getName());
114         model.setTitle(soapModel.getTitle());
115         model.setVocabularyId(soapModel.getVocabularyId());
116 
117         return model;
118     }
119 
120     public static List<AssetCategory> toModels(AssetCategorySoap[] soapModels) {
121         List<AssetCategory> models = new ArrayList<AssetCategory>(soapModels.length);
122 
123         for (AssetCategorySoap soapModel : soapModels) {
124             models.add(toModel(soapModel));
125         }
126 
127         return models;
128     }
129 
130     public static final String MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME = com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME;
131     public static final boolean FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES =
132         com.liferay.portlet.asset.model.impl.AssetEntryModelImpl.FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES;
133     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
134                 "lock.expiration.time.com.liferay.portlet.asset.model.AssetCategory"));
135 
136     public AssetCategoryModelImpl() {
137     }
138 
139     public long getPrimaryKey() {
140         return _categoryId;
141     }
142 
143     public void setPrimaryKey(long pk) {
144         setCategoryId(pk);
145     }
146 
147     public Serializable getPrimaryKeyObj() {
148         return new Long(_categoryId);
149     }
150 
151     public String getUuid() {
152         if (_uuid == null) {
153             return StringPool.BLANK;
154         }
155         else {
156             return _uuid;
157         }
158     }
159 
160     public void setUuid(String uuid) {
161         _uuid = uuid;
162 
163         if (_originalUuid == null) {
164             _originalUuid = uuid;
165         }
166     }
167 
168     public String getOriginalUuid() {
169         return GetterUtil.getString(_originalUuid);
170     }
171 
172     public long getCategoryId() {
173         return _categoryId;
174     }
175 
176     public void setCategoryId(long categoryId) {
177         _categoryId = categoryId;
178     }
179 
180     public long getGroupId() {
181         return _groupId;
182     }
183 
184     public void setGroupId(long groupId) {
185         _groupId = groupId;
186 
187         if (!_setOriginalGroupId) {
188             _setOriginalGroupId = true;
189 
190             _originalGroupId = groupId;
191         }
192     }
193 
194     public long getOriginalGroupId() {
195         return _originalGroupId;
196     }
197 
198     public long getCompanyId() {
199         return _companyId;
200     }
201 
202     public void setCompanyId(long companyId) {
203         _companyId = companyId;
204     }
205 
206     public long getUserId() {
207         return _userId;
208     }
209 
210     public void setUserId(long userId) {
211         _userId = userId;
212     }
213 
214     public String getUserUuid() throws SystemException {
215         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
216     }
217 
218     public void setUserUuid(String userUuid) {
219         _userUuid = userUuid;
220     }
221 
222     public String getUserName() {
223         if (_userName == null) {
224             return StringPool.BLANK;
225         }
226         else {
227             return _userName;
228         }
229     }
230 
231     public void setUserName(String userName) {
232         _userName = userName;
233     }
234 
235     public Date getCreateDate() {
236         return _createDate;
237     }
238 
239     public void setCreateDate(Date createDate) {
240         _createDate = createDate;
241     }
242 
243     public Date getModifiedDate() {
244         return _modifiedDate;
245     }
246 
247     public void setModifiedDate(Date modifiedDate) {
248         _modifiedDate = modifiedDate;
249     }
250 
251     public long getParentCategoryId() {
252         return _parentCategoryId;
253     }
254 
255     public void setParentCategoryId(long parentCategoryId) {
256         _parentCategoryId = parentCategoryId;
257 
258         if (!_setOriginalParentCategoryId) {
259             _setOriginalParentCategoryId = true;
260 
261             _originalParentCategoryId = parentCategoryId;
262         }
263     }
264 
265     public long getOriginalParentCategoryId() {
266         return _originalParentCategoryId;
267     }
268 
269     public long getLeftCategoryId() {
270         return _leftCategoryId;
271     }
272 
273     public void setLeftCategoryId(long leftCategoryId) {
274         _leftCategoryId = leftCategoryId;
275     }
276 
277     public long getRightCategoryId() {
278         return _rightCategoryId;
279     }
280 
281     public void setRightCategoryId(long rightCategoryId) {
282         _rightCategoryId = rightCategoryId;
283     }
284 
285     public String getName() {
286         if (_name == null) {
287             return StringPool.BLANK;
288         }
289         else {
290             return _name;
291         }
292     }
293 
294     public void setName(String name) {
295         _name = name;
296 
297         if (_originalName == null) {
298             _originalName = name;
299         }
300     }
301 
302     public String getOriginalName() {
303         return GetterUtil.getString(_originalName);
304     }
305 
306     public String getTitle() {
307         if (_title == null) {
308             return StringPool.BLANK;
309         }
310         else {
311             return _title;
312         }
313     }
314 
315     public String getTitle(Locale locale) {
316         String languageId = LocaleUtil.toLanguageId(locale);
317 
318         return getTitle(languageId);
319     }
320 
321     public String getTitle(Locale locale, boolean useDefault) {
322         String languageId = LocaleUtil.toLanguageId(locale);
323 
324         return getTitle(languageId, useDefault);
325     }
326 
327     public String getTitle(String languageId) {
328         String value = LocalizationUtil.getLocalization(getTitle(), languageId);
329 
330         if (isEscapedModel()) {
331             return HtmlUtil.escape(value);
332         }
333         else {
334             return value;
335         }
336     }
337 
338     public String getTitle(String languageId, boolean useDefault) {
339         String value = LocalizationUtil.getLocalization(getTitle(), languageId,
340                 useDefault);
341 
342         if (isEscapedModel()) {
343             return HtmlUtil.escape(value);
344         }
345         else {
346             return value;
347         }
348     }
349 
350     public Map<Locale, String> getTitleMap() {
351         return LocalizationUtil.getLocalizationMap(getTitle());
352     }
353 
354     public void setTitle(String title) {
355         _title = title;
356     }
357 
358     public void setTitle(Locale locale, String title) {
359         String languageId = LocaleUtil.toLanguageId(locale);
360 
361         if (Validator.isNotNull(title)) {
362             setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
363                     title, languageId));
364         }
365         else {
366             setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
367                     languageId));
368         }
369     }
370 
371     public void setTitleMap(Map<Locale, String> titleMap) {
372         if (titleMap == null) {
373             return;
374         }
375 
376         Locale[] locales = LanguageUtil.getAvailableLocales();
377 
378         for (Locale locale : locales) {
379             String title = titleMap.get(locale);
380 
381             setTitle(locale, title);
382         }
383     }
384 
385     public long getVocabularyId() {
386         return _vocabularyId;
387     }
388 
389     public void setVocabularyId(long vocabularyId) {
390         _vocabularyId = vocabularyId;
391 
392         if (!_setOriginalVocabularyId) {
393             _setOriginalVocabularyId = true;
394 
395             _originalVocabularyId = vocabularyId;
396         }
397     }
398 
399     public long getOriginalVocabularyId() {
400         return _originalVocabularyId;
401     }
402 
403     public AssetCategory toEscapedModel() {
404         if (isEscapedModel()) {
405             return (AssetCategory)this;
406         }
407         else {
408             return (AssetCategory)Proxy.newProxyInstance(AssetCategory.class.getClassLoader(),
409                 new Class[] { AssetCategory.class },
410                 new AutoEscapeBeanHandler(this));
411         }
412     }
413 
414     public ExpandoBridge getExpandoBridge() {
415         if (_expandoBridge == null) {
416             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
417                     AssetCategory.class.getName(), getPrimaryKey());
418         }
419 
420         return _expandoBridge;
421     }
422 
423     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
424         getExpandoBridge().setAttributes(serviceContext);
425     }
426 
427     public Object clone() {
428         AssetCategoryImpl clone = new AssetCategoryImpl();
429 
430         clone.setUuid(getUuid());
431         clone.setCategoryId(getCategoryId());
432         clone.setGroupId(getGroupId());
433         clone.setCompanyId(getCompanyId());
434         clone.setUserId(getUserId());
435         clone.setUserName(getUserName());
436         clone.setCreateDate(getCreateDate());
437         clone.setModifiedDate(getModifiedDate());
438         clone.setParentCategoryId(getParentCategoryId());
439         clone.setLeftCategoryId(getLeftCategoryId());
440         clone.setRightCategoryId(getRightCategoryId());
441         clone.setName(getName());
442         clone.setTitle(getTitle());
443         clone.setVocabularyId(getVocabularyId());
444 
445         return clone;
446     }
447 
448     public int compareTo(AssetCategory assetCategory) {
449         int value = 0;
450 
451         value = getName().compareTo(assetCategory.getName());
452 
453         if (value != 0) {
454             return value;
455         }
456 
457         return 0;
458     }
459 
460     public boolean equals(Object obj) {
461         if (obj == null) {
462             return false;
463         }
464 
465         AssetCategory assetCategory = null;
466 
467         try {
468             assetCategory = (AssetCategory)obj;
469         }
470         catch (ClassCastException cce) {
471             return false;
472         }
473 
474         long pk = assetCategory.getPrimaryKey();
475 
476         if (getPrimaryKey() == pk) {
477             return true;
478         }
479         else {
480             return false;
481         }
482     }
483 
484     public int hashCode() {
485         return (int)getPrimaryKey();
486     }
487 
488     public String toString() {
489         StringBundler sb = new StringBundler(29);
490 
491         sb.append("{uuid=");
492         sb.append(getUuid());
493         sb.append(", categoryId=");
494         sb.append(getCategoryId());
495         sb.append(", groupId=");
496         sb.append(getGroupId());
497         sb.append(", companyId=");
498         sb.append(getCompanyId());
499         sb.append(", userId=");
500         sb.append(getUserId());
501         sb.append(", userName=");
502         sb.append(getUserName());
503         sb.append(", createDate=");
504         sb.append(getCreateDate());
505         sb.append(", modifiedDate=");
506         sb.append(getModifiedDate());
507         sb.append(", parentCategoryId=");
508         sb.append(getParentCategoryId());
509         sb.append(", leftCategoryId=");
510         sb.append(getLeftCategoryId());
511         sb.append(", rightCategoryId=");
512         sb.append(getRightCategoryId());
513         sb.append(", name=");
514         sb.append(getName());
515         sb.append(", title=");
516         sb.append(getTitle());
517         sb.append(", vocabularyId=");
518         sb.append(getVocabularyId());
519         sb.append("}");
520 
521         return sb.toString();
522     }
523 
524     public String toXmlString() {
525         StringBundler sb = new StringBundler(46);
526 
527         sb.append("<model><model-name>");
528         sb.append("com.liferay.portlet.asset.model.AssetCategory");
529         sb.append("</model-name>");
530 
531         sb.append(
532             "<column><column-name>uuid</column-name><column-value><![CDATA[");
533         sb.append(getUuid());
534         sb.append("]]></column-value></column>");
535         sb.append(
536             "<column><column-name>categoryId</column-name><column-value><![CDATA[");
537         sb.append(getCategoryId());
538         sb.append("]]></column-value></column>");
539         sb.append(
540             "<column><column-name>groupId</column-name><column-value><![CDATA[");
541         sb.append(getGroupId());
542         sb.append("]]></column-value></column>");
543         sb.append(
544             "<column><column-name>companyId</column-name><column-value><![CDATA[");
545         sb.append(getCompanyId());
546         sb.append("]]></column-value></column>");
547         sb.append(
548             "<column><column-name>userId</column-name><column-value><![CDATA[");
549         sb.append(getUserId());
550         sb.append("]]></column-value></column>");
551         sb.append(
552             "<column><column-name>userName</column-name><column-value><![CDATA[");
553         sb.append(getUserName());
554         sb.append("]]></column-value></column>");
555         sb.append(
556             "<column><column-name>createDate</column-name><column-value><![CDATA[");
557         sb.append(getCreateDate());
558         sb.append("]]></column-value></column>");
559         sb.append(
560             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
561         sb.append(getModifiedDate());
562         sb.append("]]></column-value></column>");
563         sb.append(
564             "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
565         sb.append(getParentCategoryId());
566         sb.append("]]></column-value></column>");
567         sb.append(
568             "<column><column-name>leftCategoryId</column-name><column-value><![CDATA[");
569         sb.append(getLeftCategoryId());
570         sb.append("]]></column-value></column>");
571         sb.append(
572             "<column><column-name>rightCategoryId</column-name><column-value><![CDATA[");
573         sb.append(getRightCategoryId());
574         sb.append("]]></column-value></column>");
575         sb.append(
576             "<column><column-name>name</column-name><column-value><![CDATA[");
577         sb.append(getName());
578         sb.append("]]></column-value></column>");
579         sb.append(
580             "<column><column-name>title</column-name><column-value><![CDATA[");
581         sb.append(getTitle());
582         sb.append("]]></column-value></column>");
583         sb.append(
584             "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
585         sb.append(getVocabularyId());
586         sb.append("]]></column-value></column>");
587 
588         sb.append("</model>");
589 
590         return sb.toString();
591     }
592 
593     private String _uuid;
594     private String _originalUuid;
595     private long _categoryId;
596     private long _groupId;
597     private long _originalGroupId;
598     private boolean _setOriginalGroupId;
599     private long _companyId;
600     private long _userId;
601     private String _userUuid;
602     private String _userName;
603     private Date _createDate;
604     private Date _modifiedDate;
605     private long _parentCategoryId;
606     private long _originalParentCategoryId;
607     private boolean _setOriginalParentCategoryId;
608     private long _leftCategoryId;
609     private long _rightCategoryId;
610     private String _name;
611     private String _originalName;
612     private String _title;
613     private long _vocabularyId;
614     private long _originalVocabularyId;
615     private boolean _setOriginalVocabularyId;
616     private transient ExpandoBridge _expandoBridge;
617 }