1   /**
2    * Copyright (c) 2000-2009 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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.UserGroupRole;
29  import com.liferay.portal.model.UserGroupRoleSoap;
30  import com.liferay.portal.service.persistence.UserGroupRolePK;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  
42  /**
43   * <a href="UserGroupRoleModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>UserGroupRole</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portal.model.UserGroupRole
58   * @see com.liferay.portal.model.UserGroupRoleModel
59   * @see com.liferay.portal.model.impl.UserGroupRoleImpl
60   *
61   */
62  public class UserGroupRoleModelImpl extends BaseModelImpl<UserGroupRole> {
63      public static final String TABLE_NAME = "UserGroupRole";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "userId", new Integer(Types.BIGINT) },
66              
67  
68              { "groupId", new Integer(Types.BIGINT) },
69              
70  
71              { "roleId", new Integer(Types.BIGINT) }
72          };
73      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))";
74      public static final String TABLE_SQL_DROP = "drop table UserGroupRole";
75      public static final String DATA_SOURCE = "liferayDataSource";
76      public static final String SESSION_FACTORY = "liferaySessionFactory";
77      public static final String TX_MANAGER = "liferayTransactionManager";
78      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.entity.cache.enabled.com.liferay.portal.model.UserGroupRole"),
80              true);
81      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserGroupRole"),
83              true);
84  
85      public static UserGroupRole toModel(UserGroupRoleSoap soapModel) {
86          UserGroupRole model = new UserGroupRoleImpl();
87  
88          model.setUserId(soapModel.getUserId());
89          model.setGroupId(soapModel.getGroupId());
90          model.setRoleId(soapModel.getRoleId());
91  
92          return model;
93      }
94  
95      public static List<UserGroupRole> toModels(UserGroupRoleSoap[] soapModels) {
96          List<UserGroupRole> models = new ArrayList<UserGroupRole>(soapModels.length);
97  
98          for (UserGroupRoleSoap soapModel : soapModels) {
99              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             UserGroupRole model = new UserGroupRoleImpl();
163 
164             model.setNew(isNew());
165             model.setEscapedModel(true);
166 
167             model.setUserId(getUserId());
168             model.setGroupId(getGroupId());
169             model.setRoleId(getRoleId());
170 
171             model = (UserGroupRole)Proxy.newProxyInstance(UserGroupRole.class.getClassLoader(),
172                     new Class[] { UserGroupRole.class },
173                     new ReadOnlyBeanHandler(model));
174 
175             return model;
176         }
177     }
178 
179     public Object clone() {
180         UserGroupRoleImpl clone = new UserGroupRoleImpl();
181 
182         clone.setUserId(getUserId());
183         clone.setGroupId(getGroupId());
184         clone.setRoleId(getRoleId());
185 
186         return clone;
187     }
188 
189     public int compareTo(UserGroupRole userGroupRole) {
190         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
191 
192         return getPrimaryKey().compareTo(pk);
193     }
194 
195     public boolean equals(Object obj) {
196         if (obj == null) {
197             return false;
198         }
199 
200         UserGroupRole userGroupRole = null;
201 
202         try {
203             userGroupRole = (UserGroupRole)obj;
204         }
205         catch (ClassCastException cce) {
206             return false;
207         }
208 
209         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
210 
211         if (getPrimaryKey().equals(pk)) {
212             return true;
213         }
214         else {
215             return false;
216         }
217     }
218 
219     public int hashCode() {
220         return getPrimaryKey().hashCode();
221     }
222 
223     public String toString() {
224         StringBuilder sb = new StringBuilder();
225 
226         sb.append("{userId=");
227         sb.append(getUserId());
228         sb.append(", groupId=");
229         sb.append(getGroupId());
230         sb.append(", roleId=");
231         sb.append(getRoleId());
232         sb.append("}");
233 
234         return sb.toString();
235     }
236 
237     public String toXmlString() {
238         StringBuilder sb = new StringBuilder();
239 
240         sb.append("<model><model-name>");
241         sb.append("com.liferay.portal.model.UserGroupRole");
242         sb.append("</model-name>");
243 
244         sb.append(
245             "<column><column-name>userId</column-name><column-value><![CDATA[");
246         sb.append(getUserId());
247         sb.append("]]></column-value></column>");
248         sb.append(
249             "<column><column-name>groupId</column-name><column-value><![CDATA[");
250         sb.append(getGroupId());
251         sb.append("]]></column-value></column>");
252         sb.append(
253             "<column><column-name>roleId</column-name><column-value><![CDATA[");
254         sb.append(getRoleId());
255         sb.append("]]></column-value></column>");
256 
257         sb.append("</model>");
258 
259         return sb.toString();
260     }
261 
262     private long _userId;
263     private String _userUuid;
264     private long _groupId;
265     private long _roleId;
266 }