1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.UserGroupRole;
22  import com.liferay.portal.model.UserGroupRoleSoap;
23  import com.liferay.portal.service.persistence.UserGroupRolePK;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import java.io.Serializable;
27  
28  import java.lang.reflect.Proxy;
29  
30  import java.sql.Types;
31  
32  import java.util.ArrayList;
33  import java.util.List;
34  
35  /**
36   * <a href="UserGroupRoleModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be
40   * overwritten the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This interface is a model that represents the UserGroupRole table in the
45   * database.
46   * </p>
47   *
48   * @author    Brian Wing Shun Chan
49   * @see       UserGroupRoleImpl
50   * @see       com.liferay.portal.model.UserGroupRole
51   * @see       com.liferay.portal.model.UserGroupRoleModel
52   * @generated
53   */
54  public class UserGroupRoleModelImpl extends BaseModelImpl<UserGroupRole> {
55      public static final String TABLE_NAME = "UserGroupRole";
56      public static final 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 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))";
62      public static final String TABLE_SQL_DROP = "drop table UserGroupRole";
63      public static final String DATA_SOURCE = "liferayDataSource";
64      public static final String SESSION_FACTORY = "liferaySessionFactory";
65      public static final String TX_MANAGER = "liferayTransactionManager";
66      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
67                  "value.object.entity.cache.enabled.com.liferay.portal.model.UserGroupRole"),
68              true);
69      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
70                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserGroupRole"),
71              true);
72  
73      public static UserGroupRole toModel(UserGroupRoleSoap soapModel) {
74          UserGroupRole model = new UserGroupRoleImpl();
75  
76          model.setUserId(soapModel.getUserId());
77          model.setGroupId(soapModel.getGroupId());
78          model.setRoleId(soapModel.getRoleId());
79  
80          return model;
81      }
82  
83      public static List<UserGroupRole> toModels(UserGroupRoleSoap[] soapModels) {
84          List<UserGroupRole> models = new ArrayList<UserGroupRole>(soapModels.length);
85  
86          for (UserGroupRoleSoap soapModel : soapModels) {
87              models.add(toModel(soapModel));
88          }
89  
90          return models;
91      }
92  
93      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
94                  "lock.expiration.time.com.liferay.portal.model.UserGroupRole"));
95  
96      public UserGroupRoleModelImpl() {
97      }
98  
99      public UserGroupRolePK getPrimaryKey() {
100         return new UserGroupRolePK(_userId, _groupId, _roleId);
101     }
102 
103     public void setPrimaryKey(UserGroupRolePK pk) {
104         setUserId(pk.userId);
105         setGroupId(pk.groupId);
106         setRoleId(pk.roleId);
107     }
108 
109     public Serializable getPrimaryKeyObj() {
110         return new UserGroupRolePK(_userId, _groupId, _roleId);
111     }
112 
113     public long getUserId() {
114         return _userId;
115     }
116 
117     public void setUserId(long userId) {
118         _userId = userId;
119     }
120 
121     public String getUserUuid() throws SystemException {
122         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
123     }
124 
125     public void setUserUuid(String userUuid) {
126         _userUuid = userUuid;
127     }
128 
129     public long getGroupId() {
130         return _groupId;
131     }
132 
133     public void setGroupId(long groupId) {
134         _groupId = groupId;
135     }
136 
137     public long getRoleId() {
138         return _roleId;
139     }
140 
141     public void setRoleId(long roleId) {
142         _roleId = roleId;
143     }
144 
145     public UserGroupRole toEscapedModel() {
146         if (isEscapedModel()) {
147             return (UserGroupRole)this;
148         }
149         else {
150             UserGroupRole model = new UserGroupRoleImpl();
151 
152             model.setNew(isNew());
153             model.setEscapedModel(true);
154 
155             model.setUserId(getUserId());
156             model.setGroupId(getGroupId());
157             model.setRoleId(getRoleId());
158 
159             model = (UserGroupRole)Proxy.newProxyInstance(UserGroupRole.class.getClassLoader(),
160                     new Class[] { UserGroupRole.class },
161                     new ReadOnlyBeanHandler(model));
162 
163             return model;
164         }
165     }
166 
167     public Object clone() {
168         UserGroupRoleImpl clone = new UserGroupRoleImpl();
169 
170         clone.setUserId(getUserId());
171         clone.setGroupId(getGroupId());
172         clone.setRoleId(getRoleId());
173 
174         return clone;
175     }
176 
177     public int compareTo(UserGroupRole userGroupRole) {
178         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
179 
180         return getPrimaryKey().compareTo(pk);
181     }
182 
183     public boolean equals(Object obj) {
184         if (obj == null) {
185             return false;
186         }
187 
188         UserGroupRole userGroupRole = null;
189 
190         try {
191             userGroupRole = (UserGroupRole)obj;
192         }
193         catch (ClassCastException cce) {
194             return false;
195         }
196 
197         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
198 
199         if (getPrimaryKey().equals(pk)) {
200             return true;
201         }
202         else {
203             return false;
204         }
205     }
206 
207     public int hashCode() {
208         return getPrimaryKey().hashCode();
209     }
210 
211     public String toString() {
212         StringBundler sb = new StringBundler(7);
213 
214         sb.append("{userId=");
215         sb.append(getUserId());
216         sb.append(", groupId=");
217         sb.append(getGroupId());
218         sb.append(", roleId=");
219         sb.append(getRoleId());
220         sb.append("}");
221 
222         return sb.toString();
223     }
224 
225     public String toXmlString() {
226         StringBundler sb = new StringBundler(13);
227 
228         sb.append("<model><model-name>");
229         sb.append("com.liferay.portal.model.UserGroupRole");
230         sb.append("</model-name>");
231 
232         sb.append(
233             "<column><column-name>userId</column-name><column-value><![CDATA[");
234         sb.append(getUserId());
235         sb.append("]]></column-value></column>");
236         sb.append(
237             "<column><column-name>groupId</column-name><column-value><![CDATA[");
238         sb.append(getGroupId());
239         sb.append("]]></column-value></column>");
240         sb.append(
241             "<column><column-name>roleId</column-name><column-value><![CDATA[");
242         sb.append(getRoleId());
243         sb.append("]]></column-value></column>");
244 
245         sb.append("</model>");
246 
247         return sb.toString();
248     }
249 
250     private long _userId;
251     private String _userUuid;
252     private long _groupId;
253     private long _roleId;
254 }