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.Role;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.util.Html;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  /**
39   * <a href="RoleModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>Role</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.Role
54   * @see com.liferay.portal.service.model.RoleModel
55   * @see com.liferay.portal.service.model.impl.RoleImpl
56   *
57   */
58  public class RoleModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "Role_";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "roleId", new Integer(Types.BIGINT) },
62              
63  
64              { "companyId", new Integer(Types.BIGINT) },
65              
66  
67              { "classNameId", new Integer(Types.BIGINT) },
68              
69  
70              { "classPK", new Integer(Types.BIGINT) },
71              
72  
73              { "name", new Integer(Types.VARCHAR) },
74              
75  
76              { "description", new Integer(Types.VARCHAR) },
77              
78  
79              { "type_", new Integer(Types.INTEGER) }
80          };
81      public static final String TABLE_SQL_CREATE = "create table Role_ (roleId LONG not null primary key,companyId LONG,classNameId LONG,classPK LONG,name VARCHAR(75) null,description STRING null,type_ INTEGER)";
82      public static final String TABLE_SQL_DROP = "drop table Role_";
83      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
84                  "value.object.finder.cache.enabled.com.liferay.portal.model.Role"),
85              true);
86      public static final boolean CACHE_ENABLED_GROUPS_ROLES = com.liferay.portal.model.impl.GroupModelImpl.CACHE_ENABLED_GROUPS_ROLES;
87      public static final boolean CACHE_ENABLED_ROLES_PERMISSIONS = GetterUtil.getBoolean(PropsUtil.get(
88                  "value.object.finder.cache.enabled.Roles_Permissions"), true);
89      public static final boolean CACHE_ENABLED_USERS_ROLES = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_ROLES;
90      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
91                  "lock.expiration.time.com.liferay.portal.model.Role"));
92  
93      public RoleModelImpl() {
94      }
95  
96      public long getPrimaryKey() {
97          return _roleId;
98      }
99  
100     public void setPrimaryKey(long pk) {
101         setRoleId(pk);
102     }
103 
104     public Serializable getPrimaryKeyObj() {
105         return new Long(_roleId);
106     }
107 
108     public long getRoleId() {
109         return _roleId;
110     }
111 
112     public void setRoleId(long roleId) {
113         if (roleId != _roleId) {
114             _roleId = roleId;
115         }
116     }
117 
118     public long getCompanyId() {
119         return _companyId;
120     }
121 
122     public void setCompanyId(long companyId) {
123         if (companyId != _companyId) {
124             _companyId = companyId;
125         }
126     }
127 
128     public long getClassNameId() {
129         return _classNameId;
130     }
131 
132     public void setClassNameId(long classNameId) {
133         if (classNameId != _classNameId) {
134             _classNameId = classNameId;
135         }
136     }
137 
138     public long getClassPK() {
139         return _classPK;
140     }
141 
142     public void setClassPK(long classPK) {
143         if (classPK != _classPK) {
144             _classPK = classPK;
145         }
146     }
147 
148     public String getName() {
149         return GetterUtil.getString(_name);
150     }
151 
152     public void setName(String name) {
153         if (((name == null) && (_name != null)) ||
154                 ((name != null) && (_name == null)) ||
155                 ((name != null) && (_name != null) && !name.equals(_name))) {
156             _name = name;
157         }
158     }
159 
160     public String getDescription() {
161         return GetterUtil.getString(_description);
162     }
163 
164     public void setDescription(String description) {
165         if (((description == null) && (_description != null)) ||
166                 ((description != null) && (_description == null)) ||
167                 ((description != null) && (_description != null) &&
168                 !description.equals(_description))) {
169             _description = description;
170         }
171     }
172 
173     public int getType() {
174         return _type;
175     }
176 
177     public void setType(int type) {
178         if (type != _type) {
179             _type = type;
180         }
181     }
182 
183     public Role toEscapedModel() {
184         if (isEscapedModel()) {
185             return (Role)this;
186         }
187         else {
188             Role model = new RoleImpl();
189 
190             model.setEscapedModel(true);
191 
192             model.setRoleId(getRoleId());
193             model.setCompanyId(getCompanyId());
194             model.setClassNameId(getClassNameId());
195             model.setClassPK(getClassPK());
196             model.setName(Html.escape(getName()));
197             model.setDescription(Html.escape(getDescription()));
198             model.setType(getType());
199 
200             model = (Role)Proxy.newProxyInstance(Role.class.getClassLoader(),
201                     new Class[] { Role.class }, new ReadOnlyBeanHandler(model));
202 
203             return model;
204         }
205     }
206 
207     public Object clone() {
208         RoleImpl clone = new RoleImpl();
209 
210         clone.setRoleId(getRoleId());
211         clone.setCompanyId(getCompanyId());
212         clone.setClassNameId(getClassNameId());
213         clone.setClassPK(getClassPK());
214         clone.setName(getName());
215         clone.setDescription(getDescription());
216         clone.setType(getType());
217 
218         return clone;
219     }
220 
221     public int compareTo(Object obj) {
222         if (obj == null) {
223             return -1;
224         }
225 
226         RoleImpl role = (RoleImpl)obj;
227 
228         int value = 0;
229 
230         value = getName().compareTo(role.getName());
231 
232         if (value != 0) {
233             return value;
234         }
235 
236         return 0;
237     }
238 
239     public boolean equals(Object obj) {
240         if (obj == null) {
241             return false;
242         }
243 
244         RoleImpl role = null;
245 
246         try {
247             role = (RoleImpl)obj;
248         }
249         catch (ClassCastException cce) {
250             return false;
251         }
252 
253         long pk = role.getPrimaryKey();
254 
255         if (getPrimaryKey() == pk) {
256             return true;
257         }
258         else {
259             return false;
260         }
261     }
262 
263     public int hashCode() {
264         return (int)getPrimaryKey();
265     }
266 
267     private long _roleId;
268     private long _companyId;
269     private long _classNameId;
270     private long _classPK;
271     private String _name;
272     private String _description;
273     private int _type;
274 }