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