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.model.UserGroupRoleSoap;
29  import com.liferay.portal.service.persistence.UserGroupRolePK;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="UserGroupRoleModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>UserGroupRole</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portal.service.model.UserGroupRole
56   * @see com.liferay.portal.service.model.UserGroupRoleModel
57   * @see com.liferay.portal.service.model.impl.UserGroupRoleImpl
58   *
59   */
60  public class UserGroupRoleModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "UserGroupRole";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "userId", new Integer(Types.BIGINT) },
64              
65  
66              { "groupId", new Integer(Types.BIGINT) },
67              
68  
69              { "roleId", new Integer(Types.BIGINT) }
70          };
71      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))";
72      public static final String TABLE_SQL_DROP = "drop table UserGroupRole";
73      public static final String DATA_SOURCE = "liferayDataSource";
74      public static final String SESSION_FACTORY = "liferaySessionFactory";
75      public static final String TX_MANAGER = "liferayTransactionManager";
76      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserGroupRole"),
78              true);
79  
80      public static UserGroupRole toModel(UserGroupRoleSoap soapModel) {
81          UserGroupRole model = new UserGroupRoleImpl();
82  
83          model.setUserId(soapModel.getUserId());
84          model.setGroupId(soapModel.getGroupId());
85          model.setRoleId(soapModel.getRoleId());
86  
87          return model;
88      }
89  
90      public static List<UserGroupRole> toModels(UserGroupRoleSoap[] soapModels) {
91          List<UserGroupRole> models = new ArrayList<UserGroupRole>(soapModels.length);
92  
93          for (UserGroupRoleSoap soapModel : soapModels) {
94              models.add(toModel(soapModel));
95          }
96  
97          return models;
98      }
99  
100     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
101                 "lock.expiration.time.com.liferay.portal.model.UserGroupRole"));
102 
103     public UserGroupRoleModelImpl() {
104     }
105 
106     public UserGroupRolePK getPrimaryKey() {
107         return new UserGroupRolePK(_userId, _groupId, _roleId);
108     }
109 
110     public void setPrimaryKey(UserGroupRolePK pk) {
111         setUserId(pk.userId);
112         setGroupId(pk.groupId);
113         setRoleId(pk.roleId);
114     }
115 
116     public Serializable getPrimaryKeyObj() {
117         return new UserGroupRolePK(_userId, _groupId, _roleId);
118     }
119 
120     public long getUserId() {
121         return _userId;
122     }
123 
124     public void setUserId(long userId) {
125         if (userId != _userId) {
126             _userId = userId;
127         }
128     }
129 
130     public long getGroupId() {
131         return _groupId;
132     }
133 
134     public void setGroupId(long groupId) {
135         if (groupId != _groupId) {
136             _groupId = groupId;
137         }
138     }
139 
140     public long getRoleId() {
141         return _roleId;
142     }
143 
144     public void setRoleId(long roleId) {
145         if (roleId != _roleId) {
146             _roleId = roleId;
147         }
148     }
149 
150     public UserGroupRole toEscapedModel() {
151         if (isEscapedModel()) {
152             return (UserGroupRole)this;
153         }
154         else {
155             UserGroupRole model = new UserGroupRoleImpl();
156 
157             model.setEscapedModel(true);
158 
159             model.setUserId(getUserId());
160             model.setGroupId(getGroupId());
161             model.setRoleId(getRoleId());
162 
163             model = (UserGroupRole)Proxy.newProxyInstance(UserGroupRole.class.getClassLoader(),
164                     new Class[] { UserGroupRole.class },
165                     new ReadOnlyBeanHandler(model));
166 
167             return model;
168         }
169     }
170 
171     public Object clone() {
172         UserGroupRoleImpl clone = new UserGroupRoleImpl();
173 
174         clone.setUserId(getUserId());
175         clone.setGroupId(getGroupId());
176         clone.setRoleId(getRoleId());
177 
178         return clone;
179     }
180 
181     public int compareTo(Object obj) {
182         if (obj == null) {
183             return -1;
184         }
185 
186         UserGroupRoleImpl userGroupRole = (UserGroupRoleImpl)obj;
187 
188         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
189 
190         return getPrimaryKey().compareTo(pk);
191     }
192 
193     public boolean equals(Object obj) {
194         if (obj == null) {
195             return false;
196         }
197 
198         UserGroupRoleImpl userGroupRole = null;
199 
200         try {
201             userGroupRole = (UserGroupRoleImpl)obj;
202         }
203         catch (ClassCastException cce) {
204             return false;
205         }
206 
207         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
208 
209         if (getPrimaryKey().equals(pk)) {
210             return true;
211         }
212         else {
213             return false;
214         }
215     }
216 
217     public int hashCode() {
218         return getPrimaryKey().hashCode();
219     }
220 
221     private long _userId;
222     private long _groupId;
223     private long _roleId;
224 }