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