1   /**
2    * Copyright (c) 2000-2008 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.OrgGroupRole;
28  import com.liferay.portal.model.OrgGroupRoleSoap;
29  import com.liferay.portal.service.persistence.OrgGroupRolePK;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="OrgGroupRoleModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>OrgGroupRole</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.OrgGroupRole
57   * @see com.liferay.portal.service.model.OrgGroupRoleModel
58   * @see com.liferay.portal.service.model.impl.OrgGroupRoleImpl
59   *
60   */
61  public class OrgGroupRoleModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "OrgGroupRole";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "organizationId", new Integer(Types.BIGINT) },
65              
66  
67              { "groupId", new Integer(Types.BIGINT) },
68              
69  
70              { "roleId", new Integer(Types.BIGINT) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table OrgGroupRole (organizationId LONG not null,groupId LONG not null,roleId LONG not null,primary key (organizationId, groupId, roleId))";
73      public static final String TABLE_SQL_DROP = "drop table OrgGroupRole";
74      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
75                  "value.object.finder.cache.enabled.com.liferay.portal.model.OrgGroupRole"),
76              true);
77  
78      public static OrgGroupRole toModel(OrgGroupRoleSoap soapModel) {
79          OrgGroupRole model = new OrgGroupRoleImpl();
80  
81          model.setOrganizationId(soapModel.getOrganizationId());
82          model.setGroupId(soapModel.getGroupId());
83          model.setRoleId(soapModel.getRoleId());
84  
85          return model;
86      }
87  
88      public static List<OrgGroupRole> toModels(OrgGroupRoleSoap[] soapModels) {
89          List<OrgGroupRole> models = new ArrayList<OrgGroupRole>(soapModels.length);
90  
91          for (OrgGroupRoleSoap soapModel : soapModels) {
92              models.add(toModel(soapModel));
93          }
94  
95          return models;
96      }
97  
98      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
99                  "lock.expiration.time.com.liferay.portal.model.OrgGroupRole"));
100 
101     public OrgGroupRoleModelImpl() {
102     }
103 
104     public OrgGroupRolePK getPrimaryKey() {
105         return new OrgGroupRolePK(_organizationId, _groupId, _roleId);
106     }
107 
108     public void setPrimaryKey(OrgGroupRolePK pk) {
109         setOrganizationId(pk.organizationId);
110         setGroupId(pk.groupId);
111         setRoleId(pk.roleId);
112     }
113 
114     public Serializable getPrimaryKeyObj() {
115         return new OrgGroupRolePK(_organizationId, _groupId, _roleId);
116     }
117 
118     public long getOrganizationId() {
119         return _organizationId;
120     }
121 
122     public void setOrganizationId(long organizationId) {
123         if (organizationId != _organizationId) {
124             _organizationId = organizationId;
125         }
126     }
127 
128     public long getGroupId() {
129         return _groupId;
130     }
131 
132     public void setGroupId(long groupId) {
133         if (groupId != _groupId) {
134             _groupId = groupId;
135         }
136     }
137 
138     public long getRoleId() {
139         return _roleId;
140     }
141 
142     public void setRoleId(long roleId) {
143         if (roleId != _roleId) {
144             _roleId = roleId;
145         }
146     }
147 
148     public OrgGroupRole toEscapedModel() {
149         if (isEscapedModel()) {
150             return (OrgGroupRole)this;
151         }
152         else {
153             OrgGroupRole model = new OrgGroupRoleImpl();
154 
155             model.setEscapedModel(true);
156 
157             model.setOrganizationId(getOrganizationId());
158             model.setGroupId(getGroupId());
159             model.setRoleId(getRoleId());
160 
161             model = (OrgGroupRole)Proxy.newProxyInstance(OrgGroupRole.class.getClassLoader(),
162                     new Class[] { OrgGroupRole.class },
163                     new ReadOnlyBeanHandler(model));
164 
165             return model;
166         }
167     }
168 
169     public Object clone() {
170         OrgGroupRoleImpl clone = new OrgGroupRoleImpl();
171 
172         clone.setOrganizationId(getOrganizationId());
173         clone.setGroupId(getGroupId());
174         clone.setRoleId(getRoleId());
175 
176         return clone;
177     }
178 
179     public int compareTo(Object obj) {
180         if (obj == null) {
181             return -1;
182         }
183 
184         OrgGroupRoleImpl orgGroupRole = (OrgGroupRoleImpl)obj;
185 
186         OrgGroupRolePK pk = orgGroupRole.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         OrgGroupRoleImpl orgGroupRole = null;
197 
198         try {
199             orgGroupRole = (OrgGroupRoleImpl)obj;
200         }
201         catch (ClassCastException cce) {
202             return false;
203         }
204 
205         OrgGroupRolePK pk = orgGroupRole.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     private long _organizationId;
220     private long _groupId;
221     private long _roleId;
222 }