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     * 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 clone = new UserGroupRoleImpl();
170    
171                    clone.setUserId(getUserId());
172                    clone.setGroupId(getGroupId());
173                    clone.setRoleId(getRoleId());
174    
175                    return clone;
176            }
177    
178            public int compareTo(UserGroupRole userGroupRole) {
179                    UserGroupRolePK pk = userGroupRole.getPrimaryKey();
180    
181                    return getPrimaryKey().compareTo(pk);
182            }
183    
184            public boolean equals(Object obj) {
185                    if (obj == null) {
186                            return false;
187                    }
188    
189                    UserGroupRole userGroupRole = null;
190    
191                    try {
192                            userGroupRole = (UserGroupRole)obj;
193                    }
194                    catch (ClassCastException cce) {
195                            return false;
196                    }
197    
198                    UserGroupRolePK pk = userGroupRole.getPrimaryKey();
199    
200                    if (getPrimaryKey().equals(pk)) {
201                            return true;
202                    }
203                    else {
204                            return false;
205                    }
206            }
207    
208            public int hashCode() {
209                    return getPrimaryKey().hashCode();
210            }
211    
212            public String toString() {
213                    StringBundler sb = new StringBundler(7);
214    
215                    sb.append("{userId=");
216                    sb.append(getUserId());
217                    sb.append(", groupId=");
218                    sb.append(getGroupId());
219                    sb.append(", roleId=");
220                    sb.append(getRoleId());
221                    sb.append("}");
222    
223                    return sb.toString();
224            }
225    
226            public String toXmlString() {
227                    StringBundler sb = new StringBundler(13);
228    
229                    sb.append("<model><model-name>");
230                    sb.append("com.liferay.portal.model.UserGroupRole");
231                    sb.append("</model-name>");
232    
233                    sb.append(
234                            "<column><column-name>userId</column-name><column-value><![CDATA[");
235                    sb.append(getUserId());
236                    sb.append("]]></column-value></column>");
237                    sb.append(
238                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
239                    sb.append(getGroupId());
240                    sb.append("]]></column-value></column>");
241                    sb.append(
242                            "<column><column-name>roleId</column-name><column-value><![CDATA[");
243                    sb.append(getRoleId());
244                    sb.append("]]></column-value></column>");
245    
246                    sb.append("</model>");
247    
248                    return sb.toString();
249            }
250    
251            private long _userId;
252            private String _userUuid;
253            private long _groupId;
254            private long _roleId;
255    }