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