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