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.HtmlUtil;
28  import com.liferay.portal.kernel.util.StringPool;
29  import com.liferay.portal.model.Role;
30  import com.liferay.portal.model.RoleSoap;
31  import com.liferay.portal.service.ServiceContext;
32  import com.liferay.portal.util.PortalUtil;
33  
34  import com.liferay.portlet.expando.model.ExpandoBridge;
35  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
36  
37  import java.io.Serializable;
38  
39  import java.lang.reflect.Proxy;
40  
41  import java.sql.Types;
42  
43  import java.util.ArrayList;
44  import java.util.List;
45  
46  /**
47   * <a href="RoleModelImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * <p>
50   * ServiceBuilder generated this class. Modifications in this class will be
51   * overwritten the next time is generated.
52   * </p>
53   *
54   * <p>
55   * This interface is a model that represents the Role_ table in the
56   * database.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       RoleImpl
61   * @see       com.liferay.portal.model.Role
62   * @see       com.liferay.portal.model.RoleModel
63   * @generated
64   */
65  public class RoleModelImpl extends BaseModelImpl<Role> {
66      public static final String TABLE_NAME = "Role_";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "roleId", new Integer(Types.BIGINT) },
69              { "companyId", new Integer(Types.BIGINT) },
70              { "classNameId", new Integer(Types.BIGINT) },
71              { "classPK", new Integer(Types.BIGINT) },
72              { "name", new Integer(Types.VARCHAR) },
73              { "title", new Integer(Types.VARCHAR) },
74              { "description", new Integer(Types.VARCHAR) },
75              { "type_", new Integer(Types.INTEGER) },
76              { "subtype", new Integer(Types.VARCHAR) }
77          };
78      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,title STRING null,description STRING null,type_ INTEGER,subtype VARCHAR(75) null)";
79      public static final String TABLE_SQL_DROP = "drop table Role_";
80      public static final String DATA_SOURCE = "liferayDataSource";
81      public static final String SESSION_FACTORY = "liferaySessionFactory";
82      public static final String TX_MANAGER = "liferayTransactionManager";
83      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.entity.cache.enabled.com.liferay.portal.model.Role"),
85              true);
86      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87                  "value.object.finder.cache.enabled.com.liferay.portal.model.Role"),
88              true);
89  
90      public static Role toModel(RoleSoap soapModel) {
91          Role model = new RoleImpl();
92  
93          model.setRoleId(soapModel.getRoleId());
94          model.setCompanyId(soapModel.getCompanyId());
95          model.setClassNameId(soapModel.getClassNameId());
96          model.setClassPK(soapModel.getClassPK());
97          model.setName(soapModel.getName());
98          model.setTitle(soapModel.getTitle());
99          model.setDescription(soapModel.getDescription());
100         model.setType(soapModel.getType());
101         model.setSubtype(soapModel.getSubtype());
102 
103         return model;
104     }
105 
106     public static List<Role> toModels(RoleSoap[] soapModels) {
107         List<Role> models = new ArrayList<Role>(soapModels.length);
108 
109         for (RoleSoap soapModel : soapModels) {
110             models.add(toModel(soapModel));
111         }
112 
113         return models;
114     }
115 
116     public static final boolean FINDER_CACHE_ENABLED_GROUPS_ROLES = com.liferay.portal.model.impl.GroupModelImpl.FINDER_CACHE_ENABLED_GROUPS_ROLES;
117     public static final boolean FINDER_CACHE_ENABLED_ROLES_PERMISSIONS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
118                 "value.object.finder.cache.enabled.Roles_Permissions"), true);
119     public static final boolean FINDER_CACHE_ENABLED_USERS_ROLES = com.liferay.portal.model.impl.UserModelImpl.FINDER_CACHE_ENABLED_USERS_ROLES;
120     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
121                 "lock.expiration.time.com.liferay.portal.model.Role"));
122 
123     public RoleModelImpl() {
124     }
125 
126     public long getPrimaryKey() {
127         return _roleId;
128     }
129 
130     public void setPrimaryKey(long pk) {
131         setRoleId(pk);
132     }
133 
134     public Serializable getPrimaryKeyObj() {
135         return new Long(_roleId);
136     }
137 
138     public long getRoleId() {
139         return _roleId;
140     }
141 
142     public void setRoleId(long roleId) {
143         _roleId = roleId;
144     }
145 
146     public long getCompanyId() {
147         return _companyId;
148     }
149 
150     public void setCompanyId(long companyId) {
151         _companyId = companyId;
152 
153         if (!_setOriginalCompanyId) {
154             _setOriginalCompanyId = true;
155 
156             _originalCompanyId = companyId;
157         }
158     }
159 
160     public long getOriginalCompanyId() {
161         return _originalCompanyId;
162     }
163 
164     public String getClassName() {
165         if (getClassNameId() <= 0) {
166             return StringPool.BLANK;
167         }
168 
169         return PortalUtil.getClassName(getClassNameId());
170     }
171 
172     public long getClassNameId() {
173         return _classNameId;
174     }
175 
176     public void setClassNameId(long classNameId) {
177         _classNameId = classNameId;
178 
179         if (!_setOriginalClassNameId) {
180             _setOriginalClassNameId = true;
181 
182             _originalClassNameId = classNameId;
183         }
184     }
185 
186     public long getOriginalClassNameId() {
187         return _originalClassNameId;
188     }
189 
190     public long getClassPK() {
191         return _classPK;
192     }
193 
194     public void setClassPK(long classPK) {
195         _classPK = classPK;
196 
197         if (!_setOriginalClassPK) {
198             _setOriginalClassPK = true;
199 
200             _originalClassPK = classPK;
201         }
202     }
203 
204     public long getOriginalClassPK() {
205         return _originalClassPK;
206     }
207 
208     public String getName() {
209         return GetterUtil.getString(_name);
210     }
211 
212     public void setName(String name) {
213         _name = name;
214 
215         if (_originalName == null) {
216             _originalName = name;
217         }
218     }
219 
220     public String getOriginalName() {
221         return GetterUtil.getString(_originalName);
222     }
223 
224     public String getTitle() {
225         return GetterUtil.getString(_title);
226     }
227 
228     public void setTitle(String title) {
229         _title = title;
230     }
231 
232     public String getDescription() {
233         return GetterUtil.getString(_description);
234     }
235 
236     public void setDescription(String description) {
237         _description = description;
238     }
239 
240     public int getType() {
241         return _type;
242     }
243 
244     public void setType(int type) {
245         _type = type;
246     }
247 
248     public String getSubtype() {
249         return GetterUtil.getString(_subtype);
250     }
251 
252     public void setSubtype(String subtype) {
253         _subtype = subtype;
254     }
255 
256     public Role toEscapedModel() {
257         if (isEscapedModel()) {
258             return (Role)this;
259         }
260         else {
261             Role model = new RoleImpl();
262 
263             model.setNew(isNew());
264             model.setEscapedModel(true);
265 
266             model.setRoleId(getRoleId());
267             model.setCompanyId(getCompanyId());
268             model.setClassNameId(getClassNameId());
269             model.setClassPK(getClassPK());
270             model.setName(HtmlUtil.escape(getName()));
271             model.setTitle(HtmlUtil.escape(getTitle()));
272             model.setDescription(HtmlUtil.escape(getDescription()));
273             model.setType(getType());
274             model.setSubtype(HtmlUtil.escape(getSubtype()));
275 
276             model = (Role)Proxy.newProxyInstance(Role.class.getClassLoader(),
277                     new Class[] { Role.class }, new ReadOnlyBeanHandler(model));
278 
279             return model;
280         }
281     }
282 
283     public ExpandoBridge getExpandoBridge() {
284         if (_expandoBridge == null) {
285             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(Role.class.getName(),
286                     getPrimaryKey());
287         }
288 
289         return _expandoBridge;
290     }
291 
292     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
293         getExpandoBridge().setAttributes(serviceContext);
294     }
295 
296     public Object clone() {
297         RoleImpl clone = new RoleImpl();
298 
299         clone.setRoleId(getRoleId());
300         clone.setCompanyId(getCompanyId());
301         clone.setClassNameId(getClassNameId());
302         clone.setClassPK(getClassPK());
303         clone.setName(getName());
304         clone.setTitle(getTitle());
305         clone.setDescription(getDescription());
306         clone.setType(getType());
307         clone.setSubtype(getSubtype());
308 
309         return clone;
310     }
311 
312     public int compareTo(Role role) {
313         int value = 0;
314 
315         value = getName().compareTo(role.getName());
316 
317         if (value != 0) {
318             return value;
319         }
320 
321         return 0;
322     }
323 
324     public boolean equals(Object obj) {
325         if (obj == null) {
326             return false;
327         }
328 
329         Role role = null;
330 
331         try {
332             role = (Role)obj;
333         }
334         catch (ClassCastException cce) {
335             return false;
336         }
337 
338         long pk = role.getPrimaryKey();
339 
340         if (getPrimaryKey() == pk) {
341             return true;
342         }
343         else {
344             return false;
345         }
346     }
347 
348     public int hashCode() {
349         return (int)getPrimaryKey();
350     }
351 
352     public String toString() {
353         StringBuilder sb = new StringBuilder();
354 
355         sb.append("{roleId=");
356         sb.append(getRoleId());
357         sb.append(", companyId=");
358         sb.append(getCompanyId());
359         sb.append(", classNameId=");
360         sb.append(getClassNameId());
361         sb.append(", classPK=");
362         sb.append(getClassPK());
363         sb.append(", name=");
364         sb.append(getName());
365         sb.append(", title=");
366         sb.append(getTitle());
367         sb.append(", description=");
368         sb.append(getDescription());
369         sb.append(", type=");
370         sb.append(getType());
371         sb.append(", subtype=");
372         sb.append(getSubtype());
373         sb.append("}");
374 
375         return sb.toString();
376     }
377 
378     public String toXmlString() {
379         StringBuilder sb = new StringBuilder();
380 
381         sb.append("<model><model-name>");
382         sb.append("com.liferay.portal.model.Role");
383         sb.append("</model-name>");
384 
385         sb.append(
386             "<column><column-name>roleId</column-name><column-value><![CDATA[");
387         sb.append(getRoleId());
388         sb.append("]]></column-value></column>");
389         sb.append(
390             "<column><column-name>companyId</column-name><column-value><![CDATA[");
391         sb.append(getCompanyId());
392         sb.append("]]></column-value></column>");
393         sb.append(
394             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
395         sb.append(getClassNameId());
396         sb.append("]]></column-value></column>");
397         sb.append(
398             "<column><column-name>classPK</column-name><column-value><![CDATA[");
399         sb.append(getClassPK());
400         sb.append("]]></column-value></column>");
401         sb.append(
402             "<column><column-name>name</column-name><column-value><![CDATA[");
403         sb.append(getName());
404         sb.append("]]></column-value></column>");
405         sb.append(
406             "<column><column-name>title</column-name><column-value><![CDATA[");
407         sb.append(getTitle());
408         sb.append("]]></column-value></column>");
409         sb.append(
410             "<column><column-name>description</column-name><column-value><![CDATA[");
411         sb.append(getDescription());
412         sb.append("]]></column-value></column>");
413         sb.append(
414             "<column><column-name>type</column-name><column-value><![CDATA[");
415         sb.append(getType());
416         sb.append("]]></column-value></column>");
417         sb.append(
418             "<column><column-name>subtype</column-name><column-value><![CDATA[");
419         sb.append(getSubtype());
420         sb.append("]]></column-value></column>");
421 
422         sb.append("</model>");
423 
424         return sb.toString();
425     }
426 
427     private long _roleId;
428     private long _companyId;
429     private long _originalCompanyId;
430     private boolean _setOriginalCompanyId;
431     private long _classNameId;
432     private long _originalClassNameId;
433     private boolean _setOriginalClassNameId;
434     private long _classPK;
435     private long _originalClassPK;
436     private boolean _setOriginalClassPK;
437     private String _name;
438     private String _originalName;
439     private String _title;
440     private String _description;
441     private int _type;
442     private String _subtype;
443     private transient ExpandoBridge _expandoBridge;
444 }