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