001    /**
002     * Copyright (c) 2000-2010 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     * <p>
038     * This interface is a model that represents the UserGroupRole table in the
039     * database.
040     * </p>
041     *
042     * @author    Brian Wing Shun Chan
043     * @see       UserGroupRoleImpl
044     * @see       com.liferay.portal.model.UserGroupRole
045     * @see       com.liferay.portal.model.UserGroupRoleModel
046     * @generated
047     */
048    public class UserGroupRoleModelImpl extends BaseModelImpl<UserGroupRole>
049            implements UserGroupRoleModel {
050            public static final String TABLE_NAME = "UserGroupRole";
051            public static final Object[][] TABLE_COLUMNS = {
052                            { "userId", new Integer(Types.BIGINT) },
053                            { "groupId", new Integer(Types.BIGINT) },
054                            { "roleId", new Integer(Types.BIGINT) }
055                    };
056            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))";
057            public static final String TABLE_SQL_DROP = "drop table UserGroupRole";
058            public static final String DATA_SOURCE = "liferayDataSource";
059            public static final String SESSION_FACTORY = "liferaySessionFactory";
060            public static final String TX_MANAGER = "liferayTransactionManager";
061            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
062                                    "value.object.entity.cache.enabled.com.liferay.portal.model.UserGroupRole"),
063                            true);
064            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
065                                    "value.object.finder.cache.enabled.com.liferay.portal.model.UserGroupRole"),
066                            true);
067    
068            public static UserGroupRole toModel(UserGroupRoleSoap soapModel) {
069                    UserGroupRole model = new UserGroupRoleImpl();
070    
071                    model.setUserId(soapModel.getUserId());
072                    model.setGroupId(soapModel.getGroupId());
073                    model.setRoleId(soapModel.getRoleId());
074    
075                    return model;
076            }
077    
078            public static List<UserGroupRole> toModels(UserGroupRoleSoap[] soapModels) {
079                    List<UserGroupRole> models = new ArrayList<UserGroupRole>(soapModels.length);
080    
081                    for (UserGroupRoleSoap soapModel : soapModels) {
082                            models.add(toModel(soapModel));
083                    }
084    
085                    return models;
086            }
087    
088            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
089                                    "lock.expiration.time.com.liferay.portal.model.UserGroupRole"));
090    
091            public UserGroupRoleModelImpl() {
092            }
093    
094            public UserGroupRolePK getPrimaryKey() {
095                    return new UserGroupRolePK(_userId, _groupId, _roleId);
096            }
097    
098            public void setPrimaryKey(UserGroupRolePK pk) {
099                    setUserId(pk.userId);
100                    setGroupId(pk.groupId);
101                    setRoleId(pk.roleId);
102            }
103    
104            public Serializable getPrimaryKeyObj() {
105                    return new UserGroupRolePK(_userId, _groupId, _roleId);
106            }
107    
108            public long getUserId() {
109                    return _userId;
110            }
111    
112            public void setUserId(long userId) {
113                    _userId = userId;
114            }
115    
116            public String getUserUuid() throws SystemException {
117                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
118            }
119    
120            public void setUserUuid(String userUuid) {
121                    _userUuid = userUuid;
122            }
123    
124            public long getGroupId() {
125                    return _groupId;
126            }
127    
128            public void setGroupId(long groupId) {
129                    _groupId = groupId;
130            }
131    
132            public long getRoleId() {
133                    return _roleId;
134            }
135    
136            public void setRoleId(long roleId) {
137                    _roleId = roleId;
138            }
139    
140            public UserGroupRole toEscapedModel() {
141                    if (isEscapedModel()) {
142                            return (UserGroupRole)this;
143                    }
144                    else {
145                            return (UserGroupRole)Proxy.newProxyInstance(UserGroupRole.class.getClassLoader(),
146                                    new Class[] { UserGroupRole.class },
147                                    new AutoEscapeBeanHandler(this));
148                    }
149            }
150    
151            public Object clone() {
152                    UserGroupRoleImpl clone = new UserGroupRoleImpl();
153    
154                    clone.setUserId(getUserId());
155                    clone.setGroupId(getGroupId());
156                    clone.setRoleId(getRoleId());
157    
158                    return clone;
159            }
160    
161            public int compareTo(UserGroupRole userGroupRole) {
162                    UserGroupRolePK pk = userGroupRole.getPrimaryKey();
163    
164                    return getPrimaryKey().compareTo(pk);
165            }
166    
167            public boolean equals(Object obj) {
168                    if (obj == null) {
169                            return false;
170                    }
171    
172                    UserGroupRole userGroupRole = null;
173    
174                    try {
175                            userGroupRole = (UserGroupRole)obj;
176                    }
177                    catch (ClassCastException cce) {
178                            return false;
179                    }
180    
181                    UserGroupRolePK pk = userGroupRole.getPrimaryKey();
182    
183                    if (getPrimaryKey().equals(pk)) {
184                            return true;
185                    }
186                    else {
187                            return false;
188                    }
189            }
190    
191            public int hashCode() {
192                    return getPrimaryKey().hashCode();
193            }
194    
195            public String toString() {
196                    StringBundler sb = new StringBundler(7);
197    
198                    sb.append("{userId=");
199                    sb.append(getUserId());
200                    sb.append(", groupId=");
201                    sb.append(getGroupId());
202                    sb.append(", roleId=");
203                    sb.append(getRoleId());
204                    sb.append("}");
205    
206                    return sb.toString();
207            }
208    
209            public String toXmlString() {
210                    StringBundler sb = new StringBundler(13);
211    
212                    sb.append("<model><model-name>");
213                    sb.append("com.liferay.portal.model.UserGroupRole");
214                    sb.append("</model-name>");
215    
216                    sb.append(
217                            "<column><column-name>userId</column-name><column-value><![CDATA[");
218                    sb.append(getUserId());
219                    sb.append("]]></column-value></column>");
220                    sb.append(
221                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
222                    sb.append(getGroupId());
223                    sb.append("]]></column-value></column>");
224                    sb.append(
225                            "<column><column-name>roleId</column-name><column-value><![CDATA[");
226                    sb.append(getRoleId());
227                    sb.append("]]></column-value></column>");
228    
229                    sb.append("</model>");
230    
231                    return sb.toString();
232            }
233    
234            private long _userId;
235            private String _userUuid;
236            private long _groupId;
237            private long _roleId;
238    }