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