1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.UserGroupRole;
28  import com.liferay.portal.service.persistence.UserGroupRolePK;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  /**
38   * <a href="UserGroupRoleModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>UserGroupRole</code> table
47   * in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.service.model.UserGroupRole
53   * @see com.liferay.portal.service.model.UserGroupRoleModel
54   * @see com.liferay.portal.service.model.impl.UserGroupRoleImpl
55   *
56   */
57  public class UserGroupRoleModelImpl extends BaseModelImpl {
58      public static final String TABLE_NAME = "UserGroupRole";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "userId", new Integer(Types.BIGINT) },
61              
62  
63              { "groupId", new Integer(Types.BIGINT) },
64              
65  
66              { "roleId", new Integer(Types.BIGINT) }
67          };
68      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))";
69      public static final String TABLE_SQL_DROP = "drop table UserGroupRole";
70      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
71                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserGroupRole"),
72              true);
73      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
74                  "lock.expiration.time.com.liferay.portal.model.UserGroupRole"));
75  
76      public UserGroupRoleModelImpl() {
77      }
78  
79      public UserGroupRolePK getPrimaryKey() {
80          return new UserGroupRolePK(_userId, _groupId, _roleId);
81      }
82  
83      public void setPrimaryKey(UserGroupRolePK pk) {
84          setUserId(pk.userId);
85          setGroupId(pk.groupId);
86          setRoleId(pk.roleId);
87      }
88  
89      public Serializable getPrimaryKeyObj() {
90          return new UserGroupRolePK(_userId, _groupId, _roleId);
91      }
92  
93      public long getUserId() {
94          return _userId;
95      }
96  
97      public void setUserId(long userId) {
98          if (userId != _userId) {
99              _userId = userId;
100         }
101     }
102 
103     public long getGroupId() {
104         return _groupId;
105     }
106 
107     public void setGroupId(long groupId) {
108         if (groupId != _groupId) {
109             _groupId = groupId;
110         }
111     }
112 
113     public long getRoleId() {
114         return _roleId;
115     }
116 
117     public void setRoleId(long roleId) {
118         if (roleId != _roleId) {
119             _roleId = roleId;
120         }
121     }
122 
123     public UserGroupRole toEscapedModel() {
124         if (isEscapedModel()) {
125             return (UserGroupRole)this;
126         }
127         else {
128             UserGroupRole model = new UserGroupRoleImpl();
129 
130             model.setEscapedModel(true);
131 
132             model.setUserId(getUserId());
133             model.setGroupId(getGroupId());
134             model.setRoleId(getRoleId());
135 
136             model = (UserGroupRole)Proxy.newProxyInstance(UserGroupRole.class.getClassLoader(),
137                     new Class[] { UserGroupRole.class },
138                     new ReadOnlyBeanHandler(model));
139 
140             return model;
141         }
142     }
143 
144     public Object clone() {
145         UserGroupRoleImpl clone = new UserGroupRoleImpl();
146 
147         clone.setUserId(getUserId());
148         clone.setGroupId(getGroupId());
149         clone.setRoleId(getRoleId());
150 
151         return clone;
152     }
153 
154     public int compareTo(Object obj) {
155         if (obj == null) {
156             return -1;
157         }
158 
159         UserGroupRoleImpl userGroupRole = (UserGroupRoleImpl)obj;
160 
161         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
162 
163         return getPrimaryKey().compareTo(pk);
164     }
165 
166     public boolean equals(Object obj) {
167         if (obj == null) {
168             return false;
169         }
170 
171         UserGroupRoleImpl userGroupRole = null;
172 
173         try {
174             userGroupRole = (UserGroupRoleImpl)obj;
175         }
176         catch (ClassCastException cce) {
177             return false;
178         }
179 
180         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
181 
182         if (getPrimaryKey().equals(pk)) {
183             return true;
184         }
185         else {
186             return false;
187         }
188     }
189 
190     public int hashCode() {
191         return getPrimaryKey().hashCode();
192     }
193 
194     private long _userId;
195     private long _groupId;
196     private long _roleId;
197 }