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.Group;
29  import com.liferay.portal.model.GroupSoap;
30  import com.liferay.portal.util.PortalUtil;
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="GroupModelImpl.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>Group</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.Group
57   * @see com.liferay.portal.service.model.GroupModel
58   * @see com.liferay.portal.service.model.impl.GroupImpl
59   *
60   */
61  public class GroupModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "Group_";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "groupId", new Integer(Types.BIGINT) },
65              
66  
67              { "companyId", new Integer(Types.BIGINT) },
68              
69  
70              { "creatorUserId", new Integer(Types.BIGINT) },
71              
72  
73              { "classNameId", new Integer(Types.BIGINT) },
74              
75  
76              { "classPK", new Integer(Types.BIGINT) },
77              
78  
79              { "parentGroupId", new Integer(Types.BIGINT) },
80              
81  
82              { "liveGroupId", new Integer(Types.BIGINT) },
83              
84  
85              { "name", new Integer(Types.VARCHAR) },
86              
87  
88              { "description", new Integer(Types.VARCHAR) },
89              
90  
91              { "type_", new Integer(Types.INTEGER) },
92              
93  
94              { "typeSettings", new Integer(Types.VARCHAR) },
95              
96  
97              { "friendlyURL", new Integer(Types.VARCHAR) },
98              
99  
100             { "active_", new Integer(Types.BOOLEAN) }
101         };
102     public static final String TABLE_SQL_CREATE = "create table Group_ (groupId LONG not null primary key,companyId LONG,creatorUserId LONG,classNameId LONG,classPK LONG,parentGroupId LONG,liveGroupId LONG,name VARCHAR(75) null,description STRING null,type_ INTEGER,typeSettings STRING null,friendlyURL VARCHAR(100) null,active_ BOOLEAN)";
103     public static final String TABLE_SQL_DROP = "drop table Group_";
104     public static final String DATA_SOURCE = "liferayDataSource";
105     public static final String SESSION_FACTORY = "liferaySessionFactory";
106     public static final String TX_MANAGER = "liferayTransactionManager";
107     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
108                 "value.object.finder.cache.enabled.com.liferay.portal.model.Group"),
109             true);
110 
111     public static Group toModel(GroupSoap soapModel) {
112         Group model = new GroupImpl();
113 
114         model.setGroupId(soapModel.getGroupId());
115         model.setCompanyId(soapModel.getCompanyId());
116         model.setCreatorUserId(soapModel.getCreatorUserId());
117         model.setClassNameId(soapModel.getClassNameId());
118         model.setClassPK(soapModel.getClassPK());
119         model.setParentGroupId(soapModel.getParentGroupId());
120         model.setLiveGroupId(soapModel.getLiveGroupId());
121         model.setName(soapModel.getName());
122         model.setDescription(soapModel.getDescription());
123         model.setType(soapModel.getType());
124         model.setTypeSettings(soapModel.getTypeSettings());
125         model.setFriendlyURL(soapModel.getFriendlyURL());
126         model.setActive(soapModel.getActive());
127 
128         return model;
129     }
130 
131     public static List<Group> toModels(GroupSoap[] soapModels) {
132         List<Group> models = new ArrayList<Group>(soapModels.length);
133 
134         for (GroupSoap soapModel : soapModels) {
135             models.add(toModel(soapModel));
136         }
137 
138         return models;
139     }
140 
141     public static final boolean CACHE_ENABLED_GROUPS_ORGS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
142                 "value.object.finder.cache.enabled.Groups_Orgs"), true);
143     public static final boolean CACHE_ENABLED_GROUPS_PERMISSIONS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
144                 "value.object.finder.cache.enabled.Groups_Permissions"), true);
145     public static final boolean CACHE_ENABLED_GROUPS_ROLES = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
146                 "value.object.finder.cache.enabled.Groups_Roles"), true);
147     public static final boolean CACHE_ENABLED_GROUPS_USERGROUPS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
148                 "value.object.finder.cache.enabled.Groups_UserGroups"), true);
149     public static final boolean CACHE_ENABLED_USERS_GROUPS = com.liferay.portal.model.impl.UserModelImpl.CACHE_ENABLED_USERS_GROUPS;
150     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
151                 "lock.expiration.time.com.liferay.portal.model.Group"));
152 
153     public GroupModelImpl() {
154     }
155 
156     public long getPrimaryKey() {
157         return _groupId;
158     }
159 
160     public void setPrimaryKey(long pk) {
161         setGroupId(pk);
162     }
163 
164     public Serializable getPrimaryKeyObj() {
165         return new Long(_groupId);
166     }
167 
168     public long getGroupId() {
169         return _groupId;
170     }
171 
172     public void setGroupId(long groupId) {
173         if (groupId != _groupId) {
174             _groupId = groupId;
175         }
176     }
177 
178     public long getCompanyId() {
179         return _companyId;
180     }
181 
182     public void setCompanyId(long companyId) {
183         if (companyId != _companyId) {
184             _companyId = companyId;
185         }
186     }
187 
188     public long getCreatorUserId() {
189         return _creatorUserId;
190     }
191 
192     public void setCreatorUserId(long creatorUserId) {
193         if (creatorUserId != _creatorUserId) {
194             _creatorUserId = creatorUserId;
195         }
196     }
197 
198     public String getClassName() {
199         return PortalUtil.getClassName(getClassNameId());
200     }
201 
202     public long getClassNameId() {
203         return _classNameId;
204     }
205 
206     public void setClassNameId(long classNameId) {
207         if (classNameId != _classNameId) {
208             _classNameId = classNameId;
209         }
210     }
211 
212     public long getClassPK() {
213         return _classPK;
214     }
215 
216     public void setClassPK(long classPK) {
217         if (classPK != _classPK) {
218             _classPK = classPK;
219         }
220     }
221 
222     public long getParentGroupId() {
223         return _parentGroupId;
224     }
225 
226     public void setParentGroupId(long parentGroupId) {
227         if (parentGroupId != _parentGroupId) {
228             _parentGroupId = parentGroupId;
229         }
230     }
231 
232     public long getLiveGroupId() {
233         return _liveGroupId;
234     }
235 
236     public void setLiveGroupId(long liveGroupId) {
237         if (liveGroupId != _liveGroupId) {
238             _liveGroupId = liveGroupId;
239         }
240     }
241 
242     public String getName() {
243         return GetterUtil.getString(_name);
244     }
245 
246     public void setName(String name) {
247         if (((name == null) && (_name != null)) ||
248                 ((name != null) && (_name == null)) ||
249                 ((name != null) && (_name != null) && !name.equals(_name))) {
250             _name = name;
251         }
252     }
253 
254     public String getDescription() {
255         return GetterUtil.getString(_description);
256     }
257 
258     public void setDescription(String description) {
259         if (((description == null) && (_description != null)) ||
260                 ((description != null) && (_description == null)) ||
261                 ((description != null) && (_description != null) &&
262                 !description.equals(_description))) {
263             _description = description;
264         }
265     }
266 
267     public int getType() {
268         return _type;
269     }
270 
271     public void setType(int type) {
272         if (type != _type) {
273             _type = type;
274         }
275     }
276 
277     public String getTypeSettings() {
278         return GetterUtil.getString(_typeSettings);
279     }
280 
281     public void setTypeSettings(String typeSettings) {
282         if (((typeSettings == null) && (_typeSettings != null)) ||
283                 ((typeSettings != null) && (_typeSettings == null)) ||
284                 ((typeSettings != null) && (_typeSettings != null) &&
285                 !typeSettings.equals(_typeSettings))) {
286             _typeSettings = typeSettings;
287         }
288     }
289 
290     public String getFriendlyURL() {
291         return GetterUtil.getString(_friendlyURL);
292     }
293 
294     public void setFriendlyURL(String friendlyURL) {
295         if (((friendlyURL == null) && (_friendlyURL != null)) ||
296                 ((friendlyURL != null) && (_friendlyURL == null)) ||
297                 ((friendlyURL != null) && (_friendlyURL != null) &&
298                 !friendlyURL.equals(_friendlyURL))) {
299             _friendlyURL = friendlyURL;
300         }
301     }
302 
303     public boolean getActive() {
304         return _active;
305     }
306 
307     public boolean isActive() {
308         return _active;
309     }
310 
311     public void setActive(boolean active) {
312         if (active != _active) {
313             _active = active;
314         }
315     }
316 
317     public Group toEscapedModel() {
318         if (isEscapedModel()) {
319             return (Group)this;
320         }
321         else {
322             Group model = new GroupImpl();
323 
324             model.setEscapedModel(true);
325 
326             model.setGroupId(getGroupId());
327             model.setCompanyId(getCompanyId());
328             model.setCreatorUserId(getCreatorUserId());
329             model.setClassNameId(getClassNameId());
330             model.setClassPK(getClassPK());
331             model.setParentGroupId(getParentGroupId());
332             model.setLiveGroupId(getLiveGroupId());
333             model.setName(HtmlUtil.escape(getName()));
334             model.setDescription(HtmlUtil.escape(getDescription()));
335             model.setType(getType());
336             model.setTypeSettings(HtmlUtil.escape(getTypeSettings()));
337             model.setFriendlyURL(HtmlUtil.escape(getFriendlyURL()));
338             model.setActive(getActive());
339 
340             model = (Group)Proxy.newProxyInstance(Group.class.getClassLoader(),
341                     new Class[] { Group.class }, new ReadOnlyBeanHandler(model));
342 
343             return model;
344         }
345     }
346 
347     public Object clone() {
348         GroupImpl clone = new GroupImpl();
349 
350         clone.setGroupId(getGroupId());
351         clone.setCompanyId(getCompanyId());
352         clone.setCreatorUserId(getCreatorUserId());
353         clone.setClassNameId(getClassNameId());
354         clone.setClassPK(getClassPK());
355         clone.setParentGroupId(getParentGroupId());
356         clone.setLiveGroupId(getLiveGroupId());
357         clone.setName(getName());
358         clone.setDescription(getDescription());
359         clone.setType(getType());
360         clone.setTypeSettings(getTypeSettings());
361         clone.setFriendlyURL(getFriendlyURL());
362         clone.setActive(getActive());
363 
364         return clone;
365     }
366 
367     public int compareTo(Object obj) {
368         if (obj == null) {
369             return -1;
370         }
371 
372         GroupImpl group = (GroupImpl)obj;
373 
374         int value = 0;
375 
376         value = getName().toLowerCase().compareTo(group.getName().toLowerCase());
377 
378         if (value != 0) {
379             return value;
380         }
381 
382         return 0;
383     }
384 
385     public boolean equals(Object obj) {
386         if (obj == null) {
387             return false;
388         }
389 
390         GroupImpl group = null;
391 
392         try {
393             group = (GroupImpl)obj;
394         }
395         catch (ClassCastException cce) {
396             return false;
397         }
398 
399         long pk = group.getPrimaryKey();
400 
401         if (getPrimaryKey() == pk) {
402             return true;
403         }
404         else {
405             return false;
406         }
407     }
408 
409     public int hashCode() {
410         return (int)getPrimaryKey();
411     }
412 
413     private long _groupId;
414     private long _companyId;
415     private long _creatorUserId;
416     private long _classNameId;
417     private long _classPK;
418     private long _parentGroupId;
419     private long _liveGroupId;
420     private String _name;
421     private String _description;
422     private int _type;
423     private String _typeSettings;
424     private String _friendlyURL;
425     private boolean _active;
426 }