1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.kernel.util.StringBundler;
28  import com.liferay.portal.model.OrgGroupRole;
29  import com.liferay.portal.model.OrgGroupRoleSoap;
30  import com.liferay.portal.service.persistence.OrgGroupRolePK;
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 interface is a model that represents the OrgGroupRole table in the
51   * database.
52   * </p>
53   *
54   * @author    Brian Wing Shun Chan
55   * @see       OrgGroupRoleImpl
56   * @see       com.liferay.portal.model.OrgGroupRole
57   * @see       com.liferay.portal.model.OrgGroupRoleModel
58   * @generated
59   */
60  public class OrgGroupRoleModelImpl extends BaseModelImpl<OrgGroupRole> {
61      public static final String TABLE_NAME = "OrgGroupRole";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "organizationId", new Integer(Types.BIGINT) },
64              { "groupId", new Integer(Types.BIGINT) },
65              { "roleId", new Integer(Types.BIGINT) }
66          };
67      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))";
68      public static final String TABLE_SQL_DROP = "drop table OrgGroupRole";
69      public static final String DATA_SOURCE = "liferayDataSource";
70      public static final String SESSION_FACTORY = "liferaySessionFactory";
71      public static final String TX_MANAGER = "liferayTransactionManager";
72      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
73                  "value.object.entity.cache.enabled.com.liferay.portal.model.OrgGroupRole"),
74              true);
75      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.finder.cache.enabled.com.liferay.portal.model.OrgGroupRole"),
77              true);
78  
79      public static OrgGroupRole toModel(OrgGroupRoleSoap soapModel) {
80          OrgGroupRole model = new OrgGroupRoleImpl();
81  
82          model.setOrganizationId(soapModel.getOrganizationId());
83          model.setGroupId(soapModel.getGroupId());
84          model.setRoleId(soapModel.getRoleId());
85  
86          return model;
87      }
88  
89      public static List<OrgGroupRole> toModels(OrgGroupRoleSoap[] soapModels) {
90          List<OrgGroupRole> models = new ArrayList<OrgGroupRole>(soapModels.length);
91  
92          for (OrgGroupRoleSoap soapModel : soapModels) {
93              models.add(toModel(soapModel));
94          }
95  
96          return models;
97      }
98  
99      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
100                 "lock.expiration.time.com.liferay.portal.model.OrgGroupRole"));
101 
102     public OrgGroupRoleModelImpl() {
103     }
104 
105     public OrgGroupRolePK getPrimaryKey() {
106         return new OrgGroupRolePK(_organizationId, _groupId, _roleId);
107     }
108 
109     public void setPrimaryKey(OrgGroupRolePK pk) {
110         setOrganizationId(pk.organizationId);
111         setGroupId(pk.groupId);
112         setRoleId(pk.roleId);
113     }
114 
115     public Serializable getPrimaryKeyObj() {
116         return new OrgGroupRolePK(_organizationId, _groupId, _roleId);
117     }
118 
119     public long getOrganizationId() {
120         return _organizationId;
121     }
122 
123     public void setOrganizationId(long organizationId) {
124         _organizationId = organizationId;
125     }
126 
127     public long getGroupId() {
128         return _groupId;
129     }
130 
131     public void setGroupId(long groupId) {
132         _groupId = groupId;
133     }
134 
135     public long getRoleId() {
136         return _roleId;
137     }
138 
139     public void setRoleId(long roleId) {
140         _roleId = roleId;
141     }
142 
143     public OrgGroupRole toEscapedModel() {
144         if (isEscapedModel()) {
145             return (OrgGroupRole)this;
146         }
147         else {
148             OrgGroupRole model = new OrgGroupRoleImpl();
149 
150             model.setNew(isNew());
151             model.setEscapedModel(true);
152 
153             model.setOrganizationId(getOrganizationId());
154             model.setGroupId(getGroupId());
155             model.setRoleId(getRoleId());
156 
157             model = (OrgGroupRole)Proxy.newProxyInstance(OrgGroupRole.class.getClassLoader(),
158                     new Class[] { OrgGroupRole.class },
159                     new ReadOnlyBeanHandler(model));
160 
161             return model;
162         }
163     }
164 
165     public Object clone() {
166         OrgGroupRoleImpl clone = new OrgGroupRoleImpl();
167 
168         clone.setOrganizationId(getOrganizationId());
169         clone.setGroupId(getGroupId());
170         clone.setRoleId(getRoleId());
171 
172         return clone;
173     }
174 
175     public int compareTo(OrgGroupRole orgGroupRole) {
176         OrgGroupRolePK pk = orgGroupRole.getPrimaryKey();
177 
178         return getPrimaryKey().compareTo(pk);
179     }
180 
181     public boolean equals(Object obj) {
182         if (obj == null) {
183             return false;
184         }
185 
186         OrgGroupRole orgGroupRole = null;
187 
188         try {
189             orgGroupRole = (OrgGroupRole)obj;
190         }
191         catch (ClassCastException cce) {
192             return false;
193         }
194 
195         OrgGroupRolePK pk = orgGroupRole.getPrimaryKey();
196 
197         if (getPrimaryKey().equals(pk)) {
198             return true;
199         }
200         else {
201             return false;
202         }
203     }
204 
205     public int hashCode() {
206         return getPrimaryKey().hashCode();
207     }
208 
209     public String toString() {
210         StringBundler sb = new StringBundler(7);
211 
212         sb.append("{organizationId=");
213         sb.append(getOrganizationId());
214         sb.append(", groupId=");
215         sb.append(getGroupId());
216         sb.append(", roleId=");
217         sb.append(getRoleId());
218         sb.append("}");
219 
220         return sb.toString();
221     }
222 
223     public String toXmlString() {
224         StringBundler sb = new StringBundler(13);
225 
226         sb.append("<model><model-name>");
227         sb.append("com.liferay.portal.model.OrgGroupRole");
228         sb.append("</model-name>");
229 
230         sb.append(
231             "<column><column-name>organizationId</column-name><column-value><![CDATA[");
232         sb.append(getOrganizationId());
233         sb.append("]]></column-value></column>");
234         sb.append(
235             "<column><column-name>groupId</column-name><column-value><![CDATA[");
236         sb.append(getGroupId());
237         sb.append("]]></column-value></column>");
238         sb.append(
239             "<column><column-name>roleId</column-name><column-value><![CDATA[");
240         sb.append(getRoleId());
241         sb.append("]]></column-value></column>");
242 
243         sb.append("</model>");
244 
245         return sb.toString();
246     }
247 
248     private long _organizationId;
249     private long _groupId;
250     private long _roleId;
251 }