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.portal.model.impl;
016    
017    import com.liferay.portal.LocaleException;
018    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
019    import com.liferay.portal.kernel.json.JSON;
020    import com.liferay.portal.kernel.language.LanguageUtil;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.LocaleUtil;
023    import com.liferay.portal.kernel.util.LocalizationUtil;
024    import com.liferay.portal.kernel.util.ProxyUtil;
025    import com.liferay.portal.kernel.util.StringBundler;
026    import com.liferay.portal.kernel.util.StringPool;
027    import com.liferay.portal.kernel.util.Validator;
028    import com.liferay.portal.model.CacheModel;
029    import com.liferay.portal.model.Role;
030    import com.liferay.portal.model.RoleModel;
031    import com.liferay.portal.model.RoleSoap;
032    import com.liferay.portal.service.ServiceContext;
033    import com.liferay.portal.util.PortalUtil;
034    
035    import com.liferay.portlet.expando.model.ExpandoBridge;
036    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
037    
038    import java.io.Serializable;
039    
040    import java.sql.Types;
041    
042    import java.util.ArrayList;
043    import java.util.HashMap;
044    import java.util.List;
045    import java.util.Locale;
046    import java.util.Map;
047    
048    /**
049     * The base model implementation for the Role service. Represents a row in the "Role_" database table, with each column mapped to a property of this class.
050     *
051     * <p>
052     * This implementation and its corresponding interface {@link com.liferay.portal.model.RoleModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link RoleImpl}.
053     * </p>
054     *
055     * @author Brian Wing Shun Chan
056     * @see RoleImpl
057     * @see com.liferay.portal.model.Role
058     * @see com.liferay.portal.model.RoleModel
059     * @generated
060     */
061    @JSON(strict = true)
062    public class RoleModelImpl extends BaseModelImpl<Role> implements RoleModel {
063            /*
064             * NOTE FOR DEVELOPERS:
065             *
066             * Never modify or reference this class directly. All methods that expect a role model instance should use the {@link com.liferay.portal.model.Role} interface instead.
067             */
068            public static final String TABLE_NAME = "Role_";
069            public static final Object[][] TABLE_COLUMNS = {
070                            { "roleId", Types.BIGINT },
071                            { "companyId", Types.BIGINT },
072                            { "classNameId", Types.BIGINT },
073                            { "classPK", Types.BIGINT },
074                            { "name", Types.VARCHAR },
075                            { "title", Types.VARCHAR },
076                            { "description", Types.VARCHAR },
077                            { "type_", Types.INTEGER },
078                            { "subtype", Types.VARCHAR }
079                    };
080            public static final String TABLE_SQL_CREATE = "create table Role_ (roleId LONG not null primary key,companyId LONG,classNameId LONG,classPK LONG,name VARCHAR(75) null,title STRING null,description STRING null,type_ INTEGER,subtype VARCHAR(75) null)";
081            public static final String TABLE_SQL_DROP = "drop table Role_";
082            public static final String ORDER_BY_JPQL = " ORDER BY role.name ASC";
083            public static final String ORDER_BY_SQL = " ORDER BY Role_.name ASC";
084            public static final String DATA_SOURCE = "liferayDataSource";
085            public static final String SESSION_FACTORY = "liferaySessionFactory";
086            public static final String TX_MANAGER = "liferayTransactionManager";
087            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
088                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Role"),
089                            true);
090            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Role"),
092                            true);
093            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
094                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.Role"),
095                            true);
096            public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
097            public static long CLASSPK_COLUMN_BITMASK = 2L;
098            public static long COMPANYID_COLUMN_BITMASK = 4L;
099            public static long NAME_COLUMN_BITMASK = 8L;
100            public static long SUBTYPE_COLUMN_BITMASK = 16L;
101            public static long TYPE_COLUMN_BITMASK = 32L;
102    
103            /**
104             * Converts the soap model instance into a normal model instance.
105             *
106             * @param soapModel the soap model instance to convert
107             * @return the normal model instance
108             */
109            public static Role toModel(RoleSoap soapModel) {
110                    if (soapModel == null) {
111                            return null;
112                    }
113    
114                    Role model = new RoleImpl();
115    
116                    model.setRoleId(soapModel.getRoleId());
117                    model.setCompanyId(soapModel.getCompanyId());
118                    model.setClassNameId(soapModel.getClassNameId());
119                    model.setClassPK(soapModel.getClassPK());
120                    model.setName(soapModel.getName());
121                    model.setTitle(soapModel.getTitle());
122                    model.setDescription(soapModel.getDescription());
123                    model.setType(soapModel.getType());
124                    model.setSubtype(soapModel.getSubtype());
125    
126                    return model;
127            }
128    
129            /**
130             * Converts the soap model instances into normal model instances.
131             *
132             * @param soapModels the soap model instances to convert
133             * @return the normal model instances
134             */
135            public static List<Role> toModels(RoleSoap[] soapModels) {
136                    if (soapModels == null) {
137                            return null;
138                    }
139    
140                    List<Role> models = new ArrayList<Role>(soapModels.length);
141    
142                    for (RoleSoap soapModel : soapModels) {
143                            models.add(toModel(soapModel));
144                    }
145    
146                    return models;
147            }
148    
149            public static final String MAPPING_TABLE_GROUPS_ROLES_NAME = "Groups_Roles";
150            public static final Object[][] MAPPING_TABLE_GROUPS_ROLES_COLUMNS = {
151                            { "groupId", Types.BIGINT },
152                            { "roleId", Types.BIGINT }
153                    };
154            public static final String MAPPING_TABLE_GROUPS_ROLES_SQL_CREATE = "create table Groups_Roles (groupId LONG not null,roleId LONG not null,primary key (groupId, roleId))";
155            public static final boolean FINDER_CACHE_ENABLED_GROUPS_ROLES = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
156                                    "value.object.finder.cache.enabled.Groups_Roles"), true);
157            public static final String MAPPING_TABLE_ROLES_PERMISSIONS_NAME = "Roles_Permissions";
158            public static final Object[][] MAPPING_TABLE_ROLES_PERMISSIONS_COLUMNS = {
159                            { "roleId", Types.BIGINT },
160                            { "permissionId", Types.BIGINT }
161                    };
162            public static final String MAPPING_TABLE_ROLES_PERMISSIONS_SQL_CREATE = "create table Roles_Permissions (permissionId LONG not null,roleId LONG not null,primary key (permissionId, roleId))";
163            public static final boolean FINDER_CACHE_ENABLED_ROLES_PERMISSIONS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
164                                    "value.object.finder.cache.enabled.Roles_Permissions"), true);
165            public static final String MAPPING_TABLE_USERS_ROLES_NAME = "Users_Roles";
166            public static final Object[][] MAPPING_TABLE_USERS_ROLES_COLUMNS = {
167                            { "userId", Types.BIGINT },
168                            { "roleId", Types.BIGINT }
169                    };
170            public static final String MAPPING_TABLE_USERS_ROLES_SQL_CREATE = "create table Users_Roles (roleId LONG not null,userId LONG not null,primary key (roleId, userId))";
171            public static final boolean FINDER_CACHE_ENABLED_USERS_ROLES = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
172                                    "value.object.finder.cache.enabled.Users_Roles"), true);
173            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
174                                    "lock.expiration.time.com.liferay.portal.model.Role"));
175    
176            public RoleModelImpl() {
177            }
178    
179            public long getPrimaryKey() {
180                    return _roleId;
181            }
182    
183            public void setPrimaryKey(long primaryKey) {
184                    setRoleId(primaryKey);
185            }
186    
187            public Serializable getPrimaryKeyObj() {
188                    return new Long(_roleId);
189            }
190    
191            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
192                    setPrimaryKey(((Long)primaryKeyObj).longValue());
193            }
194    
195            public Class<?> getModelClass() {
196                    return Role.class;
197            }
198    
199            public String getModelClassName() {
200                    return Role.class.getName();
201            }
202    
203            @Override
204            public Map<String, Object> getModelAttributes() {
205                    Map<String, Object> attributes = new HashMap<String, Object>();
206    
207                    attributes.put("roleId", getRoleId());
208                    attributes.put("companyId", getCompanyId());
209                    attributes.put("classNameId", getClassNameId());
210                    attributes.put("classPK", getClassPK());
211                    attributes.put("name", getName());
212                    attributes.put("title", getTitle());
213                    attributes.put("description", getDescription());
214                    attributes.put("type", getType());
215                    attributes.put("subtype", getSubtype());
216    
217                    return attributes;
218            }
219    
220            @Override
221            public void setModelAttributes(Map<String, Object> attributes) {
222                    Long roleId = (Long)attributes.get("roleId");
223    
224                    if (roleId != null) {
225                            setRoleId(roleId);
226                    }
227    
228                    Long companyId = (Long)attributes.get("companyId");
229    
230                    if (companyId != null) {
231                            setCompanyId(companyId);
232                    }
233    
234                    Long classNameId = (Long)attributes.get("classNameId");
235    
236                    if (classNameId != null) {
237                            setClassNameId(classNameId);
238                    }
239    
240                    Long classPK = (Long)attributes.get("classPK");
241    
242                    if (classPK != null) {
243                            setClassPK(classPK);
244                    }
245    
246                    String name = (String)attributes.get("name");
247    
248                    if (name != null) {
249                            setName(name);
250                    }
251    
252                    String title = (String)attributes.get("title");
253    
254                    if (title != null) {
255                            setTitle(title);
256                    }
257    
258                    String description = (String)attributes.get("description");
259    
260                    if (description != null) {
261                            setDescription(description);
262                    }
263    
264                    Integer type = (Integer)attributes.get("type");
265    
266                    if (type != null) {
267                            setType(type);
268                    }
269    
270                    String subtype = (String)attributes.get("subtype");
271    
272                    if (subtype != null) {
273                            setSubtype(subtype);
274                    }
275            }
276    
277            @JSON
278            public long getRoleId() {
279                    return _roleId;
280            }
281    
282            public void setRoleId(long roleId) {
283                    _roleId = roleId;
284            }
285    
286            @JSON
287            public long getCompanyId() {
288                    return _companyId;
289            }
290    
291            public void setCompanyId(long companyId) {
292                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
293    
294                    if (!_setOriginalCompanyId) {
295                            _setOriginalCompanyId = true;
296    
297                            _originalCompanyId = _companyId;
298                    }
299    
300                    _companyId = companyId;
301            }
302    
303            public long getOriginalCompanyId() {
304                    return _originalCompanyId;
305            }
306    
307            public String getClassName() {
308                    if (getClassNameId() <= 0) {
309                            return StringPool.BLANK;
310                    }
311    
312                    return PortalUtil.getClassName(getClassNameId());
313            }
314    
315            public void setClassName(String className) {
316                    long classNameId = 0;
317    
318                    if (Validator.isNotNull(className)) {
319                            classNameId = PortalUtil.getClassNameId(className);
320                    }
321    
322                    setClassNameId(classNameId);
323            }
324    
325            @JSON
326            public long getClassNameId() {
327                    return _classNameId;
328            }
329    
330            public void setClassNameId(long classNameId) {
331                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
332    
333                    if (!_setOriginalClassNameId) {
334                            _setOriginalClassNameId = true;
335    
336                            _originalClassNameId = _classNameId;
337                    }
338    
339                    _classNameId = classNameId;
340            }
341    
342            public long getOriginalClassNameId() {
343                    return _originalClassNameId;
344            }
345    
346            @JSON
347            public long getClassPK() {
348                    return _classPK;
349            }
350    
351            public void setClassPK(long classPK) {
352                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
353    
354                    if (!_setOriginalClassPK) {
355                            _setOriginalClassPK = true;
356    
357                            _originalClassPK = _classPK;
358                    }
359    
360                    _classPK = classPK;
361            }
362    
363            public long getOriginalClassPK() {
364                    return _originalClassPK;
365            }
366    
367            @JSON
368            public String getName() {
369                    if (_name == null) {
370                            return StringPool.BLANK;
371                    }
372                    else {
373                            return _name;
374                    }
375            }
376    
377            public void setName(String name) {
378                    _columnBitmask = -1L;
379    
380                    if (_originalName == null) {
381                            _originalName = _name;
382                    }
383    
384                    _name = name;
385            }
386    
387            public String getOriginalName() {
388                    return GetterUtil.getString(_originalName);
389            }
390    
391            @JSON
392            public String getTitle() {
393                    if (_title == null) {
394                            return StringPool.BLANK;
395                    }
396                    else {
397                            return _title;
398                    }
399            }
400    
401            public String getTitle(Locale locale) {
402                    String languageId = LocaleUtil.toLanguageId(locale);
403    
404                    return getTitle(languageId);
405            }
406    
407            public String getTitle(Locale locale, boolean useDefault) {
408                    String languageId = LocaleUtil.toLanguageId(locale);
409    
410                    return getTitle(languageId, useDefault);
411            }
412    
413            public String getTitle(String languageId) {
414                    return LocalizationUtil.getLocalization(getTitle(), languageId);
415            }
416    
417            public String getTitle(String languageId, boolean useDefault) {
418                    return LocalizationUtil.getLocalization(getTitle(), languageId,
419                            useDefault);
420            }
421    
422            public String getTitleCurrentLanguageId() {
423                    return _titleCurrentLanguageId;
424            }
425    
426            @JSON
427            public String getTitleCurrentValue() {
428                    Locale locale = getLocale(_titleCurrentLanguageId);
429    
430                    return getTitle(locale);
431            }
432    
433            public Map<Locale, String> getTitleMap() {
434                    return LocalizationUtil.getLocalizationMap(getTitle());
435            }
436    
437            public void setTitle(String title) {
438                    _title = title;
439            }
440    
441            public void setTitle(String title, Locale locale) {
442                    setTitle(title, locale, LocaleUtil.getDefault());
443            }
444    
445            public void setTitle(String title, Locale locale, Locale defaultLocale) {
446                    String languageId = LocaleUtil.toLanguageId(locale);
447                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
448    
449                    if (Validator.isNotNull(title)) {
450                            setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
451                                            title, languageId, defaultLanguageId));
452                    }
453                    else {
454                            setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
455                                            languageId));
456                    }
457            }
458    
459            public void setTitleCurrentLanguageId(String languageId) {
460                    _titleCurrentLanguageId = languageId;
461            }
462    
463            public void setTitleMap(Map<Locale, String> titleMap) {
464                    setTitleMap(titleMap, LocaleUtil.getDefault());
465            }
466    
467            public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
468                    if (titleMap == null) {
469                            return;
470                    }
471    
472                    Locale[] locales = LanguageUtil.getAvailableLocales();
473    
474                    for (Locale locale : locales) {
475                            String title = titleMap.get(locale);
476    
477                            setTitle(title, locale, defaultLocale);
478                    }
479            }
480    
481            @JSON
482            public String getDescription() {
483                    if (_description == null) {
484                            return StringPool.BLANK;
485                    }
486                    else {
487                            return _description;
488                    }
489            }
490    
491            public String getDescription(Locale locale) {
492                    String languageId = LocaleUtil.toLanguageId(locale);
493    
494                    return getDescription(languageId);
495            }
496    
497            public String getDescription(Locale locale, boolean useDefault) {
498                    String languageId = LocaleUtil.toLanguageId(locale);
499    
500                    return getDescription(languageId, useDefault);
501            }
502    
503            public String getDescription(String languageId) {
504                    return LocalizationUtil.getLocalization(getDescription(), languageId);
505            }
506    
507            public String getDescription(String languageId, boolean useDefault) {
508                    return LocalizationUtil.getLocalization(getDescription(), languageId,
509                            useDefault);
510            }
511    
512            public String getDescriptionCurrentLanguageId() {
513                    return _descriptionCurrentLanguageId;
514            }
515    
516            @JSON
517            public String getDescriptionCurrentValue() {
518                    Locale locale = getLocale(_descriptionCurrentLanguageId);
519    
520                    return getDescription(locale);
521            }
522    
523            public Map<Locale, String> getDescriptionMap() {
524                    return LocalizationUtil.getLocalizationMap(getDescription());
525            }
526    
527            public void setDescription(String description) {
528                    _description = description;
529            }
530    
531            public void setDescription(String description, Locale locale) {
532                    setDescription(description, locale, LocaleUtil.getDefault());
533            }
534    
535            public void setDescription(String description, Locale locale,
536                    Locale defaultLocale) {
537                    String languageId = LocaleUtil.toLanguageId(locale);
538                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
539    
540                    if (Validator.isNotNull(description)) {
541                            setDescription(LocalizationUtil.updateLocalization(
542                                            getDescription(), "Description", description, languageId,
543                                            defaultLanguageId));
544                    }
545                    else {
546                            setDescription(LocalizationUtil.removeLocalization(
547                                            getDescription(), "Description", languageId));
548                    }
549            }
550    
551            public void setDescriptionCurrentLanguageId(String languageId) {
552                    _descriptionCurrentLanguageId = languageId;
553            }
554    
555            public void setDescriptionMap(Map<Locale, String> descriptionMap) {
556                    setDescriptionMap(descriptionMap, LocaleUtil.getDefault());
557            }
558    
559            public void setDescriptionMap(Map<Locale, String> descriptionMap,
560                    Locale defaultLocale) {
561                    if (descriptionMap == null) {
562                            return;
563                    }
564    
565                    Locale[] locales = LanguageUtil.getAvailableLocales();
566    
567                    for (Locale locale : locales) {
568                            String description = descriptionMap.get(locale);
569    
570                            setDescription(description, locale, defaultLocale);
571                    }
572            }
573    
574            @JSON
575            public int getType() {
576                    return _type;
577            }
578    
579            public void setType(int type) {
580                    _columnBitmask |= TYPE_COLUMN_BITMASK;
581    
582                    if (!_setOriginalType) {
583                            _setOriginalType = true;
584    
585                            _originalType = _type;
586                    }
587    
588                    _type = type;
589            }
590    
591            public int getOriginalType() {
592                    return _originalType;
593            }
594    
595            @JSON
596            public String getSubtype() {
597                    if (_subtype == null) {
598                            return StringPool.BLANK;
599                    }
600                    else {
601                            return _subtype;
602                    }
603            }
604    
605            public void setSubtype(String subtype) {
606                    _columnBitmask |= SUBTYPE_COLUMN_BITMASK;
607    
608                    if (_originalSubtype == null) {
609                            _originalSubtype = _subtype;
610                    }
611    
612                    _subtype = subtype;
613            }
614    
615            public String getOriginalSubtype() {
616                    return GetterUtil.getString(_originalSubtype);
617            }
618    
619            public long getColumnBitmask() {
620                    return _columnBitmask;
621            }
622    
623            @Override
624            public ExpandoBridge getExpandoBridge() {
625                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
626                            Role.class.getName(), getPrimaryKey());
627            }
628    
629            @Override
630            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
631                    ExpandoBridge expandoBridge = getExpandoBridge();
632    
633                    expandoBridge.setAttributes(serviceContext);
634            }
635    
636            @SuppressWarnings("unused")
637            public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
638                    throws LocaleException {
639                    setTitle(getTitle(defaultImportLocale), defaultImportLocale,
640                            defaultImportLocale);
641                    setDescription(getDescription(defaultImportLocale),
642                            defaultImportLocale, defaultImportLocale);
643            }
644    
645            @Override
646            public Role toEscapedModel() {
647                    if (_escapedModel == null) {
648                            _escapedModel = (Role)ProxyUtil.newProxyInstance(_classLoader,
649                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
650                    }
651    
652                    return _escapedModel;
653            }
654    
655            public Role toUnescapedModel() {
656                    return (Role)this;
657            }
658    
659            @Override
660            public Object clone() {
661                    RoleImpl roleImpl = new RoleImpl();
662    
663                    roleImpl.setRoleId(getRoleId());
664                    roleImpl.setCompanyId(getCompanyId());
665                    roleImpl.setClassNameId(getClassNameId());
666                    roleImpl.setClassPK(getClassPK());
667                    roleImpl.setName(getName());
668                    roleImpl.setTitle(getTitle());
669                    roleImpl.setDescription(getDescription());
670                    roleImpl.setType(getType());
671                    roleImpl.setSubtype(getSubtype());
672    
673                    roleImpl.resetOriginalValues();
674    
675                    return roleImpl;
676            }
677    
678            public int compareTo(Role role) {
679                    int value = 0;
680    
681                    value = getName().compareTo(role.getName());
682    
683                    if (value != 0) {
684                            return value;
685                    }
686    
687                    return 0;
688            }
689    
690            @Override
691            public boolean equals(Object obj) {
692                    if (this == obj) {
693                            return true;
694                    }
695    
696                    if (!(obj instanceof Role)) {
697                            return false;
698                    }
699    
700                    Role role = (Role)obj;
701    
702                    long primaryKey = role.getPrimaryKey();
703    
704                    if (getPrimaryKey() == primaryKey) {
705                            return true;
706                    }
707                    else {
708                            return false;
709                    }
710            }
711    
712            @Override
713            public int hashCode() {
714                    return (int)getPrimaryKey();
715            }
716    
717            @Override
718            public void resetOriginalValues() {
719                    RoleModelImpl roleModelImpl = this;
720    
721                    roleModelImpl._originalCompanyId = roleModelImpl._companyId;
722    
723                    roleModelImpl._setOriginalCompanyId = false;
724    
725                    roleModelImpl._originalClassNameId = roleModelImpl._classNameId;
726    
727                    roleModelImpl._setOriginalClassNameId = false;
728    
729                    roleModelImpl._originalClassPK = roleModelImpl._classPK;
730    
731                    roleModelImpl._setOriginalClassPK = false;
732    
733                    roleModelImpl._originalName = roleModelImpl._name;
734    
735                    roleModelImpl._originalType = roleModelImpl._type;
736    
737                    roleModelImpl._setOriginalType = false;
738    
739                    roleModelImpl._originalSubtype = roleModelImpl._subtype;
740    
741                    roleModelImpl._columnBitmask = 0;
742            }
743    
744            @Override
745            public CacheModel<Role> toCacheModel() {
746                    RoleCacheModel roleCacheModel = new RoleCacheModel();
747    
748                    roleCacheModel.roleId = getRoleId();
749    
750                    roleCacheModel.companyId = getCompanyId();
751    
752                    roleCacheModel.classNameId = getClassNameId();
753    
754                    roleCacheModel.classPK = getClassPK();
755    
756                    roleCacheModel.name = getName();
757    
758                    String name = roleCacheModel.name;
759    
760                    if ((name != null) && (name.length() == 0)) {
761                            roleCacheModel.name = null;
762                    }
763    
764                    roleCacheModel.title = getTitle();
765    
766                    String title = roleCacheModel.title;
767    
768                    if ((title != null) && (title.length() == 0)) {
769                            roleCacheModel.title = null;
770                    }
771    
772                    roleCacheModel.description = getDescription();
773    
774                    String description = roleCacheModel.description;
775    
776                    if ((description != null) && (description.length() == 0)) {
777                            roleCacheModel.description = null;
778                    }
779    
780                    roleCacheModel.type = getType();
781    
782                    roleCacheModel.subtype = getSubtype();
783    
784                    String subtype = roleCacheModel.subtype;
785    
786                    if ((subtype != null) && (subtype.length() == 0)) {
787                            roleCacheModel.subtype = null;
788                    }
789    
790                    return roleCacheModel;
791            }
792    
793            @Override
794            public String toString() {
795                    StringBundler sb = new StringBundler(19);
796    
797                    sb.append("{roleId=");
798                    sb.append(getRoleId());
799                    sb.append(", companyId=");
800                    sb.append(getCompanyId());
801                    sb.append(", classNameId=");
802                    sb.append(getClassNameId());
803                    sb.append(", classPK=");
804                    sb.append(getClassPK());
805                    sb.append(", name=");
806                    sb.append(getName());
807                    sb.append(", title=");
808                    sb.append(getTitle());
809                    sb.append(", description=");
810                    sb.append(getDescription());
811                    sb.append(", type=");
812                    sb.append(getType());
813                    sb.append(", subtype=");
814                    sb.append(getSubtype());
815                    sb.append("}");
816    
817                    return sb.toString();
818            }
819    
820            public String toXmlString() {
821                    StringBundler sb = new StringBundler(31);
822    
823                    sb.append("<model><model-name>");
824                    sb.append("com.liferay.portal.model.Role");
825                    sb.append("</model-name>");
826    
827                    sb.append(
828                            "<column><column-name>roleId</column-name><column-value><![CDATA[");
829                    sb.append(getRoleId());
830                    sb.append("]]></column-value></column>");
831                    sb.append(
832                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
833                    sb.append(getCompanyId());
834                    sb.append("]]></column-value></column>");
835                    sb.append(
836                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
837                    sb.append(getClassNameId());
838                    sb.append("]]></column-value></column>");
839                    sb.append(
840                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
841                    sb.append(getClassPK());
842                    sb.append("]]></column-value></column>");
843                    sb.append(
844                            "<column><column-name>name</column-name><column-value><![CDATA[");
845                    sb.append(getName());
846                    sb.append("]]></column-value></column>");
847                    sb.append(
848                            "<column><column-name>title</column-name><column-value><![CDATA[");
849                    sb.append(getTitle());
850                    sb.append("]]></column-value></column>");
851                    sb.append(
852                            "<column><column-name>description</column-name><column-value><![CDATA[");
853                    sb.append(getDescription());
854                    sb.append("]]></column-value></column>");
855                    sb.append(
856                            "<column><column-name>type</column-name><column-value><![CDATA[");
857                    sb.append(getType());
858                    sb.append("]]></column-value></column>");
859                    sb.append(
860                            "<column><column-name>subtype</column-name><column-value><![CDATA[");
861                    sb.append(getSubtype());
862                    sb.append("]]></column-value></column>");
863    
864                    sb.append("</model>");
865    
866                    return sb.toString();
867            }
868    
869            private static ClassLoader _classLoader = Role.class.getClassLoader();
870            private static Class<?>[] _escapedModelInterfaces = new Class[] { Role.class };
871            private long _roleId;
872            private long _companyId;
873            private long _originalCompanyId;
874            private boolean _setOriginalCompanyId;
875            private long _classNameId;
876            private long _originalClassNameId;
877            private boolean _setOriginalClassNameId;
878            private long _classPK;
879            private long _originalClassPK;
880            private boolean _setOriginalClassPK;
881            private String _name;
882            private String _originalName;
883            private String _title;
884            private String _titleCurrentLanguageId;
885            private String _description;
886            private String _descriptionCurrentLanguageId;
887            private int _type;
888            private int _originalType;
889            private boolean _setOriginalType;
890            private String _subtype;
891            private String _originalSubtype;
892            private long _columnBitmask;
893            private Role _escapedModel;
894    }