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