001    /**
002     * Copyright (c) 2000-present 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.asset.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.LocaleException;
020    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
021    import com.liferay.portal.kernel.exception.PortalException;
022    import com.liferay.portal.kernel.json.JSON;
023    import com.liferay.portal.kernel.util.GetterUtil;
024    import com.liferay.portal.kernel.util.LocaleUtil;
025    import com.liferay.portal.kernel.util.LocalizationUtil;
026    import com.liferay.portal.kernel.util.ProxyUtil;
027    import com.liferay.portal.kernel.util.StringBundler;
028    import com.liferay.portal.kernel.util.StringPool;
029    import com.liferay.portal.kernel.util.Validator;
030    import com.liferay.portal.model.CacheModel;
031    import com.liferay.portal.model.User;
032    import com.liferay.portal.model.impl.BaseModelImpl;
033    import com.liferay.portal.service.ServiceContext;
034    import com.liferay.portal.service.UserLocalServiceUtil;
035    import com.liferay.portal.util.PortalUtil;
036    
037    import com.liferay.portlet.asset.model.AssetCategory;
038    import com.liferay.portlet.asset.model.AssetCategoryModel;
039    import com.liferay.portlet.asset.model.AssetCategorySoap;
040    import com.liferay.portlet.expando.model.ExpandoBridge;
041    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
042    import com.liferay.portlet.exportimport.lar.StagedModelType;
043    
044    import java.io.Serializable;
045    
046    import java.sql.Types;
047    
048    import java.util.ArrayList;
049    import java.util.Date;
050    import java.util.HashMap;
051    import java.util.List;
052    import java.util.Locale;
053    import java.util.Map;
054    import java.util.Set;
055    import java.util.TreeSet;
056    
057    /**
058     * The base model implementation for the AssetCategory service. Represents a row in the "AssetCategory" database table, with each column mapped to a property of this class.
059     *
060     * <p>
061     * This implementation and its corresponding interface {@link AssetCategoryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AssetCategoryImpl}.
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see AssetCategoryImpl
066     * @see AssetCategory
067     * @see AssetCategoryModel
068     * @generated
069     */
070    @JSON(strict = true)
071    @ProviderType
072    public class AssetCategoryModelImpl extends BaseModelImpl<AssetCategory>
073            implements AssetCategoryModel {
074            /*
075             * NOTE FOR DEVELOPERS:
076             *
077             * Never modify or reference this class directly. All methods that expect a asset category model instance should use the {@link AssetCategory} interface instead.
078             */
079            public static final String TABLE_NAME = "AssetCategory";
080            public static final Object[][] TABLE_COLUMNS = {
081                            { "uuid_", Types.VARCHAR },
082                            { "categoryId", Types.BIGINT },
083                            { "groupId", Types.BIGINT },
084                            { "companyId", Types.BIGINT },
085                            { "userId", Types.BIGINT },
086                            { "userName", Types.VARCHAR },
087                            { "createDate", Types.TIMESTAMP },
088                            { "modifiedDate", Types.TIMESTAMP },
089                            { "parentCategoryId", Types.BIGINT },
090                            { "leftCategoryId", Types.BIGINT },
091                            { "rightCategoryId", Types.BIGINT },
092                            { "name", Types.VARCHAR },
093                            { "title", Types.VARCHAR },
094                            { "description", Types.VARCHAR },
095                            { "vocabularyId", Types.BIGINT },
096                            { "lastPublishDate", Types.TIMESTAMP }
097                    };
098            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
099    
100            static {
101                    TABLE_COLUMNS_MAP.put("uuid_", Types.VARCHAR);
102                    TABLE_COLUMNS_MAP.put("categoryId", Types.BIGINT);
103                    TABLE_COLUMNS_MAP.put("groupId", Types.BIGINT);
104                    TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT);
105                    TABLE_COLUMNS_MAP.put("userId", Types.BIGINT);
106                    TABLE_COLUMNS_MAP.put("userName", Types.VARCHAR);
107                    TABLE_COLUMNS_MAP.put("createDate", Types.TIMESTAMP);
108                    TABLE_COLUMNS_MAP.put("modifiedDate", Types.TIMESTAMP);
109                    TABLE_COLUMNS_MAP.put("parentCategoryId", Types.BIGINT);
110                    TABLE_COLUMNS_MAP.put("leftCategoryId", Types.BIGINT);
111                    TABLE_COLUMNS_MAP.put("rightCategoryId", Types.BIGINT);
112                    TABLE_COLUMNS_MAP.put("name", Types.VARCHAR);
113                    TABLE_COLUMNS_MAP.put("title", Types.VARCHAR);
114                    TABLE_COLUMNS_MAP.put("description", Types.VARCHAR);
115                    TABLE_COLUMNS_MAP.put("vocabularyId", Types.BIGINT);
116                    TABLE_COLUMNS_MAP.put("lastPublishDate", Types.TIMESTAMP);
117            }
118    
119            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,description STRING null,vocabularyId LONG,lastPublishDate DATE null)";
120            public static final String TABLE_SQL_DROP = "drop table AssetCategory";
121            public static final String ORDER_BY_JPQL = " ORDER BY assetCategory.name ASC";
122            public static final String ORDER_BY_SQL = " ORDER BY AssetCategory.name ASC";
123            public static final String DATA_SOURCE = "liferayDataSource";
124            public static final String SESSION_FACTORY = "liferaySessionFactory";
125            public static final String TX_MANAGER = "liferayTransactionManager";
126            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
127                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetCategory"),
128                            true);
129            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
130                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetCategory"),
131                            true);
132            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
133                                    "value.object.column.bitmask.enabled.com.liferay.portlet.asset.model.AssetCategory"),
134                            true);
135            public static final long COMPANYID_COLUMN_BITMASK = 1L;
136            public static final long GROUPID_COLUMN_BITMASK = 2L;
137            public static final long NAME_COLUMN_BITMASK = 4L;
138            public static final long PARENTCATEGORYID_COLUMN_BITMASK = 8L;
139            public static final long UUID_COLUMN_BITMASK = 16L;
140            public static final long VOCABULARYID_COLUMN_BITMASK = 32L;
141    
142            /**
143             * Converts the soap model instance into a normal model instance.
144             *
145             * @param soapModel the soap model instance to convert
146             * @return the normal model instance
147             */
148            public static AssetCategory toModel(AssetCategorySoap soapModel) {
149                    if (soapModel == null) {
150                            return null;
151                    }
152    
153                    AssetCategory model = new AssetCategoryImpl();
154    
155                    model.setUuid(soapModel.getUuid());
156                    model.setCategoryId(soapModel.getCategoryId());
157                    model.setGroupId(soapModel.getGroupId());
158                    model.setCompanyId(soapModel.getCompanyId());
159                    model.setUserId(soapModel.getUserId());
160                    model.setUserName(soapModel.getUserName());
161                    model.setCreateDate(soapModel.getCreateDate());
162                    model.setModifiedDate(soapModel.getModifiedDate());
163                    model.setParentCategoryId(soapModel.getParentCategoryId());
164                    model.setLeftCategoryId(soapModel.getLeftCategoryId());
165                    model.setRightCategoryId(soapModel.getRightCategoryId());
166                    model.setName(soapModel.getName());
167                    model.setTitle(soapModel.getTitle());
168                    model.setDescription(soapModel.getDescription());
169                    model.setVocabularyId(soapModel.getVocabularyId());
170                    model.setLastPublishDate(soapModel.getLastPublishDate());
171    
172                    return model;
173            }
174    
175            /**
176             * Converts the soap model instances into normal model instances.
177             *
178             * @param soapModels the soap model instances to convert
179             * @return the normal model instances
180             */
181            public static List<AssetCategory> toModels(AssetCategorySoap[] soapModels) {
182                    if (soapModels == null) {
183                            return null;
184                    }
185    
186                    List<AssetCategory> models = new ArrayList<AssetCategory>(soapModels.length);
187    
188                    for (AssetCategorySoap soapModel : soapModels) {
189                            models.add(toModel(soapModel));
190                    }
191    
192                    return models;
193            }
194    
195            public static final String MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_NAME = "AssetEntries_AssetCategories";
196            public static final Object[][] MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_COLUMNS =
197                    {
198                            { "companyId", Types.BIGINT },
199                            { "categoryId", Types.BIGINT },
200                            { "entryId", Types.BIGINT }
201                    };
202            public static final String MAPPING_TABLE_ASSETENTRIES_ASSETCATEGORIES_SQL_CREATE =
203                    "create table AssetEntries_AssetCategories (companyId LONG not null,categoryId LONG not null,entryId LONG not null,primary key (categoryId, entryId))";
204            public static final boolean FINDER_CACHE_ENABLED_ASSETENTRIES_ASSETCATEGORIES =
205                    GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
206                                    "value.object.finder.cache.enabled.AssetEntries_AssetCategories"),
207                            true);
208            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
209                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetCategory"));
210    
211            public AssetCategoryModelImpl() {
212            }
213    
214            @Override
215            public long getPrimaryKey() {
216                    return _categoryId;
217            }
218    
219            @Override
220            public void setPrimaryKey(long primaryKey) {
221                    setCategoryId(primaryKey);
222            }
223    
224            @Override
225            public Serializable getPrimaryKeyObj() {
226                    return _categoryId;
227            }
228    
229            @Override
230            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
231                    setPrimaryKey(((Long)primaryKeyObj).longValue());
232            }
233    
234            @Override
235            public Class<?> getModelClass() {
236                    return AssetCategory.class;
237            }
238    
239            @Override
240            public String getModelClassName() {
241                    return AssetCategory.class.getName();
242            }
243    
244            @Override
245            public Map<String, Object> getModelAttributes() {
246                    Map<String, Object> attributes = new HashMap<String, Object>();
247    
248                    attributes.put("uuid", getUuid());
249                    attributes.put("categoryId", getCategoryId());
250                    attributes.put("groupId", getGroupId());
251                    attributes.put("companyId", getCompanyId());
252                    attributes.put("userId", getUserId());
253                    attributes.put("userName", getUserName());
254                    attributes.put("createDate", getCreateDate());
255                    attributes.put("modifiedDate", getModifiedDate());
256                    attributes.put("parentCategoryId", getParentCategoryId());
257                    attributes.put("leftCategoryId", getLeftCategoryId());
258                    attributes.put("rightCategoryId", getRightCategoryId());
259                    attributes.put("name", getName());
260                    attributes.put("title", getTitle());
261                    attributes.put("description", getDescription());
262                    attributes.put("vocabularyId", getVocabularyId());
263                    attributes.put("lastPublishDate", getLastPublishDate());
264    
265                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
266                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
267    
268                    return attributes;
269            }
270    
271            @Override
272            public void setModelAttributes(Map<String, Object> attributes) {
273                    String uuid = (String)attributes.get("uuid");
274    
275                    if (uuid != null) {
276                            setUuid(uuid);
277                    }
278    
279                    Long categoryId = (Long)attributes.get("categoryId");
280    
281                    if (categoryId != null) {
282                            setCategoryId(categoryId);
283                    }
284    
285                    Long groupId = (Long)attributes.get("groupId");
286    
287                    if (groupId != null) {
288                            setGroupId(groupId);
289                    }
290    
291                    Long companyId = (Long)attributes.get("companyId");
292    
293                    if (companyId != null) {
294                            setCompanyId(companyId);
295                    }
296    
297                    Long userId = (Long)attributes.get("userId");
298    
299                    if (userId != null) {
300                            setUserId(userId);
301                    }
302    
303                    String userName = (String)attributes.get("userName");
304    
305                    if (userName != null) {
306                            setUserName(userName);
307                    }
308    
309                    Date createDate = (Date)attributes.get("createDate");
310    
311                    if (createDate != null) {
312                            setCreateDate(createDate);
313                    }
314    
315                    Date modifiedDate = (Date)attributes.get("modifiedDate");
316    
317                    if (modifiedDate != null) {
318                            setModifiedDate(modifiedDate);
319                    }
320    
321                    Long parentCategoryId = (Long)attributes.get("parentCategoryId");
322    
323                    if (parentCategoryId != null) {
324                            setParentCategoryId(parentCategoryId);
325                    }
326    
327                    Long leftCategoryId = (Long)attributes.get("leftCategoryId");
328    
329                    if (leftCategoryId != null) {
330                            setLeftCategoryId(leftCategoryId);
331                    }
332    
333                    Long rightCategoryId = (Long)attributes.get("rightCategoryId");
334    
335                    if (rightCategoryId != null) {
336                            setRightCategoryId(rightCategoryId);
337                    }
338    
339                    String name = (String)attributes.get("name");
340    
341                    if (name != null) {
342                            setName(name);
343                    }
344    
345                    String title = (String)attributes.get("title");
346    
347                    if (title != null) {
348                            setTitle(title);
349                    }
350    
351                    String description = (String)attributes.get("description");
352    
353                    if (description != null) {
354                            setDescription(description);
355                    }
356    
357                    Long vocabularyId = (Long)attributes.get("vocabularyId");
358    
359                    if (vocabularyId != null) {
360                            setVocabularyId(vocabularyId);
361                    }
362    
363                    Date lastPublishDate = (Date)attributes.get("lastPublishDate");
364    
365                    if (lastPublishDate != null) {
366                            setLastPublishDate(lastPublishDate);
367                    }
368            }
369    
370            @JSON
371            @Override
372            public String getUuid() {
373                    if (_uuid == null) {
374                            return StringPool.BLANK;
375                    }
376                    else {
377                            return _uuid;
378                    }
379            }
380    
381            @Override
382            public void setUuid(String uuid) {
383                    if (_originalUuid == null) {
384                            _originalUuid = _uuid;
385                    }
386    
387                    _uuid = uuid;
388            }
389    
390            public String getOriginalUuid() {
391                    return GetterUtil.getString(_originalUuid);
392            }
393    
394            @JSON
395            @Override
396            public long getCategoryId() {
397                    return _categoryId;
398            }
399    
400            @Override
401            public void setCategoryId(long categoryId) {
402                    _categoryId = categoryId;
403            }
404    
405            @JSON
406            @Override
407            public long getGroupId() {
408                    return _groupId;
409            }
410    
411            @Override
412            public void setGroupId(long groupId) {
413                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
414    
415                    if (!_setOriginalGroupId) {
416                            _setOriginalGroupId = true;
417    
418                            _originalGroupId = _groupId;
419                    }
420    
421                    _groupId = groupId;
422            }
423    
424            public long getOriginalGroupId() {
425                    return _originalGroupId;
426            }
427    
428            @JSON
429            @Override
430            public long getCompanyId() {
431                    return _companyId;
432            }
433    
434            @Override
435            public void setCompanyId(long companyId) {
436                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
437    
438                    if (!_setOriginalCompanyId) {
439                            _setOriginalCompanyId = true;
440    
441                            _originalCompanyId = _companyId;
442                    }
443    
444                    _companyId = companyId;
445            }
446    
447            public long getOriginalCompanyId() {
448                    return _originalCompanyId;
449            }
450    
451            @JSON
452            @Override
453            public long getUserId() {
454                    return _userId;
455            }
456    
457            @Override
458            public void setUserId(long userId) {
459                    _userId = userId;
460            }
461    
462            @Override
463            public String getUserUuid() {
464                    try {
465                            User user = UserLocalServiceUtil.getUserById(getUserId());
466    
467                            return user.getUuid();
468                    }
469                    catch (PortalException pe) {
470                            return StringPool.BLANK;
471                    }
472            }
473    
474            @Override
475            public void setUserUuid(String userUuid) {
476            }
477    
478            @JSON
479            @Override
480            public String getUserName() {
481                    if (_userName == null) {
482                            return StringPool.BLANK;
483                    }
484                    else {
485                            return _userName;
486                    }
487            }
488    
489            @Override
490            public void setUserName(String userName) {
491                    _userName = userName;
492            }
493    
494            @JSON
495            @Override
496            public Date getCreateDate() {
497                    return _createDate;
498            }
499    
500            @Override
501            public void setCreateDate(Date createDate) {
502                    _createDate = createDate;
503            }
504    
505            @JSON
506            @Override
507            public Date getModifiedDate() {
508                    return _modifiedDate;
509            }
510    
511            public boolean hasSetModifiedDate() {
512                    return _setModifiedDate;
513            }
514    
515            @Override
516            public void setModifiedDate(Date modifiedDate) {
517                    _setModifiedDate = true;
518    
519                    _modifiedDate = modifiedDate;
520            }
521    
522            @JSON
523            @Override
524            public long getParentCategoryId() {
525                    return _parentCategoryId;
526            }
527    
528            @Override
529            public void setParentCategoryId(long parentCategoryId) {
530                    _columnBitmask |= PARENTCATEGORYID_COLUMN_BITMASK;
531    
532                    if (!_setOriginalParentCategoryId) {
533                            _setOriginalParentCategoryId = true;
534    
535                            _originalParentCategoryId = _parentCategoryId;
536                    }
537    
538                    _parentCategoryId = parentCategoryId;
539            }
540    
541            public long getOriginalParentCategoryId() {
542                    return _originalParentCategoryId;
543            }
544    
545            @JSON
546            @Override
547            public long getLeftCategoryId() {
548                    return _leftCategoryId;
549            }
550    
551            @Override
552            public void setLeftCategoryId(long leftCategoryId) {
553                    _leftCategoryId = leftCategoryId;
554            }
555    
556            @JSON
557            @Override
558            public long getRightCategoryId() {
559                    return _rightCategoryId;
560            }
561    
562            @Override
563            public void setRightCategoryId(long rightCategoryId) {
564                    _rightCategoryId = rightCategoryId;
565            }
566    
567            @JSON
568            @Override
569            public String getName() {
570                    if (_name == null) {
571                            return StringPool.BLANK;
572                    }
573                    else {
574                            return _name;
575                    }
576            }
577    
578            @Override
579            public void setName(String name) {
580                    _columnBitmask = -1L;
581    
582                    if (_originalName == null) {
583                            _originalName = _name;
584                    }
585    
586                    _name = name;
587            }
588    
589            public String getOriginalName() {
590                    return GetterUtil.getString(_originalName);
591            }
592    
593            @JSON
594            @Override
595            public String getTitle() {
596                    if (_title == null) {
597                            return StringPool.BLANK;
598                    }
599                    else {
600                            return _title;
601                    }
602            }
603    
604            @Override
605            public String getTitle(Locale locale) {
606                    String languageId = LocaleUtil.toLanguageId(locale);
607    
608                    return getTitle(languageId);
609            }
610    
611            @Override
612            public String getTitle(Locale locale, boolean useDefault) {
613                    String languageId = LocaleUtil.toLanguageId(locale);
614    
615                    return getTitle(languageId, useDefault);
616            }
617    
618            @Override
619            public String getTitle(String languageId) {
620                    return LocalizationUtil.getLocalization(getTitle(), languageId);
621            }
622    
623            @Override
624            public String getTitle(String languageId, boolean useDefault) {
625                    return LocalizationUtil.getLocalization(getTitle(), languageId,
626                            useDefault);
627            }
628    
629            @Override
630            public String getTitleCurrentLanguageId() {
631                    return _titleCurrentLanguageId;
632            }
633    
634            @JSON
635            @Override
636            public String getTitleCurrentValue() {
637                    Locale locale = getLocale(_titleCurrentLanguageId);
638    
639                    return getTitle(locale);
640            }
641    
642            @Override
643            public Map<Locale, String> getTitleMap() {
644                    return LocalizationUtil.getLocalizationMap(getTitle());
645            }
646    
647            @Override
648            public void setTitle(String title) {
649                    _title = title;
650            }
651    
652            @Override
653            public void setTitle(String title, Locale locale) {
654                    setTitle(title, locale, LocaleUtil.getSiteDefault());
655            }
656    
657            @Override
658            public void setTitle(String title, Locale locale, Locale defaultLocale) {
659                    String languageId = LocaleUtil.toLanguageId(locale);
660                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
661    
662                    if (Validator.isNotNull(title)) {
663                            setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
664                                            title, languageId, defaultLanguageId));
665                    }
666                    else {
667                            setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
668                                            languageId));
669                    }
670            }
671    
672            @Override
673            public void setTitleCurrentLanguageId(String languageId) {
674                    _titleCurrentLanguageId = languageId;
675            }
676    
677            @Override
678            public void setTitleMap(Map<Locale, String> titleMap) {
679                    setTitleMap(titleMap, LocaleUtil.getSiteDefault());
680            }
681    
682            @Override
683            public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
684                    if (titleMap == null) {
685                            return;
686                    }
687    
688                    setTitle(LocalizationUtil.updateLocalization(titleMap, getTitle(),
689                                    "Title", LocaleUtil.toLanguageId(defaultLocale)));
690            }
691    
692            @JSON
693            @Override
694            public String getDescription() {
695                    if (_description == null) {
696                            return StringPool.BLANK;
697                    }
698                    else {
699                            return _description;
700                    }
701            }
702    
703            @Override
704            public String getDescription(Locale locale) {
705                    String languageId = LocaleUtil.toLanguageId(locale);
706    
707                    return getDescription(languageId);
708            }
709    
710            @Override
711            public String getDescription(Locale locale, boolean useDefault) {
712                    String languageId = LocaleUtil.toLanguageId(locale);
713    
714                    return getDescription(languageId, useDefault);
715            }
716    
717            @Override
718            public String getDescription(String languageId) {
719                    return LocalizationUtil.getLocalization(getDescription(), languageId);
720            }
721    
722            @Override
723            public String getDescription(String languageId, boolean useDefault) {
724                    return LocalizationUtil.getLocalization(getDescription(), languageId,
725                            useDefault);
726            }
727    
728            @Override
729            public String getDescriptionCurrentLanguageId() {
730                    return _descriptionCurrentLanguageId;
731            }
732    
733            @JSON
734            @Override
735            public String getDescriptionCurrentValue() {
736                    Locale locale = getLocale(_descriptionCurrentLanguageId);
737    
738                    return getDescription(locale);
739            }
740    
741            @Override
742            public Map<Locale, String> getDescriptionMap() {
743                    return LocalizationUtil.getLocalizationMap(getDescription());
744            }
745    
746            @Override
747            public void setDescription(String description) {
748                    _description = description;
749            }
750    
751            @Override
752            public void setDescription(String description, Locale locale) {
753                    setDescription(description, locale, LocaleUtil.getSiteDefault());
754            }
755    
756            @Override
757            public void setDescription(String description, Locale locale,
758                    Locale defaultLocale) {
759                    String languageId = LocaleUtil.toLanguageId(locale);
760                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
761    
762                    if (Validator.isNotNull(description)) {
763                            setDescription(LocalizationUtil.updateLocalization(
764                                            getDescription(), "Description", description, languageId,
765                                            defaultLanguageId));
766                    }
767                    else {
768                            setDescription(LocalizationUtil.removeLocalization(
769                                            getDescription(), "Description", languageId));
770                    }
771            }
772    
773            @Override
774            public void setDescriptionCurrentLanguageId(String languageId) {
775                    _descriptionCurrentLanguageId = languageId;
776            }
777    
778            @Override
779            public void setDescriptionMap(Map<Locale, String> descriptionMap) {
780                    setDescriptionMap(descriptionMap, LocaleUtil.getSiteDefault());
781            }
782    
783            @Override
784            public void setDescriptionMap(Map<Locale, String> descriptionMap,
785                    Locale defaultLocale) {
786                    if (descriptionMap == null) {
787                            return;
788                    }
789    
790                    setDescription(LocalizationUtil.updateLocalization(descriptionMap,
791                                    getDescription(), "Description",
792                                    LocaleUtil.toLanguageId(defaultLocale)));
793            }
794    
795            @JSON
796            @Override
797            public long getVocabularyId() {
798                    return _vocabularyId;
799            }
800    
801            @Override
802            public void setVocabularyId(long vocabularyId) {
803                    _columnBitmask |= VOCABULARYID_COLUMN_BITMASK;
804    
805                    if (!_setOriginalVocabularyId) {
806                            _setOriginalVocabularyId = true;
807    
808                            _originalVocabularyId = _vocabularyId;
809                    }
810    
811                    _vocabularyId = vocabularyId;
812            }
813    
814            public long getOriginalVocabularyId() {
815                    return _originalVocabularyId;
816            }
817    
818            @JSON
819            @Override
820            public Date getLastPublishDate() {
821                    return _lastPublishDate;
822            }
823    
824            @Override
825            public void setLastPublishDate(Date lastPublishDate) {
826                    _lastPublishDate = lastPublishDate;
827            }
828    
829            public long getNestedSetsTreeNodeLeft() {
830                    return _leftCategoryId;
831            }
832    
833            public long getNestedSetsTreeNodeRight() {
834                    return _rightCategoryId;
835            }
836    
837            public long getNestedSetsTreeNodeScopeId() {
838                    return _groupId;
839            }
840    
841            public void setNestedSetsTreeNodeLeft(long nestedSetsTreeNodeLeft) {
842                    _leftCategoryId = nestedSetsTreeNodeLeft;
843            }
844    
845            public void setNestedSetsTreeNodeRight(long nestedSetsTreeNodeRight) {
846                    _rightCategoryId = nestedSetsTreeNodeRight;
847            }
848    
849            @Override
850            public StagedModelType getStagedModelType() {
851                    return new StagedModelType(PortalUtil.getClassNameId(
852                                    AssetCategory.class.getName()));
853            }
854    
855            public long getColumnBitmask() {
856                    return _columnBitmask;
857            }
858    
859            @Override
860            public ExpandoBridge getExpandoBridge() {
861                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
862                            AssetCategory.class.getName(), getPrimaryKey());
863            }
864    
865            @Override
866            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
867                    ExpandoBridge expandoBridge = getExpandoBridge();
868    
869                    expandoBridge.setAttributes(serviceContext);
870            }
871    
872            @Override
873            public String[] getAvailableLanguageIds() {
874                    Set<String> availableLanguageIds = new TreeSet<String>();
875    
876                    Map<Locale, String> titleMap = getTitleMap();
877    
878                    for (Map.Entry<Locale, String> entry : titleMap.entrySet()) {
879                            Locale locale = entry.getKey();
880                            String value = entry.getValue();
881    
882                            if (Validator.isNotNull(value)) {
883                                    availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
884                            }
885                    }
886    
887                    Map<Locale, String> descriptionMap = getDescriptionMap();
888    
889                    for (Map.Entry<Locale, String> entry : descriptionMap.entrySet()) {
890                            Locale locale = entry.getKey();
891                            String value = entry.getValue();
892    
893                            if (Validator.isNotNull(value)) {
894                                    availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
895                            }
896                    }
897    
898                    return availableLanguageIds.toArray(new String[availableLanguageIds.size()]);
899            }
900    
901            @Override
902            public String getDefaultLanguageId() {
903                    String xml = getTitle();
904    
905                    if (xml == null) {
906                            return StringPool.BLANK;
907                    }
908    
909                    Locale defaultLocale = LocaleUtil.getSiteDefault();
910    
911                    return LocalizationUtil.getDefaultLanguageId(xml, defaultLocale);
912            }
913    
914            @Override
915            public void prepareLocalizedFieldsForImport() throws LocaleException {
916                    Locale defaultLocale = LocaleUtil.fromLanguageId(getDefaultLanguageId());
917    
918                    Locale[] availableLocales = LocaleUtil.fromLanguageIds(getAvailableLanguageIds());
919    
920                    Locale defaultImportLocale = LocalizationUtil.getDefaultImportLocale(AssetCategory.class.getName(),
921                                    getPrimaryKey(), defaultLocale, availableLocales);
922    
923                    prepareLocalizedFieldsForImport(defaultImportLocale);
924            }
925    
926            @Override
927            @SuppressWarnings("unused")
928            public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
929                    throws LocaleException {
930                    Locale defaultLocale = LocaleUtil.getSiteDefault();
931    
932                    String modelDefaultLanguageId = getDefaultLanguageId();
933    
934                    String title = getTitle(defaultLocale);
935    
936                    if (Validator.isNull(title)) {
937                            setTitle(getTitle(modelDefaultLanguageId), defaultLocale);
938                    }
939                    else {
940                            setTitle(getTitle(defaultLocale), defaultLocale, defaultLocale);
941                    }
942    
943                    String description = getDescription(defaultLocale);
944    
945                    if (Validator.isNull(description)) {
946                            setDescription(getDescription(modelDefaultLanguageId), defaultLocale);
947                    }
948                    else {
949                            setDescription(getDescription(defaultLocale), defaultLocale,
950                                    defaultLocale);
951                    }
952            }
953    
954            @Override
955            public AssetCategory toEscapedModel() {
956                    if (_escapedModel == null) {
957                            _escapedModel = (AssetCategory)ProxyUtil.newProxyInstance(_classLoader,
958                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
959                    }
960    
961                    return _escapedModel;
962            }
963    
964            @Override
965            public Object clone() {
966                    AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
967    
968                    assetCategoryImpl.setUuid(getUuid());
969                    assetCategoryImpl.setCategoryId(getCategoryId());
970                    assetCategoryImpl.setGroupId(getGroupId());
971                    assetCategoryImpl.setCompanyId(getCompanyId());
972                    assetCategoryImpl.setUserId(getUserId());
973                    assetCategoryImpl.setUserName(getUserName());
974                    assetCategoryImpl.setCreateDate(getCreateDate());
975                    assetCategoryImpl.setModifiedDate(getModifiedDate());
976                    assetCategoryImpl.setParentCategoryId(getParentCategoryId());
977                    assetCategoryImpl.setLeftCategoryId(getLeftCategoryId());
978                    assetCategoryImpl.setRightCategoryId(getRightCategoryId());
979                    assetCategoryImpl.setName(getName());
980                    assetCategoryImpl.setTitle(getTitle());
981                    assetCategoryImpl.setDescription(getDescription());
982                    assetCategoryImpl.setVocabularyId(getVocabularyId());
983                    assetCategoryImpl.setLastPublishDate(getLastPublishDate());
984    
985                    assetCategoryImpl.resetOriginalValues();
986    
987                    return assetCategoryImpl;
988            }
989    
990            @Override
991            public int compareTo(AssetCategory assetCategory) {
992                    int value = 0;
993    
994                    value = getName().compareTo(assetCategory.getName());
995    
996                    if (value != 0) {
997                            return value;
998                    }
999    
1000                    return 0;
1001            }
1002    
1003            @Override
1004            public boolean equals(Object obj) {
1005                    if (this == obj) {
1006                            return true;
1007                    }
1008    
1009                    if (!(obj instanceof AssetCategory)) {
1010                            return false;
1011                    }
1012    
1013                    AssetCategory assetCategory = (AssetCategory)obj;
1014    
1015                    long primaryKey = assetCategory.getPrimaryKey();
1016    
1017                    if (getPrimaryKey() == primaryKey) {
1018                            return true;
1019                    }
1020                    else {
1021                            return false;
1022                    }
1023            }
1024    
1025            @Override
1026            public int hashCode() {
1027                    return (int)getPrimaryKey();
1028            }
1029    
1030            @Override
1031            public boolean isEntityCacheEnabled() {
1032                    return ENTITY_CACHE_ENABLED;
1033            }
1034    
1035            @Override
1036            public boolean isFinderCacheEnabled() {
1037                    return FINDER_CACHE_ENABLED;
1038            }
1039    
1040            @Override
1041            public void resetOriginalValues() {
1042                    AssetCategoryModelImpl assetCategoryModelImpl = this;
1043    
1044                    assetCategoryModelImpl._originalUuid = assetCategoryModelImpl._uuid;
1045    
1046                    assetCategoryModelImpl._originalGroupId = assetCategoryModelImpl._groupId;
1047    
1048                    assetCategoryModelImpl._setOriginalGroupId = false;
1049    
1050                    assetCategoryModelImpl._originalCompanyId = assetCategoryModelImpl._companyId;
1051    
1052                    assetCategoryModelImpl._setOriginalCompanyId = false;
1053    
1054                    assetCategoryModelImpl._setModifiedDate = false;
1055    
1056                    assetCategoryModelImpl._originalParentCategoryId = assetCategoryModelImpl._parentCategoryId;
1057    
1058                    assetCategoryModelImpl._setOriginalParentCategoryId = false;
1059    
1060                    assetCategoryModelImpl._originalName = assetCategoryModelImpl._name;
1061    
1062                    assetCategoryModelImpl._originalVocabularyId = assetCategoryModelImpl._vocabularyId;
1063    
1064                    assetCategoryModelImpl._setOriginalVocabularyId = false;
1065    
1066                    assetCategoryModelImpl._columnBitmask = 0;
1067            }
1068    
1069            @Override
1070            public CacheModel<AssetCategory> toCacheModel() {
1071                    AssetCategoryCacheModel assetCategoryCacheModel = new AssetCategoryCacheModel();
1072    
1073                    assetCategoryCacheModel.uuid = getUuid();
1074    
1075                    String uuid = assetCategoryCacheModel.uuid;
1076    
1077                    if ((uuid != null) && (uuid.length() == 0)) {
1078                            assetCategoryCacheModel.uuid = null;
1079                    }
1080    
1081                    assetCategoryCacheModel.categoryId = getCategoryId();
1082    
1083                    assetCategoryCacheModel.groupId = getGroupId();
1084    
1085                    assetCategoryCacheModel.companyId = getCompanyId();
1086    
1087                    assetCategoryCacheModel.userId = getUserId();
1088    
1089                    assetCategoryCacheModel.userName = getUserName();
1090    
1091                    String userName = assetCategoryCacheModel.userName;
1092    
1093                    if ((userName != null) && (userName.length() == 0)) {
1094                            assetCategoryCacheModel.userName = null;
1095                    }
1096    
1097                    Date createDate = getCreateDate();
1098    
1099                    if (createDate != null) {
1100                            assetCategoryCacheModel.createDate = createDate.getTime();
1101                    }
1102                    else {
1103                            assetCategoryCacheModel.createDate = Long.MIN_VALUE;
1104                    }
1105    
1106                    Date modifiedDate = getModifiedDate();
1107    
1108                    if (modifiedDate != null) {
1109                            assetCategoryCacheModel.modifiedDate = modifiedDate.getTime();
1110                    }
1111                    else {
1112                            assetCategoryCacheModel.modifiedDate = Long.MIN_VALUE;
1113                    }
1114    
1115                    assetCategoryCacheModel.parentCategoryId = getParentCategoryId();
1116    
1117                    assetCategoryCacheModel.leftCategoryId = getLeftCategoryId();
1118    
1119                    assetCategoryCacheModel.rightCategoryId = getRightCategoryId();
1120    
1121                    assetCategoryCacheModel.name = getName();
1122    
1123                    String name = assetCategoryCacheModel.name;
1124    
1125                    if ((name != null) && (name.length() == 0)) {
1126                            assetCategoryCacheModel.name = null;
1127                    }
1128    
1129                    assetCategoryCacheModel.title = getTitle();
1130    
1131                    String title = assetCategoryCacheModel.title;
1132    
1133                    if ((title != null) && (title.length() == 0)) {
1134                            assetCategoryCacheModel.title = null;
1135                    }
1136    
1137                    assetCategoryCacheModel.description = getDescription();
1138    
1139                    String description = assetCategoryCacheModel.description;
1140    
1141                    if ((description != null) && (description.length() == 0)) {
1142                            assetCategoryCacheModel.description = null;
1143                    }
1144    
1145                    assetCategoryCacheModel.vocabularyId = getVocabularyId();
1146    
1147                    Date lastPublishDate = getLastPublishDate();
1148    
1149                    if (lastPublishDate != null) {
1150                            assetCategoryCacheModel.lastPublishDate = lastPublishDate.getTime();
1151                    }
1152                    else {
1153                            assetCategoryCacheModel.lastPublishDate = Long.MIN_VALUE;
1154                    }
1155    
1156                    return assetCategoryCacheModel;
1157            }
1158    
1159            @Override
1160            public String toString() {
1161                    StringBundler sb = new StringBundler(33);
1162    
1163                    sb.append("{uuid=");
1164                    sb.append(getUuid());
1165                    sb.append(", categoryId=");
1166                    sb.append(getCategoryId());
1167                    sb.append(", groupId=");
1168                    sb.append(getGroupId());
1169                    sb.append(", companyId=");
1170                    sb.append(getCompanyId());
1171                    sb.append(", userId=");
1172                    sb.append(getUserId());
1173                    sb.append(", userName=");
1174                    sb.append(getUserName());
1175                    sb.append(", createDate=");
1176                    sb.append(getCreateDate());
1177                    sb.append(", modifiedDate=");
1178                    sb.append(getModifiedDate());
1179                    sb.append(", parentCategoryId=");
1180                    sb.append(getParentCategoryId());
1181                    sb.append(", leftCategoryId=");
1182                    sb.append(getLeftCategoryId());
1183                    sb.append(", rightCategoryId=");
1184                    sb.append(getRightCategoryId());
1185                    sb.append(", name=");
1186                    sb.append(getName());
1187                    sb.append(", title=");
1188                    sb.append(getTitle());
1189                    sb.append(", description=");
1190                    sb.append(getDescription());
1191                    sb.append(", vocabularyId=");
1192                    sb.append(getVocabularyId());
1193                    sb.append(", lastPublishDate=");
1194                    sb.append(getLastPublishDate());
1195                    sb.append("}");
1196    
1197                    return sb.toString();
1198            }
1199    
1200            @Override
1201            public String toXmlString() {
1202                    StringBundler sb = new StringBundler(52);
1203    
1204                    sb.append("<model><model-name>");
1205                    sb.append("com.liferay.portlet.asset.model.AssetCategory");
1206                    sb.append("</model-name>");
1207    
1208                    sb.append(
1209                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
1210                    sb.append(getUuid());
1211                    sb.append("]]></column-value></column>");
1212                    sb.append(
1213                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
1214                    sb.append(getCategoryId());
1215                    sb.append("]]></column-value></column>");
1216                    sb.append(
1217                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
1218                    sb.append(getGroupId());
1219                    sb.append("]]></column-value></column>");
1220                    sb.append(
1221                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
1222                    sb.append(getCompanyId());
1223                    sb.append("]]></column-value></column>");
1224                    sb.append(
1225                            "<column><column-name>userId</column-name><column-value><![CDATA[");
1226                    sb.append(getUserId());
1227                    sb.append("]]></column-value></column>");
1228                    sb.append(
1229                            "<column><column-name>userName</column-name><column-value><![CDATA[");
1230                    sb.append(getUserName());
1231                    sb.append("]]></column-value></column>");
1232                    sb.append(
1233                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
1234                    sb.append(getCreateDate());
1235                    sb.append("]]></column-value></column>");
1236                    sb.append(
1237                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1238                    sb.append(getModifiedDate());
1239                    sb.append("]]></column-value></column>");
1240                    sb.append(
1241                            "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
1242                    sb.append(getParentCategoryId());
1243                    sb.append("]]></column-value></column>");
1244                    sb.append(
1245                            "<column><column-name>leftCategoryId</column-name><column-value><![CDATA[");
1246                    sb.append(getLeftCategoryId());
1247                    sb.append("]]></column-value></column>");
1248                    sb.append(
1249                            "<column><column-name>rightCategoryId</column-name><column-value><![CDATA[");
1250                    sb.append(getRightCategoryId());
1251                    sb.append("]]></column-value></column>");
1252                    sb.append(
1253                            "<column><column-name>name</column-name><column-value><![CDATA[");
1254                    sb.append(getName());
1255                    sb.append("]]></column-value></column>");
1256                    sb.append(
1257                            "<column><column-name>title</column-name><column-value><![CDATA[");
1258                    sb.append(getTitle());
1259                    sb.append("]]></column-value></column>");
1260                    sb.append(
1261                            "<column><column-name>description</column-name><column-value><![CDATA[");
1262                    sb.append(getDescription());
1263                    sb.append("]]></column-value></column>");
1264                    sb.append(
1265                            "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
1266                    sb.append(getVocabularyId());
1267                    sb.append("]]></column-value></column>");
1268                    sb.append(
1269                            "<column><column-name>lastPublishDate</column-name><column-value><![CDATA[");
1270                    sb.append(getLastPublishDate());
1271                    sb.append("]]></column-value></column>");
1272    
1273                    sb.append("</model>");
1274    
1275                    return sb.toString();
1276            }
1277    
1278            private static final ClassLoader _classLoader = AssetCategory.class.getClassLoader();
1279            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
1280                            AssetCategory.class
1281                    };
1282            private String _uuid;
1283            private String _originalUuid;
1284            private long _categoryId;
1285            private long _groupId;
1286            private long _originalGroupId;
1287            private boolean _setOriginalGroupId;
1288            private long _companyId;
1289            private long _originalCompanyId;
1290            private boolean _setOriginalCompanyId;
1291            private long _userId;
1292            private String _userName;
1293            private Date _createDate;
1294            private Date _modifiedDate;
1295            private boolean _setModifiedDate;
1296            private long _parentCategoryId;
1297            private long _originalParentCategoryId;
1298            private boolean _setOriginalParentCategoryId;
1299            private long _leftCategoryId;
1300            private long _rightCategoryId;
1301            private String _name;
1302            private String _originalName;
1303            private String _title;
1304            private String _titleCurrentLanguageId;
1305            private String _description;
1306            private String _descriptionCurrentLanguageId;
1307            private long _vocabularyId;
1308            private long _originalVocabularyId;
1309            private boolean _setOriginalVocabularyId;
1310            private Date _lastPublishDate;
1311            private long _columnBitmask;
1312            private AssetCategory _escapedModel;
1313    }