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