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