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