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