001    /**
002     * Copyright (c) 2000-2011 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.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.model.UserGroupRole;
022    import com.liferay.portal.model.UserGroupRoleModel;
023    import com.liferay.portal.model.UserGroupRoleSoap;
024    import com.liferay.portal.service.persistence.UserGroupRolePK;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import java.io.Serializable;
028    
029    import java.lang.reflect.Proxy;
030    
031    import java.sql.Types;
032    
033    import java.util.ArrayList;
034    import java.util.List;
035    
036    /**
037     * The base model implementation for the UserGroupRole service. Represents a row in the "UserGroupRole" database table, with each column mapped to a property of this class.
038     *
039     * <p>
040     * This implementation and its corresponding interface {@link com.liferay.portal.model.UserGroupRoleModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link UserGroupRoleImpl}.
041     * </p>
042     *
043     * <p>
044     * Never modify or reference this class directly. All methods that expect a user group role model instance should use the {@link com.liferay.portal.model.UserGroupRole} interface instead.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see UserGroupRoleImpl
049     * @see com.liferay.portal.model.UserGroupRole
050     * @see com.liferay.portal.model.UserGroupRoleModel
051     * @generated
052     */
053    public class UserGroupRoleModelImpl extends BaseModelImpl<UserGroupRole>
054            implements UserGroupRoleModel {
055            public static final String TABLE_NAME = "UserGroupRole";
056            public static final Object[][] TABLE_COLUMNS = {
057                            { "userId", new Integer(Types.BIGINT) },
058                            { "groupId", new Integer(Types.BIGINT) },
059                            { "roleId", new Integer(Types.BIGINT) }
060                    };
061            public static final String TABLE_SQL_CREATE = "create table UserGroupRole (userId LONG not null,groupId LONG not null,roleId LONG not null,primary key (userId, groupId, roleId))";
062            public static final String TABLE_SQL_DROP = "drop table UserGroupRole";
063            public static final String DATA_SOURCE = "liferayDataSource";
064            public static final String SESSION_FACTORY = "liferaySessionFactory";
065            public static final String TX_MANAGER = "liferayTransactionManager";
066            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
067                                    "value.object.entity.cache.enabled.com.liferay.portal.model.UserGroupRole"),
068                            true);
069            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.finder.cache.enabled.com.liferay.portal.model.UserGroupRole"),
071                            true);
072    
073            /**
074             * Converts the soap model instance into a normal model instance.
075             *
076             * @param soapModel the soap model instance to convert
077             * @return the normal model instance
078             */
079            public static UserGroupRole toModel(UserGroupRoleSoap soapModel) {
080                    UserGroupRole model = new UserGroupRoleImpl();
081    
082                    model.setUserId(soapModel.getUserId());
083                    model.setGroupId(soapModel.getGroupId());
084                    model.setRoleId(soapModel.getRoleId());
085    
086                    return model;
087            }
088    
089            /**
090             * Converts the soap model instances into normal model instances.
091             *
092             * @param soapModels the soap model instances to convert
093             * @return the normal model instances
094             */
095            public static List<UserGroupRole> toModels(UserGroupRoleSoap[] soapModels) {
096                    List<UserGroupRole> models = new ArrayList<UserGroupRole>(soapModels.length);
097    
098                    for (UserGroupRoleSoap soapModel : soapModels) {
099                            models.add(toModel(soapModel));
100                    }
101    
102                    return models;
103            }
104    
105            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                                    "lock.expiration.time.com.liferay.portal.model.UserGroupRole"));
107    
108            public UserGroupRoleModelImpl() {
109            }
110    
111            public UserGroupRolePK getPrimaryKey() {
112                    return new UserGroupRolePK(_userId, _groupId, _roleId);
113            }
114    
115            public void setPrimaryKey(UserGroupRolePK pk) {
116                    setUserId(pk.userId);
117                    setGroupId(pk.groupId);
118                    setRoleId(pk.roleId);
119            }
120    
121            public Serializable getPrimaryKeyObj() {
122                    return new UserGroupRolePK(_userId, _groupId, _roleId);
123            }
124    
125            public long getUserId() {
126                    return _userId;
127            }
128    
129            public void setUserId(long userId) {
130                    _userId = userId;
131            }
132    
133            public String getUserUuid() throws SystemException {
134                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
135            }
136    
137            public void setUserUuid(String userUuid) {
138                    _userUuid = userUuid;
139            }
140    
141            public long getGroupId() {
142                    return _groupId;
143            }
144    
145            public void setGroupId(long groupId) {
146                    _groupId = groupId;
147            }
148    
149            public long getRoleId() {
150                    return _roleId;
151            }
152    
153            public void setRoleId(long roleId) {
154                    _roleId = roleId;
155            }
156    
157            public UserGroupRole toEscapedModel() {
158                    if (isEscapedModel()) {
159                            return (UserGroupRole)this;
160                    }
161                    else {
162                            return (UserGroupRole)Proxy.newProxyInstance(UserGroupRole.class.getClassLoader(),
163                                    new Class[] { UserGroupRole.class },
164                                    new AutoEscapeBeanHandler(this));
165                    }
166            }
167    
168            public Object clone() {
169                    UserGroupRoleImpl userGroupRoleImpl = new UserGroupRoleImpl();
170    
171                    userGroupRoleImpl.setUserId(getUserId());
172    
173                    userGroupRoleImpl.setGroupId(getGroupId());
174    
175                    userGroupRoleImpl.setRoleId(getRoleId());
176    
177                    return userGroupRoleImpl;
178            }
179    
180            public int compareTo(UserGroupRole userGroupRole) {
181                    UserGroupRolePK pk = userGroupRole.getPrimaryKey();
182    
183                    return getPrimaryKey().compareTo(pk);
184            }
185    
186            public boolean equals(Object obj) {
187                    if (obj == null) {
188                            return false;
189                    }
190    
191                    UserGroupRole userGroupRole = null;
192    
193                    try {
194                            userGroupRole = (UserGroupRole)obj;
195                    }
196                    catch (ClassCastException cce) {
197                            return false;
198                    }
199    
200                    UserGroupRolePK pk = userGroupRole.getPrimaryKey();
201    
202                    if (getPrimaryKey().equals(pk)) {
203                            return true;
204                    }
205                    else {
206                            return false;
207                    }
208            }
209    
210            public int hashCode() {
211                    return getPrimaryKey().hashCode();
212            }
213    
214            public String toString() {
215                    StringBundler sb = new StringBundler(7);
216    
217                    sb.append("{userId=");
218                    sb.append(getUserId());
219                    sb.append(", groupId=");
220                    sb.append(getGroupId());
221                    sb.append(", roleId=");
222                    sb.append(getRoleId());
223                    sb.append("}");
224    
225                    return sb.toString();
226            }
227    
228            public String toXmlString() {
229                    StringBundler sb = new StringBundler(13);
230    
231                    sb.append("<model><model-name>");
232                    sb.append("com.liferay.portal.model.UserGroupRole");
233                    sb.append("</model-name>");
234    
235                    sb.append(
236                            "<column><column-name>userId</column-name><column-value><![CDATA[");
237                    sb.append(getUserId());
238                    sb.append("]]></column-value></column>");
239                    sb.append(
240                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
241                    sb.append(getGroupId());
242                    sb.append("]]></column-value></column>");
243                    sb.append(
244                            "<column><column-name>roleId</column-name><column-value><![CDATA[");
245                    sb.append(getRoleId());
246                    sb.append("]]></column-value></column>");
247    
248                    sb.append("</model>");
249    
250                    return sb.toString();
251            }
252    
253            private long _userId;
254            private String _userUuid;
255            private long _groupId;
256            private long _roleId;
257    }