1   /**
2    * Copyright (c) 2000-2007 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.service.persistence.UserGroupRolePK;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import java.io.Serializable;
31  
32  import java.sql.Types;
33  
34  /**
35   * <a href="UserGroupRoleModelImpl.java.html"><b><i>View Source</i></b></a>
36   *
37   * <p>
38   * ServiceBuilder generated this class. Modifications in this class will be overwritten
39   * the next time is generated.
40   * </p>
41   *
42   * <p>
43   * This class is a model that represents the <code>UserGroupRole</code> table in
44   * the database.
45   * </p>
46   *
47   * @author Brian Wing Shun Chan
48   *
49   * @see com.liferay.portal.service.model.UserGroupRole
50   * @see com.liferay.portal.service.model.UserGroupRoleModel
51   * @see com.liferay.portal.service.model.impl.UserGroupRoleImpl
52   *
53   */
54  public class UserGroupRoleModelImpl extends BaseModelImpl {
55      public static String TABLE_NAME = "UserGroupRole";
56      public static Object[][] TABLE_COLUMNS = {
57              { "userId", new Integer(Types.BIGINT) },
58              { "groupId", new Integer(Types.BIGINT) },
59              { "roleId", new Integer(Types.BIGINT) }
60          };
61      public static String TABLE_SQL_CREATE = "create table UserGroupRole (userId LONG not null,groupId LONG not null,roleId LONG not null,primary key (userId, groupId, roleId))";
62      public static String TABLE_SQL_DROP = "drop table UserGroupRole";
63      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
64                  "xss.allow.com.liferay.portal.model.UserGroupRole"), XSS_ALLOW);
65      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
66                  "lock.expiration.time.com.liferay.portal.model.UserGroupRoleModel"));
67  
68      public UserGroupRoleModelImpl() {
69      }
70  
71      public UserGroupRolePK getPrimaryKey() {
72          return new UserGroupRolePK(_userId, _groupId, _roleId);
73      }
74  
75      public void setPrimaryKey(UserGroupRolePK pk) {
76          setUserId(pk.userId);
77          setGroupId(pk.groupId);
78          setRoleId(pk.roleId);
79      }
80  
81      public Serializable getPrimaryKeyObj() {
82          return new UserGroupRolePK(_userId, _groupId, _roleId);
83      }
84  
85      public long getUserId() {
86          return _userId;
87      }
88  
89      public void setUserId(long userId) {
90          if (userId != _userId) {
91              _userId = userId;
92          }
93      }
94  
95      public long getGroupId() {
96          return _groupId;
97      }
98  
99      public void setGroupId(long groupId) {
100         if (groupId != _groupId) {
101             _groupId = groupId;
102         }
103     }
104 
105     public long getRoleId() {
106         return _roleId;
107     }
108 
109     public void setRoleId(long roleId) {
110         if (roleId != _roleId) {
111             _roleId = roleId;
112         }
113     }
114 
115     public Object clone() {
116         UserGroupRoleImpl clone = new UserGroupRoleImpl();
117         clone.setUserId(getUserId());
118         clone.setGroupId(getGroupId());
119         clone.setRoleId(getRoleId());
120 
121         return clone;
122     }
123 
124     public int compareTo(Object obj) {
125         if (obj == null) {
126             return -1;
127         }
128 
129         UserGroupRoleImpl userGroupRole = (UserGroupRoleImpl)obj;
130         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
131 
132         return getPrimaryKey().compareTo(pk);
133     }
134 
135     public boolean equals(Object obj) {
136         if (obj == null) {
137             return false;
138         }
139 
140         UserGroupRoleImpl userGroupRole = null;
141 
142         try {
143             userGroupRole = (UserGroupRoleImpl)obj;
144         }
145         catch (ClassCastException cce) {
146             return false;
147         }
148 
149         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
150 
151         if (getPrimaryKey().equals(pk)) {
152             return true;
153         }
154         else {
155             return false;
156         }
157     }
158 
159     public int hashCode() {
160         return getPrimaryKey().hashCode();
161     }
162 
163     private long _userId;
164     private long _groupId;
165     private long _roleId;
166 }