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