1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.UserGroup;
26  import com.liferay.portal.model.UserGroupSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="UserGroupModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This class is a model that represents the <code>UserGroup</code> table
47   * in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.model.UserGroup
53   * @see com.liferay.portal.model.UserGroupModel
54   * @see com.liferay.portal.model.impl.UserGroupImpl
55   *
56   */
57  public class UserGroupModelImpl extends BaseModelImpl {
58      public static final String TABLE_NAME = "UserGroup";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "userGroupId", new Integer(Types.BIGINT) },
61              
62  
63              { "companyId", new Integer(Types.BIGINT) },
64              
65  
66              { "parentUserGroupId", new Integer(Types.BIGINT) },
67              
68  
69              { "name", new Integer(Types.VARCHAR) },
70              
71  
72              { "description", new Integer(Types.VARCHAR) }
73          };
74      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)";
75      public static final String TABLE_SQL_DROP = "drop table UserGroup";
76      public static final String DATA_SOURCE = "liferayDataSource";
77      public static final String SESSION_FACTORY = "liferaySessionFactory";
78      public static final String TX_MANAGER = "liferayTransactionManager";
79      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portal.model.UserGroup"),
81              true);
82  
83      public static UserGroup toModel(UserGroupSoap soapModel) {
84          UserGroup model = new UserGroupImpl();
85  
86          model.setUserGroupId(soapModel.getUserGroupId());
87          model.setCompanyId(soapModel.getCompanyId());
88          model.setParentUserGroupId(soapModel.getParentUserGroupId());
89          model.setName(soapModel.getName());
90          model.setDescription(soapModel.getDescription());
91  
92          return model;
93      }
94  
95      public static List<UserGroup> toModels(UserGroupSoap[] soapModels) {
96          List<UserGroup> models = new ArrayList<UserGroup>(soapModels.length);
97  
98          for (UserGroupSoap soapModel : soapModels) {
99              models.add(toModel(soapModel));
100         }
101 
102         return models;
103     }
104 
105     public static final boolean CACHE_ENABLED_USERS_USERGROUPS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_USERGROUPS;
106     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
107                 "lock.expiration.time.com.liferay.portal.model.UserGroup"));
108 
109     public UserGroupModelImpl() {
110     }
111 
112     public long getPrimaryKey() {
113         return _userGroupId;
114     }
115 
116     public void setPrimaryKey(long pk) {
117         setUserGroupId(pk);
118     }
119 
120     public Serializable getPrimaryKeyObj() {
121         return new Long(_userGroupId);
122     }
123 
124     public long getUserGroupId() {
125         return _userGroupId;
126     }
127 
128     public void setUserGroupId(long userGroupId) {
129         if (userGroupId != _userGroupId) {
130             _userGroupId = userGroupId;
131         }
132     }
133 
134     public long getCompanyId() {
135         return _companyId;
136     }
137 
138     public void setCompanyId(long companyId) {
139         if (companyId != _companyId) {
140             _companyId = companyId;
141         }
142     }
143 
144     public long getParentUserGroupId() {
145         return _parentUserGroupId;
146     }
147 
148     public void setParentUserGroupId(long parentUserGroupId) {
149         if (parentUserGroupId != _parentUserGroupId) {
150             _parentUserGroupId = parentUserGroupId;
151         }
152     }
153 
154     public String getName() {
155         return GetterUtil.getString(_name);
156     }
157 
158     public void setName(String name) {
159         if (((name == null) && (_name != null)) ||
160                 ((name != null) && (_name == null)) ||
161                 ((name != null) && (_name != null) && !name.equals(_name))) {
162             _name = name;
163         }
164     }
165 
166     public String getDescription() {
167         return GetterUtil.getString(_description);
168     }
169 
170     public void setDescription(String description) {
171         if (((description == null) && (_description != null)) ||
172                 ((description != null) && (_description == null)) ||
173                 ((description != null) && (_description != null) &&
174                 !description.equals(_description))) {
175             _description = description;
176         }
177     }
178 
179     public UserGroup toEscapedModel() {
180         if (isEscapedModel()) {
181             return (UserGroup)this;
182         }
183         else {
184             UserGroup model = new UserGroupImpl();
185 
186             model.setNew(isNew());
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 }