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