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