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 interface is a model that represents the UserGroupRole table in the
52   * database.
53   * </p>
54   *
55   * @author    Brian Wing Shun Chan
56   * @see       UserGroupRoleImpl
57   * @see       com.liferay.portal.model.UserGroupRole
58   * @see       com.liferay.portal.model.UserGroupRoleModel
59   * @generated
60   */
61  public class UserGroupRoleModelImpl extends BaseModelImpl<UserGroupRole> {
62      public static final String TABLE_NAME = "UserGroupRole";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "userId", new Integer(Types.BIGINT) },
65              { "groupId", new Integer(Types.BIGINT) },
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 String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.entity.cache.enabled.com.liferay.portal.model.UserGroupRole"),
75              true);
76      public static final boolean FINDER_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         _userId = userId;
126     }
127 
128     public String getUserUuid() throws SystemException {
129         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
130     }
131 
132     public void setUserUuid(String userUuid) {
133         _userUuid = userUuid;
134     }
135 
136     public long getGroupId() {
137         return _groupId;
138     }
139 
140     public void setGroupId(long groupId) {
141         _groupId = groupId;
142     }
143 
144     public long getRoleId() {
145         return _roleId;
146     }
147 
148     public void setRoleId(long roleId) {
149         _roleId = roleId;
150     }
151 
152     public UserGroupRole toEscapedModel() {
153         if (isEscapedModel()) {
154             return (UserGroupRole)this;
155         }
156         else {
157             UserGroupRole model = new UserGroupRoleImpl();
158 
159             model.setNew(isNew());
160             model.setEscapedModel(true);
161 
162             model.setUserId(getUserId());
163             model.setGroupId(getGroupId());
164             model.setRoleId(getRoleId());
165 
166             model = (UserGroupRole)Proxy.newProxyInstance(UserGroupRole.class.getClassLoader(),
167                     new Class[] { UserGroupRole.class },
168                     new ReadOnlyBeanHandler(model));
169 
170             return model;
171         }
172     }
173 
174     public Object clone() {
175         UserGroupRoleImpl clone = new UserGroupRoleImpl();
176 
177         clone.setUserId(getUserId());
178         clone.setGroupId(getGroupId());
179         clone.setRoleId(getRoleId());
180 
181         return clone;
182     }
183 
184     public int compareTo(UserGroupRole userGroupRole) {
185         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
186 
187         return getPrimaryKey().compareTo(pk);
188     }
189 
190     public boolean equals(Object obj) {
191         if (obj == null) {
192             return false;
193         }
194 
195         UserGroupRole userGroupRole = null;
196 
197         try {
198             userGroupRole = (UserGroupRole)obj;
199         }
200         catch (ClassCastException cce) {
201             return false;
202         }
203 
204         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
205 
206         if (getPrimaryKey().equals(pk)) {
207             return true;
208         }
209         else {
210             return false;
211         }
212     }
213 
214     public int hashCode() {
215         return getPrimaryKey().hashCode();
216     }
217 
218     public String toString() {
219         StringBuilder sb = new StringBuilder();
220 
221         sb.append("{userId=");
222         sb.append(getUserId());
223         sb.append(", groupId=");
224         sb.append(getGroupId());
225         sb.append(", roleId=");
226         sb.append(getRoleId());
227         sb.append("}");
228 
229         return sb.toString();
230     }
231 
232     public String toXmlString() {
233         StringBuilder sb = new StringBuilder();
234 
235         sb.append("<model><model-name>");
236         sb.append("com.liferay.portal.model.UserGroupRole");
237         sb.append("</model-name>");
238 
239         sb.append(
240             "<column><column-name>userId</column-name><column-value><![CDATA[");
241         sb.append(getUserId());
242         sb.append("]]></column-value></column>");
243         sb.append(
244             "<column><column-name>groupId</column-name><column-value><![CDATA[");
245         sb.append(getGroupId());
246         sb.append("]]></column-value></column>");
247         sb.append(
248             "<column><column-name>roleId</column-name><column-value><![CDATA[");
249         sb.append(getRoleId());
250         sb.append("]]></column-value></column>");
251 
252         sb.append("</model>");
253 
254         return sb.toString();
255     }
256 
257     private long _userId;
258     private String _userUuid;
259     private long _groupId;
260     private long _roleId;
261 }