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