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.lar.StagedModelType;
024    import com.liferay.portal.kernel.util.GetterUtil;
025    import com.liferay.portal.kernel.util.LocaleUtil;
026    import com.liferay.portal.kernel.util.LocalizationUtil;
027    import com.liferay.portal.kernel.util.ProxyUtil;
028    import com.liferay.portal.kernel.util.StringBundler;
029    import com.liferay.portal.kernel.util.StringPool;
030    import com.liferay.portal.kernel.util.Validator;
031    import com.liferay.portal.model.CacheModel;
032    import com.liferay.portal.model.User;
033    import com.liferay.portal.model.impl.BaseModelImpl;
034    import com.liferay.portal.service.ServiceContext;
035    import com.liferay.portal.service.UserLocalServiceUtil;
036    import com.liferay.portal.util.PortalUtil;
037    
038    import com.liferay.portlet.asset.model.AssetCategory;
039    import com.liferay.portlet.asset.model.AssetCategoryModel;
040    import com.liferay.portlet.asset.model.AssetCategorySoap;
041    import com.liferay.portlet.expando.model.ExpandoBridge;
042    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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 com.liferay.portlet.asset.model.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 com.liferay.portlet.asset.model.AssetCategory
067     * @see com.liferay.portlet.asset.model.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 com.liferay.portlet.asset.model.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            @Override
481            public void setModifiedDate(Date modifiedDate) {
482                    _modifiedDate = modifiedDate;
483            }
484    
485            @JSON
486            @Override
487            public long getParentCategoryId() {
488                    return _parentCategoryId;
489            }
490    
491            @Override
492            public void setParentCategoryId(long parentCategoryId) {
493                    _columnBitmask |= PARENTCATEGORYID_COLUMN_BITMASK;
494    
495                    if (!_setOriginalParentCategoryId) {
496                            _setOriginalParentCategoryId = true;
497    
498                            _originalParentCategoryId = _parentCategoryId;
499                    }
500    
501                    _parentCategoryId = parentCategoryId;
502            }
503    
504            public long getOriginalParentCategoryId() {
505                    return _originalParentCategoryId;
506            }
507    
508            @JSON
509            @Override
510            public long getLeftCategoryId() {
511                    return _leftCategoryId;
512            }
513    
514            @Override
515            public void setLeftCategoryId(long leftCategoryId) {
516                    _leftCategoryId = leftCategoryId;
517            }
518    
519            @JSON
520            @Override
521            public long getRightCategoryId() {
522                    return _rightCategoryId;
523            }
524    
525            @Override
526            public void setRightCategoryId(long rightCategoryId) {
527                    _rightCategoryId = rightCategoryId;
528            }
529    
530            @JSON
531            @Override
532            public String getName() {
533                    if (_name == null) {
534                            return StringPool.BLANK;
535                    }
536                    else {
537                            return _name;
538                    }
539            }
540    
541            @Override
542            public void setName(String name) {
543                    _columnBitmask = -1L;
544    
545                    if (_originalName == null) {
546                            _originalName = _name;
547                    }
548    
549                    _name = name;
550            }
551    
552            public String getOriginalName() {
553                    return GetterUtil.getString(_originalName);
554            }
555    
556            @JSON
557            @Override
558            public String getTitle() {
559                    if (_title == null) {
560                            return StringPool.BLANK;
561                    }
562                    else {
563                            return _title;
564                    }
565            }
566    
567            @Override
568            public String getTitle(Locale locale) {
569                    String languageId = LocaleUtil.toLanguageId(locale);
570    
571                    return getTitle(languageId);
572            }
573    
574            @Override
575            public String getTitle(Locale locale, boolean useDefault) {
576                    String languageId = LocaleUtil.toLanguageId(locale);
577    
578                    return getTitle(languageId, useDefault);
579            }
580    
581            @Override
582            public String getTitle(String languageId) {
583                    return LocalizationUtil.getLocalization(getTitle(), languageId);
584            }
585    
586            @Override
587            public String getTitle(String languageId, boolean useDefault) {
588                    return LocalizationUtil.getLocalization(getTitle(), languageId,
589                            useDefault);
590            }
591    
592            @Override
593            public String getTitleCurrentLanguageId() {
594                    return _titleCurrentLanguageId;
595            }
596    
597            @JSON
598            @Override
599            public String getTitleCurrentValue() {
600                    Locale locale = getLocale(_titleCurrentLanguageId);
601    
602                    return getTitle(locale);
603            }
604    
605            @Override
606            public Map<Locale, String> getTitleMap() {
607                    return LocalizationUtil.getLocalizationMap(getTitle());
608            }
609    
610            @Override
611            public void setTitle(String title) {
612                    _title = title;
613            }
614    
615            @Override
616            public void setTitle(String title, Locale locale) {
617                    setTitle(title, locale, LocaleUtil.getSiteDefault());
618            }
619    
620            @Override
621            public void setTitle(String title, Locale locale, Locale defaultLocale) {
622                    String languageId = LocaleUtil.toLanguageId(locale);
623                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
624    
625                    if (Validator.isNotNull(title)) {
626                            setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
627                                            title, languageId, defaultLanguageId));
628                    }
629                    else {
630                            setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
631                                            languageId));
632                    }
633            }
634    
635            @Override
636            public void setTitleCurrentLanguageId(String languageId) {
637                    _titleCurrentLanguageId = languageId;
638            }
639    
640            @Override
641            public void setTitleMap(Map<Locale, String> titleMap) {
642                    setTitleMap(titleMap, LocaleUtil.getSiteDefault());
643            }
644    
645            @Override
646            public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
647                    if (titleMap == null) {
648                            return;
649                    }
650    
651                    setTitle(LocalizationUtil.updateLocalization(titleMap, getTitle(),
652                                    "Title", LocaleUtil.toLanguageId(defaultLocale)));
653            }
654    
655            @JSON
656            @Override
657            public String getDescription() {
658                    if (_description == null) {
659                            return StringPool.BLANK;
660                    }
661                    else {
662                            return _description;
663                    }
664            }
665    
666            @Override
667            public String getDescription(Locale locale) {
668                    String languageId = LocaleUtil.toLanguageId(locale);
669    
670                    return getDescription(languageId);
671            }
672    
673            @Override
674            public String getDescription(Locale locale, boolean useDefault) {
675                    String languageId = LocaleUtil.toLanguageId(locale);
676    
677                    return getDescription(languageId, useDefault);
678            }
679    
680            @Override
681            public String getDescription(String languageId) {
682                    return LocalizationUtil.getLocalization(getDescription(), languageId);
683            }
684    
685            @Override
686            public String getDescription(String languageId, boolean useDefault) {
687                    return LocalizationUtil.getLocalization(getDescription(), languageId,
688                            useDefault);
689            }
690    
691            @Override
692            public String getDescriptionCurrentLanguageId() {
693                    return _descriptionCurrentLanguageId;
694            }
695    
696            @JSON
697            @Override
698            public String getDescriptionCurrentValue() {
699                    Locale locale = getLocale(_descriptionCurrentLanguageId);
700    
701                    return getDescription(locale);
702            }
703    
704            @Override
705            public Map<Locale, String> getDescriptionMap() {
706                    return LocalizationUtil.getLocalizationMap(getDescription());
707            }
708    
709            @Override
710            public void setDescription(String description) {
711                    _description = description;
712            }
713    
714            @Override
715            public void setDescription(String description, Locale locale) {
716                    setDescription(description, locale, LocaleUtil.getSiteDefault());
717            }
718    
719            @Override
720            public void setDescription(String description, Locale locale,
721                    Locale defaultLocale) {
722                    String languageId = LocaleUtil.toLanguageId(locale);
723                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
724    
725                    if (Validator.isNotNull(description)) {
726                            setDescription(LocalizationUtil.updateLocalization(
727                                            getDescription(), "Description", description, languageId,
728                                            defaultLanguageId));
729                    }
730                    else {
731                            setDescription(LocalizationUtil.removeLocalization(
732                                            getDescription(), "Description", languageId));
733                    }
734            }
735    
736            @Override
737            public void setDescriptionCurrentLanguageId(String languageId) {
738                    _descriptionCurrentLanguageId = languageId;
739            }
740    
741            @Override
742            public void setDescriptionMap(Map<Locale, String> descriptionMap) {
743                    setDescriptionMap(descriptionMap, LocaleUtil.getSiteDefault());
744            }
745    
746            @Override
747            public void setDescriptionMap(Map<Locale, String> descriptionMap,
748                    Locale defaultLocale) {
749                    if (descriptionMap == null) {
750                            return;
751                    }
752    
753                    setDescription(LocalizationUtil.updateLocalization(descriptionMap,
754                                    getDescription(), "Description",
755                                    LocaleUtil.toLanguageId(defaultLocale)));
756            }
757    
758            @JSON
759            @Override
760            public long getVocabularyId() {
761                    return _vocabularyId;
762            }
763    
764            @Override
765            public void setVocabularyId(long vocabularyId) {
766                    _columnBitmask |= VOCABULARYID_COLUMN_BITMASK;
767    
768                    if (!_setOriginalVocabularyId) {
769                            _setOriginalVocabularyId = true;
770    
771                            _originalVocabularyId = _vocabularyId;
772                    }
773    
774                    _vocabularyId = vocabularyId;
775            }
776    
777            public long getOriginalVocabularyId() {
778                    return _originalVocabularyId;
779            }
780    
781            public long getNestedSetsTreeNodeLeft() {
782                    return _leftCategoryId;
783            }
784    
785            public long getNestedSetsTreeNodeRight() {
786                    return _rightCategoryId;
787            }
788    
789            public long getNestedSetsTreeNodeScopeId() {
790                    return _groupId;
791            }
792    
793            public void setNestedSetsTreeNodeLeft(long nestedSetsTreeNodeLeft) {
794                    _leftCategoryId = nestedSetsTreeNodeLeft;
795            }
796    
797            public void setNestedSetsTreeNodeRight(long nestedSetsTreeNodeRight) {
798                    _rightCategoryId = nestedSetsTreeNodeRight;
799            }
800    
801            @Override
802            public StagedModelType getStagedModelType() {
803                    return new StagedModelType(PortalUtil.getClassNameId(
804                                    AssetCategory.class.getName()));
805            }
806    
807            public long getColumnBitmask() {
808                    return _columnBitmask;
809            }
810    
811            @Override
812            public ExpandoBridge getExpandoBridge() {
813                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
814                            AssetCategory.class.getName(), getPrimaryKey());
815            }
816    
817            @Override
818            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
819                    ExpandoBridge expandoBridge = getExpandoBridge();
820    
821                    expandoBridge.setAttributes(serviceContext);
822            }
823    
824            @Override
825            public String[] getAvailableLanguageIds() {
826                    Set<String> availableLanguageIds = new TreeSet<String>();
827    
828                    Map<Locale, String> titleMap = getTitleMap();
829    
830                    for (Map.Entry<Locale, String> entry : titleMap.entrySet()) {
831                            Locale locale = entry.getKey();
832                            String value = entry.getValue();
833    
834                            if (Validator.isNotNull(value)) {
835                                    availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
836                            }
837                    }
838    
839                    Map<Locale, String> descriptionMap = getDescriptionMap();
840    
841                    for (Map.Entry<Locale, String> entry : descriptionMap.entrySet()) {
842                            Locale locale = entry.getKey();
843                            String value = entry.getValue();
844    
845                            if (Validator.isNotNull(value)) {
846                                    availableLanguageIds.add(LocaleUtil.toLanguageId(locale));
847                            }
848                    }
849    
850                    return availableLanguageIds.toArray(new String[availableLanguageIds.size()]);
851            }
852    
853            @Override
854            public String getDefaultLanguageId() {
855                    String xml = getTitle();
856    
857                    if (xml == null) {
858                            return StringPool.BLANK;
859                    }
860    
861                    Locale defaultLocale = LocaleUtil.getSiteDefault();
862    
863                    return LocalizationUtil.getDefaultLanguageId(xml, defaultLocale);
864            }
865    
866            @Override
867            public void prepareLocalizedFieldsForImport() throws LocaleException {
868                    Locale defaultLocale = LocaleUtil.fromLanguageId(getDefaultLanguageId());
869    
870                    Locale[] availableLocales = LocaleUtil.fromLanguageIds(getAvailableLanguageIds());
871    
872                    Locale defaultImportLocale = LocalizationUtil.getDefaultImportLocale(AssetCategory.class.getName(),
873                                    getPrimaryKey(), defaultLocale, availableLocales);
874    
875                    prepareLocalizedFieldsForImport(defaultImportLocale);
876            }
877    
878            @Override
879            @SuppressWarnings("unused")
880            public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
881                    throws LocaleException {
882                    Locale defaultLocale = LocaleUtil.getSiteDefault();
883    
884                    String modelDefaultLanguageId = getDefaultLanguageId();
885    
886                    String title = getTitle(defaultLocale);
887    
888                    if (Validator.isNull(title)) {
889                            setTitle(getTitle(modelDefaultLanguageId), defaultLocale);
890                    }
891                    else {
892                            setTitle(getTitle(defaultLocale), defaultLocale, defaultLocale);
893                    }
894    
895                    String description = getDescription(defaultLocale);
896    
897                    if (Validator.isNull(description)) {
898                            setDescription(getDescription(modelDefaultLanguageId), defaultLocale);
899                    }
900                    else {
901                            setDescription(getDescription(defaultLocale), defaultLocale,
902                                    defaultLocale);
903                    }
904            }
905    
906            @Override
907            public AssetCategory toEscapedModel() {
908                    if (_escapedModel == null) {
909                            _escapedModel = (AssetCategory)ProxyUtil.newProxyInstance(_classLoader,
910                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
911                    }
912    
913                    return _escapedModel;
914            }
915    
916            @Override
917            public Object clone() {
918                    AssetCategoryImpl assetCategoryImpl = new AssetCategoryImpl();
919    
920                    assetCategoryImpl.setUuid(getUuid());
921                    assetCategoryImpl.setCategoryId(getCategoryId());
922                    assetCategoryImpl.setGroupId(getGroupId());
923                    assetCategoryImpl.setCompanyId(getCompanyId());
924                    assetCategoryImpl.setUserId(getUserId());
925                    assetCategoryImpl.setUserName(getUserName());
926                    assetCategoryImpl.setCreateDate(getCreateDate());
927                    assetCategoryImpl.setModifiedDate(getModifiedDate());
928                    assetCategoryImpl.setParentCategoryId(getParentCategoryId());
929                    assetCategoryImpl.setLeftCategoryId(getLeftCategoryId());
930                    assetCategoryImpl.setRightCategoryId(getRightCategoryId());
931                    assetCategoryImpl.setName(getName());
932                    assetCategoryImpl.setTitle(getTitle());
933                    assetCategoryImpl.setDescription(getDescription());
934                    assetCategoryImpl.setVocabularyId(getVocabularyId());
935    
936                    assetCategoryImpl.resetOriginalValues();
937    
938                    return assetCategoryImpl;
939            }
940    
941            @Override
942            public int compareTo(AssetCategory assetCategory) {
943                    int value = 0;
944    
945                    value = getName().compareTo(assetCategory.getName());
946    
947                    if (value != 0) {
948                            return value;
949                    }
950    
951                    return 0;
952            }
953    
954            @Override
955            public boolean equals(Object obj) {
956                    if (this == obj) {
957                            return true;
958                    }
959    
960                    if (!(obj instanceof AssetCategory)) {
961                            return false;
962                    }
963    
964                    AssetCategory assetCategory = (AssetCategory)obj;
965    
966                    long primaryKey = assetCategory.getPrimaryKey();
967    
968                    if (getPrimaryKey() == primaryKey) {
969                            return true;
970                    }
971                    else {
972                            return false;
973                    }
974            }
975    
976            @Override
977            public int hashCode() {
978                    return (int)getPrimaryKey();
979            }
980    
981            @Override
982            public boolean isEntityCacheEnabled() {
983                    return ENTITY_CACHE_ENABLED;
984            }
985    
986            @Override
987            public boolean isFinderCacheEnabled() {
988                    return FINDER_CACHE_ENABLED;
989            }
990    
991            @Override
992            public void resetOriginalValues() {
993                    AssetCategoryModelImpl assetCategoryModelImpl = this;
994    
995                    assetCategoryModelImpl._originalUuid = assetCategoryModelImpl._uuid;
996    
997                    assetCategoryModelImpl._originalGroupId = assetCategoryModelImpl._groupId;
998    
999                    assetCategoryModelImpl._setOriginalGroupId = false;
1000    
1001                    assetCategoryModelImpl._originalCompanyId = assetCategoryModelImpl._companyId;
1002    
1003                    assetCategoryModelImpl._setOriginalCompanyId = false;
1004    
1005                    assetCategoryModelImpl._originalParentCategoryId = assetCategoryModelImpl._parentCategoryId;
1006    
1007                    assetCategoryModelImpl._setOriginalParentCategoryId = false;
1008    
1009                    assetCategoryModelImpl._originalName = assetCategoryModelImpl._name;
1010    
1011                    assetCategoryModelImpl._originalVocabularyId = assetCategoryModelImpl._vocabularyId;
1012    
1013                    assetCategoryModelImpl._setOriginalVocabularyId = false;
1014    
1015                    assetCategoryModelImpl._columnBitmask = 0;
1016            }
1017    
1018            @Override
1019            public CacheModel<AssetCategory> toCacheModel() {
1020                    AssetCategoryCacheModel assetCategoryCacheModel = new AssetCategoryCacheModel();
1021    
1022                    assetCategoryCacheModel.uuid = getUuid();
1023    
1024                    String uuid = assetCategoryCacheModel.uuid;
1025    
1026                    if ((uuid != null) && (uuid.length() == 0)) {
1027                            assetCategoryCacheModel.uuid = null;
1028                    }
1029    
1030                    assetCategoryCacheModel.categoryId = getCategoryId();
1031    
1032                    assetCategoryCacheModel.groupId = getGroupId();
1033    
1034                    assetCategoryCacheModel.companyId = getCompanyId();
1035    
1036                    assetCategoryCacheModel.userId = getUserId();
1037    
1038                    assetCategoryCacheModel.userName = getUserName();
1039    
1040                    String userName = assetCategoryCacheModel.userName;
1041    
1042                    if ((userName != null) && (userName.length() == 0)) {
1043                            assetCategoryCacheModel.userName = null;
1044                    }
1045    
1046                    Date createDate = getCreateDate();
1047    
1048                    if (createDate != null) {
1049                            assetCategoryCacheModel.createDate = createDate.getTime();
1050                    }
1051                    else {
1052                            assetCategoryCacheModel.createDate = Long.MIN_VALUE;
1053                    }
1054    
1055                    Date modifiedDate = getModifiedDate();
1056    
1057                    if (modifiedDate != null) {
1058                            assetCategoryCacheModel.modifiedDate = modifiedDate.getTime();
1059                    }
1060                    else {
1061                            assetCategoryCacheModel.modifiedDate = Long.MIN_VALUE;
1062                    }
1063    
1064                    assetCategoryCacheModel.parentCategoryId = getParentCategoryId();
1065    
1066                    assetCategoryCacheModel.leftCategoryId = getLeftCategoryId();
1067    
1068                    assetCategoryCacheModel.rightCategoryId = getRightCategoryId();
1069    
1070                    assetCategoryCacheModel.name = getName();
1071    
1072                    String name = assetCategoryCacheModel.name;
1073    
1074                    if ((name != null) && (name.length() == 0)) {
1075                            assetCategoryCacheModel.name = null;
1076                    }
1077    
1078                    assetCategoryCacheModel.title = getTitle();
1079    
1080                    String title = assetCategoryCacheModel.title;
1081    
1082                    if ((title != null) && (title.length() == 0)) {
1083                            assetCategoryCacheModel.title = null;
1084                    }
1085    
1086                    assetCategoryCacheModel.description = getDescription();
1087    
1088                    String description = assetCategoryCacheModel.description;
1089    
1090                    if ((description != null) && (description.length() == 0)) {
1091                            assetCategoryCacheModel.description = null;
1092                    }
1093    
1094                    assetCategoryCacheModel.vocabularyId = getVocabularyId();
1095    
1096                    return assetCategoryCacheModel;
1097            }
1098    
1099            @Override
1100            public String toString() {
1101                    StringBundler sb = new StringBundler(31);
1102    
1103                    sb.append("{uuid=");
1104                    sb.append(getUuid());
1105                    sb.append(", categoryId=");
1106                    sb.append(getCategoryId());
1107                    sb.append(", groupId=");
1108                    sb.append(getGroupId());
1109                    sb.append(", companyId=");
1110                    sb.append(getCompanyId());
1111                    sb.append(", userId=");
1112                    sb.append(getUserId());
1113                    sb.append(", userName=");
1114                    sb.append(getUserName());
1115                    sb.append(", createDate=");
1116                    sb.append(getCreateDate());
1117                    sb.append(", modifiedDate=");
1118                    sb.append(getModifiedDate());
1119                    sb.append(", parentCategoryId=");
1120                    sb.append(getParentCategoryId());
1121                    sb.append(", leftCategoryId=");
1122                    sb.append(getLeftCategoryId());
1123                    sb.append(", rightCategoryId=");
1124                    sb.append(getRightCategoryId());
1125                    sb.append(", name=");
1126                    sb.append(getName());
1127                    sb.append(", title=");
1128                    sb.append(getTitle());
1129                    sb.append(", description=");
1130                    sb.append(getDescription());
1131                    sb.append(", vocabularyId=");
1132                    sb.append(getVocabularyId());
1133                    sb.append("}");
1134    
1135                    return sb.toString();
1136            }
1137    
1138            @Override
1139            public String toXmlString() {
1140                    StringBundler sb = new StringBundler(49);
1141    
1142                    sb.append("<model><model-name>");
1143                    sb.append("com.liferay.portlet.asset.model.AssetCategory");
1144                    sb.append("</model-name>");
1145    
1146                    sb.append(
1147                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
1148                    sb.append(getUuid());
1149                    sb.append("]]></column-value></column>");
1150                    sb.append(
1151                            "<column><column-name>categoryId</column-name><column-value><![CDATA[");
1152                    sb.append(getCategoryId());
1153                    sb.append("]]></column-value></column>");
1154                    sb.append(
1155                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
1156                    sb.append(getGroupId());
1157                    sb.append("]]></column-value></column>");
1158                    sb.append(
1159                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
1160                    sb.append(getCompanyId());
1161                    sb.append("]]></column-value></column>");
1162                    sb.append(
1163                            "<column><column-name>userId</column-name><column-value><![CDATA[");
1164                    sb.append(getUserId());
1165                    sb.append("]]></column-value></column>");
1166                    sb.append(
1167                            "<column><column-name>userName</column-name><column-value><![CDATA[");
1168                    sb.append(getUserName());
1169                    sb.append("]]></column-value></column>");
1170                    sb.append(
1171                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
1172                    sb.append(getCreateDate());
1173                    sb.append("]]></column-value></column>");
1174                    sb.append(
1175                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1176                    sb.append(getModifiedDate());
1177                    sb.append("]]></column-value></column>");
1178                    sb.append(
1179                            "<column><column-name>parentCategoryId</column-name><column-value><![CDATA[");
1180                    sb.append(getParentCategoryId());
1181                    sb.append("]]></column-value></column>");
1182                    sb.append(
1183                            "<column><column-name>leftCategoryId</column-name><column-value><![CDATA[");
1184                    sb.append(getLeftCategoryId());
1185                    sb.append("]]></column-value></column>");
1186                    sb.append(
1187                            "<column><column-name>rightCategoryId</column-name><column-value><![CDATA[");
1188                    sb.append(getRightCategoryId());
1189                    sb.append("]]></column-value></column>");
1190                    sb.append(
1191                            "<column><column-name>name</column-name><column-value><![CDATA[");
1192                    sb.append(getName());
1193                    sb.append("]]></column-value></column>");
1194                    sb.append(
1195                            "<column><column-name>title</column-name><column-value><![CDATA[");
1196                    sb.append(getTitle());
1197                    sb.append("]]></column-value></column>");
1198                    sb.append(
1199                            "<column><column-name>description</column-name><column-value><![CDATA[");
1200                    sb.append(getDescription());
1201                    sb.append("]]></column-value></column>");
1202                    sb.append(
1203                            "<column><column-name>vocabularyId</column-name><column-value><![CDATA[");
1204                    sb.append(getVocabularyId());
1205                    sb.append("]]></column-value></column>");
1206    
1207                    sb.append("</model>");
1208    
1209                    return sb.toString();
1210            }
1211    
1212            private static final ClassLoader _classLoader = AssetCategory.class.getClassLoader();
1213            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
1214                            AssetCategory.class
1215                    };
1216            private String _uuid;
1217            private String _originalUuid;
1218            private long _categoryId;
1219            private long _groupId;
1220            private long _originalGroupId;
1221            private boolean _setOriginalGroupId;
1222            private long _companyId;
1223            private long _originalCompanyId;
1224            private boolean _setOriginalCompanyId;
1225            private long _userId;
1226            private String _userName;
1227            private Date _createDate;
1228            private Date _modifiedDate;
1229            private long _parentCategoryId;
1230            private long _originalParentCategoryId;
1231            private boolean _setOriginalParentCategoryId;
1232            private long _leftCategoryId;
1233            private long _rightCategoryId;
1234            private String _name;
1235            private String _originalName;
1236            private String _title;
1237            private String _titleCurrentLanguageId;
1238            private String _description;
1239            private String _descriptionCurrentLanguageId;
1240            private long _vocabularyId;
1241            private long _originalVocabularyId;
1242            private boolean _setOriginalVocabularyId;
1243            private long _columnBitmask;
1244            private AssetCategory _escapedModel;
1245    }