1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
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             return (UserGroupRole)Proxy.newProxyInstance(UserGroupRole.class.getClassLoader(),
151                 new Class[] { UserGroupRole.class },
152                 new AutoEscapeBeanHandler(this));
153         }
154     }
155 
156     public Object clone() {
157         UserGroupRoleImpl clone = new UserGroupRoleImpl();
158 
159         clone.setUserId(getUserId());
160         clone.setGroupId(getGroupId());
161         clone.setRoleId(getRoleId());
162 
163         return clone;
164     }
165 
166     public int compareTo(UserGroupRole userGroupRole) {
167         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
168 
169         return getPrimaryKey().compareTo(pk);
170     }
171 
172     public boolean equals(Object obj) {
173         if (obj == null) {
174             return false;
175         }
176 
177         UserGroupRole userGroupRole = null;
178 
179         try {
180             userGroupRole = (UserGroupRole)obj;
181         }
182         catch (ClassCastException cce) {
183             return false;
184         }
185 
186         UserGroupRolePK pk = userGroupRole.getPrimaryKey();
187 
188         if (getPrimaryKey().equals(pk)) {
189             return true;
190         }
191         else {
192             return false;
193         }
194     }
195 
196     public int hashCode() {
197         return getPrimaryKey().hashCode();
198     }
199 
200     public String toString() {
201         StringBundler sb = new StringBundler(7);
202 
203         sb.append("{userId=");
204         sb.append(getUserId());
205         sb.append(", groupId=");
206         sb.append(getGroupId());
207         sb.append(", roleId=");
208         sb.append(getRoleId());
209         sb.append("}");
210 
211         return sb.toString();
212     }
213 
214     public String toXmlString() {
215         StringBundler sb = new StringBundler(13);
216 
217         sb.append("<model><model-name>");
218         sb.append("com.liferay.portal.model.UserGroupRole");
219         sb.append("</model-name>");
220 
221         sb.append(
222             "<column><column-name>userId</column-name><column-value><![CDATA[");
223         sb.append(getUserId());
224         sb.append("]]></column-value></column>");
225         sb.append(
226             "<column><column-name>groupId</column-name><column-value><![CDATA[");
227         sb.append(getGroupId());
228         sb.append("]]></column-value></column>");
229         sb.append(
230             "<column><column-name>roleId</column-name><column-value><![CDATA[");
231         sb.append(getRoleId());
232         sb.append("]]></column-value></column>");
233 
234         sb.append("</model>");
235 
236         return sb.toString();
237     }
238 
239     private long _userId;
240     private String _userUuid;
241     private long _groupId;
242     private long _roleId;
243 }