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