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