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.UserGroup;
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="UserGroupModelImpl.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>UserGroup</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portal.service.model.UserGroup
54   * @see com.liferay.portal.service.model.UserGroupModel
55   * @see com.liferay.portal.service.model.impl.UserGroupImpl
56   *
57   */
58  public class UserGroupModelImpl extends BaseModelImpl {
59      public static final String TABLE_NAME = "UserGroup";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "userGroupId", new Integer(Types.BIGINT) },
62              
63  
64              { "companyId", new Integer(Types.BIGINT) },
65              
66  
67              { "parentUserGroupId", new Integer(Types.BIGINT) },
68              
69  
70              { "name", new Integer(Types.VARCHAR) },
71              
72  
73              { "description", new Integer(Types.VARCHAR) }
74          };
75      public static final String TABLE_SQL_CREATE = "create table UserGroup (userGroupId LONG not null primary key,companyId LONG,parentUserGroupId LONG,name VARCHAR(75) null,description STRING null)";
76      public static final String TABLE_SQL_DROP = "drop table UserGroup";
77      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
78                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserGroup"),
79              true);
80      public static final boolean CACHE_ENABLED_USERS_USERGROUPS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_USERGROUPS;
81      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
82                  "lock.expiration.time.com.liferay.portal.model.UserGroup"));
83  
84      public UserGroupModelImpl() {
85      }
86  
87      public long getPrimaryKey() {
88          return _userGroupId;
89      }
90  
91      public void setPrimaryKey(long pk) {
92          setUserGroupId(pk);
93      }
94  
95      public Serializable getPrimaryKeyObj() {
96          return new Long(_userGroupId);
97      }
98  
99      public long getUserGroupId() {
100         return _userGroupId;
101     }
102 
103     public void setUserGroupId(long userGroupId) {
104         if (userGroupId != _userGroupId) {
105             _userGroupId = userGroupId;
106         }
107     }
108 
109     public long getCompanyId() {
110         return _companyId;
111     }
112 
113     public void setCompanyId(long companyId) {
114         if (companyId != _companyId) {
115             _companyId = companyId;
116         }
117     }
118 
119     public long getParentUserGroupId() {
120         return _parentUserGroupId;
121     }
122 
123     public void setParentUserGroupId(long parentUserGroupId) {
124         if (parentUserGroupId != _parentUserGroupId) {
125             _parentUserGroupId = parentUserGroupId;
126         }
127     }
128 
129     public String getName() {
130         return GetterUtil.getString(_name);
131     }
132 
133     public void setName(String name) {
134         if (((name == null) && (_name != null)) ||
135                 ((name != null) && (_name == null)) ||
136                 ((name != null) && (_name != null) && !name.equals(_name))) {
137             _name = name;
138         }
139     }
140 
141     public String getDescription() {
142         return GetterUtil.getString(_description);
143     }
144 
145     public void setDescription(String description) {
146         if (((description == null) && (_description != null)) ||
147                 ((description != null) && (_description == null)) ||
148                 ((description != null) && (_description != null) &&
149                 !description.equals(_description))) {
150             _description = description;
151         }
152     }
153 
154     public UserGroup toEscapedModel() {
155         if (isEscapedModel()) {
156             return (UserGroup)this;
157         }
158         else {
159             UserGroup model = new UserGroupImpl();
160 
161             model.setEscapedModel(true);
162 
163             model.setUserGroupId(getUserGroupId());
164             model.setCompanyId(getCompanyId());
165             model.setParentUserGroupId(getParentUserGroupId());
166             model.setName(Html.escape(getName()));
167             model.setDescription(Html.escape(getDescription()));
168 
169             model = (UserGroup)Proxy.newProxyInstance(UserGroup.class.getClassLoader(),
170                     new Class[] { UserGroup.class },
171                     new ReadOnlyBeanHandler(model));
172 
173             return model;
174         }
175     }
176 
177     public Object clone() {
178         UserGroupImpl clone = new UserGroupImpl();
179 
180         clone.setUserGroupId(getUserGroupId());
181         clone.setCompanyId(getCompanyId());
182         clone.setParentUserGroupId(getParentUserGroupId());
183         clone.setName(getName());
184         clone.setDescription(getDescription());
185 
186         return clone;
187     }
188 
189     public int compareTo(Object obj) {
190         if (obj == null) {
191             return -1;
192         }
193 
194         UserGroupImpl userGroup = (UserGroupImpl)obj;
195 
196         int value = 0;
197 
198         value = getName().compareTo(userGroup.getName());
199 
200         if (value != 0) {
201             return value;
202         }
203 
204         return 0;
205     }
206 
207     public boolean equals(Object obj) {
208         if (obj == null) {
209             return false;
210         }
211 
212         UserGroupImpl userGroup = null;
213 
214         try {
215             userGroup = (UserGroupImpl)obj;
216         }
217         catch (ClassCastException cce) {
218             return false;
219         }
220 
221         long pk = userGroup.getPrimaryKey();
222 
223         if (getPrimaryKey() == pk) {
224             return true;
225         }
226         else {
227             return false;
228         }
229     }
230 
231     public int hashCode() {
232         return (int)getPrimaryKey();
233     }
234 
235     private long _userGroupId;
236     private long _companyId;
237     private long _parentUserGroupId;
238     private String _name;
239     private String _description;
240 }