1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.model.OrgGroupRole;
21  import com.liferay.portal.model.OrgGroupRoleSoap;
22  import com.liferay.portal.service.persistence.OrgGroupRolePK;
23  
24  import java.io.Serializable;
25  
26  import java.lang.reflect.Proxy;
27  
28  import java.sql.Types;
29  
30  import java.util.ArrayList;
31  import java.util.List;
32  
33  /**
34   * <a href="OrgGroupRoleModelImpl.java.html"><b><i>View Source</i></b></a>
35   *
36   * <p>
37   * ServiceBuilder generated this class. Modifications in this class will be
38   * overwritten the next time is generated.
39   * </p>
40   *
41   * <p>
42   * This interface is a model that represents the OrgGroupRole table in the
43   * database.
44   * </p>
45   *
46   * @author    Brian Wing Shun Chan
47   * @see       OrgGroupRoleImpl
48   * @see       com.liferay.portal.model.OrgGroupRole
49   * @see       com.liferay.portal.model.OrgGroupRoleModel
50   * @generated
51   */
52  public class OrgGroupRoleModelImpl extends BaseModelImpl<OrgGroupRole> {
53      public static final String TABLE_NAME = "OrgGroupRole";
54      public static final Object[][] TABLE_COLUMNS = {
55              { "organizationId", new Integer(Types.BIGINT) },
56              { "groupId", new Integer(Types.BIGINT) },
57              { "roleId", new Integer(Types.BIGINT) }
58          };
59      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))";
60      public static final String TABLE_SQL_DROP = "drop table OrgGroupRole";
61      public static final String DATA_SOURCE = "liferayDataSource";
62      public static final String SESSION_FACTORY = "liferaySessionFactory";
63      public static final String TX_MANAGER = "liferayTransactionManager";
64      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
65                  "value.object.entity.cache.enabled.com.liferay.portal.model.OrgGroupRole"),
66              true);
67      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
68                  "value.object.finder.cache.enabled.com.liferay.portal.model.OrgGroupRole"),
69              true);
70  
71      public static OrgGroupRole toModel(OrgGroupRoleSoap soapModel) {
72          OrgGroupRole model = new OrgGroupRoleImpl();
73  
74          model.setOrganizationId(soapModel.getOrganizationId());
75          model.setGroupId(soapModel.getGroupId());
76          model.setRoleId(soapModel.getRoleId());
77  
78          return model;
79      }
80  
81      public static List<OrgGroupRole> toModels(OrgGroupRoleSoap[] soapModels) {
82          List<OrgGroupRole> models = new ArrayList<OrgGroupRole>(soapModels.length);
83  
84          for (OrgGroupRoleSoap soapModel : soapModels) {
85              models.add(toModel(soapModel));
86          }
87  
88          return models;
89      }
90  
91      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
92                  "lock.expiration.time.com.liferay.portal.model.OrgGroupRole"));
93  
94      public OrgGroupRoleModelImpl() {
95      }
96  
97      public OrgGroupRolePK getPrimaryKey() {
98          return new OrgGroupRolePK(_organizationId, _groupId, _roleId);
99      }
100 
101     public void setPrimaryKey(OrgGroupRolePK pk) {
102         setOrganizationId(pk.organizationId);
103         setGroupId(pk.groupId);
104         setRoleId(pk.roleId);
105     }
106 
107     public Serializable getPrimaryKeyObj() {
108         return new OrgGroupRolePK(_organizationId, _groupId, _roleId);
109     }
110 
111     public long getOrganizationId() {
112         return _organizationId;
113     }
114 
115     public void setOrganizationId(long organizationId) {
116         _organizationId = organizationId;
117     }
118 
119     public long getGroupId() {
120         return _groupId;
121     }
122 
123     public void setGroupId(long groupId) {
124         _groupId = groupId;
125     }
126 
127     public long getRoleId() {
128         return _roleId;
129     }
130 
131     public void setRoleId(long roleId) {
132         _roleId = roleId;
133     }
134 
135     public OrgGroupRole toEscapedModel() {
136         if (isEscapedModel()) {
137             return (OrgGroupRole)this;
138         }
139         else {
140             OrgGroupRole model = new OrgGroupRoleImpl();
141 
142             model.setNew(isNew());
143             model.setEscapedModel(true);
144 
145             model.setOrganizationId(getOrganizationId());
146             model.setGroupId(getGroupId());
147             model.setRoleId(getRoleId());
148 
149             model = (OrgGroupRole)Proxy.newProxyInstance(OrgGroupRole.class.getClassLoader(),
150                     new Class[] { OrgGroupRole.class },
151                     new ReadOnlyBeanHandler(model));
152 
153             return model;
154         }
155     }
156 
157     public Object clone() {
158         OrgGroupRoleImpl clone = new OrgGroupRoleImpl();
159 
160         clone.setOrganizationId(getOrganizationId());
161         clone.setGroupId(getGroupId());
162         clone.setRoleId(getRoleId());
163 
164         return clone;
165     }
166 
167     public int compareTo(OrgGroupRole orgGroupRole) {
168         OrgGroupRolePK pk = orgGroupRole.getPrimaryKey();
169 
170         return getPrimaryKey().compareTo(pk);
171     }
172 
173     public boolean equals(Object obj) {
174         if (obj == null) {
175             return false;
176         }
177 
178         OrgGroupRole orgGroupRole = null;
179 
180         try {
181             orgGroupRole = (OrgGroupRole)obj;
182         }
183         catch (ClassCastException cce) {
184             return false;
185         }
186 
187         OrgGroupRolePK pk = orgGroupRole.getPrimaryKey();
188 
189         if (getPrimaryKey().equals(pk)) {
190             return true;
191         }
192         else {
193             return false;
194         }
195     }
196 
197     public int hashCode() {
198         return getPrimaryKey().hashCode();
199     }
200 
201     public String toString() {
202         StringBundler sb = new StringBundler(7);
203 
204         sb.append("{organizationId=");
205         sb.append(getOrganizationId());
206         sb.append(", groupId=");
207         sb.append(getGroupId());
208         sb.append(", roleId=");
209         sb.append(getRoleId());
210         sb.append("}");
211 
212         return sb.toString();
213     }
214 
215     public String toXmlString() {
216         StringBundler sb = new StringBundler(13);
217 
218         sb.append("<model><model-name>");
219         sb.append("com.liferay.portal.model.OrgGroupRole");
220         sb.append("</model-name>");
221 
222         sb.append(
223             "<column><column-name>organizationId</column-name><column-value><![CDATA[");
224         sb.append(getOrganizationId());
225         sb.append("]]></column-value></column>");
226         sb.append(
227             "<column><column-name>groupId</column-name><column-value><![CDATA[");
228         sb.append(getGroupId());
229         sb.append("]]></column-value></column>");
230         sb.append(
231             "<column><column-name>roleId</column-name><column-value><![CDATA[");
232         sb.append(getRoleId());
233         sb.append("]]></column-value></column>");
234 
235         sb.append("</model>");
236 
237         return sb.toString();
238     }
239 
240     private long _organizationId;
241     private long _groupId;
242     private long _roleId;
243 }