001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.Group;
023    import com.liferay.portal.model.GroupModel;
024    import com.liferay.portal.model.GroupSoap;
025    import com.liferay.portal.service.ServiceContext;
026    import com.liferay.portal.util.PortalUtil;
027    
028    import com.liferay.portlet.expando.model.ExpandoBridge;
029    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
030    
031    import java.io.Serializable;
032    
033    import java.lang.reflect.Proxy;
034    
035    import java.sql.Types;
036    
037    import java.util.ArrayList;
038    import java.util.List;
039    
040    /**
041     * The base model implementation for the Group service. Represents a row in the "Group_" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link com.liferay.portal.model.GroupModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link GroupImpl}.
045     * </p>
046     *
047     * <p>
048     * Never modify or reference this class directly. All methods that expect a group model instance should use the {@link com.liferay.portal.model.Group} interface instead.
049     * </p>
050     *
051     * @author Brian Wing Shun Chan
052     * @see GroupImpl
053     * @see com.liferay.portal.model.Group
054     * @see com.liferay.portal.model.GroupModel
055     * @generated
056     */
057    public class GroupModelImpl extends BaseModelImpl<Group> implements GroupModel {
058            public static final String TABLE_NAME = "Group_";
059            public static final Object[][] TABLE_COLUMNS = {
060                            { "groupId", new Integer(Types.BIGINT) },
061                            { "companyId", new Integer(Types.BIGINT) },
062                            { "creatorUserId", new Integer(Types.BIGINT) },
063                            { "classNameId", new Integer(Types.BIGINT) },
064                            { "classPK", new Integer(Types.BIGINT) },
065                            { "parentGroupId", new Integer(Types.BIGINT) },
066                            { "liveGroupId", new Integer(Types.BIGINT) },
067                            { "name", new Integer(Types.VARCHAR) },
068                            { "description", new Integer(Types.VARCHAR) },
069                            { "type_", new Integer(Types.INTEGER) },
070                            { "typeSettings", new Integer(Types.VARCHAR) },
071                            { "friendlyURL", new Integer(Types.VARCHAR) },
072                            { "active_", new Integer(Types.BOOLEAN) }
073                    };
074            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)";
075            public static final String TABLE_SQL_DROP = "drop table Group_";
076            public static final String ORDER_BY_JPQL = " ORDER BY group_.name ASC";
077            public static final String ORDER_BY_SQL = " ORDER BY Group_.name ASC";
078            public static final String DATA_SOURCE = "liferayDataSource";
079            public static final String SESSION_FACTORY = "liferaySessionFactory";
080            public static final String TX_MANAGER = "liferayTransactionManager";
081            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Group"),
083                            true);
084            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Group"),
086                            true);
087    
088            /**
089             * Converts the soap model instance into a normal model instance.
090             *
091             * @param soapModel the soap model instance to convert
092             * @return the normal model instance
093             */
094            public static Group toModel(GroupSoap soapModel) {
095                    Group model = new GroupImpl();
096    
097                    model.setGroupId(soapModel.getGroupId());
098                    model.setCompanyId(soapModel.getCompanyId());
099                    model.setCreatorUserId(soapModel.getCreatorUserId());
100                    model.setClassNameId(soapModel.getClassNameId());
101                    model.setClassPK(soapModel.getClassPK());
102                    model.setParentGroupId(soapModel.getParentGroupId());
103                    model.setLiveGroupId(soapModel.getLiveGroupId());
104                    model.setName(soapModel.getName());
105                    model.setDescription(soapModel.getDescription());
106                    model.setType(soapModel.getType());
107                    model.setTypeSettings(soapModel.getTypeSettings());
108                    model.setFriendlyURL(soapModel.getFriendlyURL());
109                    model.setActive(soapModel.getActive());
110    
111                    return model;
112            }
113    
114            /**
115             * Converts the soap model instances into normal model instances.
116             *
117             * @param soapModels the soap model instances to convert
118             * @return the normal model instances
119             */
120            public static List<Group> toModels(GroupSoap[] soapModels) {
121                    List<Group> models = new ArrayList<Group>(soapModels.length);
122    
123                    for (GroupSoap soapModel : soapModels) {
124                            models.add(toModel(soapModel));
125                    }
126    
127                    return models;
128            }
129    
130            public static final String MAPPING_TABLE_GROUPS_ORGS_NAME = "Groups_Orgs";
131            public static final Object[][] MAPPING_TABLE_GROUPS_ORGS_COLUMNS = {
132                            { "groupId", new Integer(Types.BIGINT) },
133                            { "organizationId", new Integer(Types.BIGINT) }
134                    };
135            public static final String MAPPING_TABLE_GROUPS_ORGS_SQL_CREATE = "create table Groups_Orgs (groupId LONG not null,organizationId LONG not null,primary key (groupId, organizationId))";
136            public static final boolean FINDER_CACHE_ENABLED_GROUPS_ORGS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
137                                    "value.object.finder.cache.enabled.Groups_Orgs"), true);
138            public static final String MAPPING_TABLE_GROUPS_PERMISSIONS_NAME = "Groups_Permissions";
139            public static final Object[][] MAPPING_TABLE_GROUPS_PERMISSIONS_COLUMNS = {
140                            { "groupId", new Integer(Types.BIGINT) },
141                            { "permissionId", new Integer(Types.BIGINT) }
142                    };
143            public static final String MAPPING_TABLE_GROUPS_PERMISSIONS_SQL_CREATE = "create table Groups_Permissions (groupId LONG not null,permissionId LONG not null,primary key (groupId, permissionId))";
144            public static final boolean FINDER_CACHE_ENABLED_GROUPS_PERMISSIONS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
145                                    "value.object.finder.cache.enabled.Groups_Permissions"), true);
146            public static final String MAPPING_TABLE_GROUPS_ROLES_NAME = "Groups_Roles";
147            public static final Object[][] MAPPING_TABLE_GROUPS_ROLES_COLUMNS = {
148                            { "groupId", new Integer(Types.BIGINT) },
149                            { "roleId", new Integer(Types.BIGINT) }
150                    };
151            public static final String MAPPING_TABLE_GROUPS_ROLES_SQL_CREATE = "create table Groups_Roles (groupId LONG not null,roleId LONG not null,primary key (groupId, roleId))";
152            public static final boolean FINDER_CACHE_ENABLED_GROUPS_ROLES = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
153                                    "value.object.finder.cache.enabled.Groups_Roles"), true);
154            public static final String MAPPING_TABLE_GROUPS_USERGROUPS_NAME = "Groups_UserGroups";
155            public static final Object[][] MAPPING_TABLE_GROUPS_USERGROUPS_COLUMNS = {
156                            { "groupId", new Integer(Types.BIGINT) },
157                            { "userGroupId", new Integer(Types.BIGINT) }
158                    };
159            public static final String MAPPING_TABLE_GROUPS_USERGROUPS_SQL_CREATE = "create table Groups_UserGroups (groupId LONG not null,userGroupId LONG not null,primary key (groupId, userGroupId))";
160            public static final boolean FINDER_CACHE_ENABLED_GROUPS_USERGROUPS = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
161                                    "value.object.finder.cache.enabled.Groups_UserGroups"), true);
162            public static final String MAPPING_TABLE_USERS_GROUPS_NAME = com.liferay.portal.model.impl.UserModelImpl.MAPPING_TABLE_USERS_GROUPS_NAME;
163            public static final boolean FINDER_CACHE_ENABLED_USERS_GROUPS = com.liferay.portal.model.impl.UserModelImpl.FINDER_CACHE_ENABLED_USERS_GROUPS;
164            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
165                                    "lock.expiration.time.com.liferay.portal.model.Group"));
166    
167            public GroupModelImpl() {
168            }
169    
170            public long getPrimaryKey() {
171                    return _groupId;
172            }
173    
174            public void setPrimaryKey(long pk) {
175                    setGroupId(pk);
176            }
177    
178            public Serializable getPrimaryKeyObj() {
179                    return new Long(_groupId);
180            }
181    
182            public long getGroupId() {
183                    return _groupId;
184            }
185    
186            public void setGroupId(long groupId) {
187                    _groupId = groupId;
188            }
189    
190            public long getCompanyId() {
191                    return _companyId;
192            }
193    
194            public void setCompanyId(long companyId) {
195                    if (!_setOriginalCompanyId) {
196                            _setOriginalCompanyId = true;
197    
198                            _originalCompanyId = _companyId;
199                    }
200    
201                    _companyId = companyId;
202            }
203    
204            public long getOriginalCompanyId() {
205                    return _originalCompanyId;
206            }
207    
208            public long getCreatorUserId() {
209                    return _creatorUserId;
210            }
211    
212            public void setCreatorUserId(long creatorUserId) {
213                    _creatorUserId = creatorUserId;
214            }
215    
216            public String getCreatorUserUuid() throws SystemException {
217                    return PortalUtil.getUserValue(getCreatorUserId(), "uuid",
218                            _creatorUserUuid);
219            }
220    
221            public void setCreatorUserUuid(String creatorUserUuid) {
222                    _creatorUserUuid = creatorUserUuid;
223            }
224    
225            public String getClassName() {
226                    if (getClassNameId() <= 0) {
227                            return StringPool.BLANK;
228                    }
229    
230                    return PortalUtil.getClassName(getClassNameId());
231            }
232    
233            public long getClassNameId() {
234                    return _classNameId;
235            }
236    
237            public void setClassNameId(long classNameId) {
238                    if (!_setOriginalClassNameId) {
239                            _setOriginalClassNameId = true;
240    
241                            _originalClassNameId = _classNameId;
242                    }
243    
244                    _classNameId = classNameId;
245            }
246    
247            public long getOriginalClassNameId() {
248                    return _originalClassNameId;
249            }
250    
251            public long getClassPK() {
252                    return _classPK;
253            }
254    
255            public void setClassPK(long classPK) {
256                    if (!_setOriginalClassPK) {
257                            _setOriginalClassPK = true;
258    
259                            _originalClassPK = _classPK;
260                    }
261    
262                    _classPK = classPK;
263            }
264    
265            public long getOriginalClassPK() {
266                    return _originalClassPK;
267            }
268    
269            public long getParentGroupId() {
270                    return _parentGroupId;
271            }
272    
273            public void setParentGroupId(long parentGroupId) {
274                    _parentGroupId = parentGroupId;
275            }
276    
277            public long getLiveGroupId() {
278                    return _liveGroupId;
279            }
280    
281            public void setLiveGroupId(long liveGroupId) {
282                    if (!_setOriginalLiveGroupId) {
283                            _setOriginalLiveGroupId = true;
284    
285                            _originalLiveGroupId = _liveGroupId;
286                    }
287    
288                    _liveGroupId = liveGroupId;
289            }
290    
291            public long getOriginalLiveGroupId() {
292                    return _originalLiveGroupId;
293            }
294    
295            public String getName() {
296                    if (_name == null) {
297                            return StringPool.BLANK;
298                    }
299                    else {
300                            return _name;
301                    }
302            }
303    
304            public void setName(String name) {
305                    if (_originalName == null) {
306                            _originalName = _name;
307                    }
308    
309                    _name = name;
310            }
311    
312            public String getOriginalName() {
313                    return GetterUtil.getString(_originalName);
314            }
315    
316            public String getDescription() {
317                    if (_description == null) {
318                            return StringPool.BLANK;
319                    }
320                    else {
321                            return _description;
322                    }
323            }
324    
325            public void setDescription(String description) {
326                    _description = description;
327            }
328    
329            public int getType() {
330                    return _type;
331            }
332    
333            public void setType(int type) {
334                    _type = type;
335            }
336    
337            public String getTypeSettings() {
338                    if (_typeSettings == null) {
339                            return StringPool.BLANK;
340                    }
341                    else {
342                            return _typeSettings;
343                    }
344            }
345    
346            public void setTypeSettings(String typeSettings) {
347                    _typeSettings = typeSettings;
348            }
349    
350            public String getFriendlyURL() {
351                    if (_friendlyURL == null) {
352                            return StringPool.BLANK;
353                    }
354                    else {
355                            return _friendlyURL;
356                    }
357            }
358    
359            public void setFriendlyURL(String friendlyURL) {
360                    if (_originalFriendlyURL == null) {
361                            _originalFriendlyURL = _friendlyURL;
362                    }
363    
364                    _friendlyURL = friendlyURL;
365            }
366    
367            public String getOriginalFriendlyURL() {
368                    return GetterUtil.getString(_originalFriendlyURL);
369            }
370    
371            public boolean getActive() {
372                    return _active;
373            }
374    
375            public boolean isActive() {
376                    return _active;
377            }
378    
379            public void setActive(boolean active) {
380                    _active = active;
381            }
382    
383            public Group toEscapedModel() {
384                    if (isEscapedModel()) {
385                            return (Group)this;
386                    }
387                    else {
388                            return (Group)Proxy.newProxyInstance(Group.class.getClassLoader(),
389                                    new Class[] { Group.class }, new AutoEscapeBeanHandler(this));
390                    }
391            }
392    
393            public ExpandoBridge getExpandoBridge() {
394                    if (_expandoBridge == null) {
395                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
396                                            Group.class.getName(), getPrimaryKey());
397                    }
398    
399                    return _expandoBridge;
400            }
401    
402            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
403                    getExpandoBridge().setAttributes(serviceContext);
404            }
405    
406            public Object clone() {
407                    GroupImpl groupImpl = new GroupImpl();
408    
409                    groupImpl.setGroupId(getGroupId());
410    
411                    groupImpl.setCompanyId(getCompanyId());
412    
413                    GroupModelImpl groupModelImpl = groupImpl;
414    
415                    groupModelImpl._originalCompanyId = groupModelImpl._companyId;
416    
417                    groupModelImpl._setOriginalCompanyId = false;
418                    groupImpl.setCreatorUserId(getCreatorUserId());
419    
420                    groupImpl.setClassNameId(getClassNameId());
421    
422                    groupModelImpl._originalClassNameId = groupModelImpl._classNameId;
423    
424                    groupModelImpl._setOriginalClassNameId = false;
425                    groupImpl.setClassPK(getClassPK());
426    
427                    groupModelImpl._originalClassPK = groupModelImpl._classPK;
428    
429                    groupModelImpl._setOriginalClassPK = false;
430                    groupImpl.setParentGroupId(getParentGroupId());
431    
432                    groupImpl.setLiveGroupId(getLiveGroupId());
433    
434                    groupModelImpl._originalLiveGroupId = groupModelImpl._liveGroupId;
435    
436                    groupModelImpl._setOriginalLiveGroupId = false;
437                    groupImpl.setName(getName());
438    
439                    groupModelImpl._originalName = groupModelImpl._name;
440    
441                    groupImpl.setDescription(getDescription());
442    
443                    groupImpl.setType(getType());
444    
445                    groupImpl.setTypeSettings(getTypeSettings());
446    
447                    groupImpl.setFriendlyURL(getFriendlyURL());
448    
449                    groupModelImpl._originalFriendlyURL = groupModelImpl._friendlyURL;
450    
451                    groupImpl.setActive(getActive());
452    
453                    return groupImpl;
454            }
455    
456            public int compareTo(Group group) {
457                    int value = 0;
458    
459                    value = getName().toLowerCase().compareTo(group.getName().toLowerCase());
460    
461                    if (value != 0) {
462                            return value;
463                    }
464    
465                    return 0;
466            }
467    
468            public boolean equals(Object obj) {
469                    if (obj == null) {
470                            return false;
471                    }
472    
473                    Group group = null;
474    
475                    try {
476                            group = (Group)obj;
477                    }
478                    catch (ClassCastException cce) {
479                            return false;
480                    }
481    
482                    long pk = group.getPrimaryKey();
483    
484                    if (getPrimaryKey() == pk) {
485                            return true;
486                    }
487                    else {
488                            return false;
489                    }
490            }
491    
492            public int hashCode() {
493                    return (int)getPrimaryKey();
494            }
495    
496            public String toString() {
497                    StringBundler sb = new StringBundler(27);
498    
499                    sb.append("{groupId=");
500                    sb.append(getGroupId());
501                    sb.append(", companyId=");
502                    sb.append(getCompanyId());
503                    sb.append(", creatorUserId=");
504                    sb.append(getCreatorUserId());
505                    sb.append(", classNameId=");
506                    sb.append(getClassNameId());
507                    sb.append(", classPK=");
508                    sb.append(getClassPK());
509                    sb.append(", parentGroupId=");
510                    sb.append(getParentGroupId());
511                    sb.append(", liveGroupId=");
512                    sb.append(getLiveGroupId());
513                    sb.append(", name=");
514                    sb.append(getName());
515                    sb.append(", description=");
516                    sb.append(getDescription());
517                    sb.append(", type=");
518                    sb.append(getType());
519                    sb.append(", typeSettings=");
520                    sb.append(getTypeSettings());
521                    sb.append(", friendlyURL=");
522                    sb.append(getFriendlyURL());
523                    sb.append(", active=");
524                    sb.append(getActive());
525                    sb.append("}");
526    
527                    return sb.toString();
528            }
529    
530            public String toXmlString() {
531                    StringBundler sb = new StringBundler(43);
532    
533                    sb.append("<model><model-name>");
534                    sb.append("com.liferay.portal.model.Group");
535                    sb.append("</model-name>");
536    
537                    sb.append(
538                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
539                    sb.append(getGroupId());
540                    sb.append("]]></column-value></column>");
541                    sb.append(
542                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
543                    sb.append(getCompanyId());
544                    sb.append("]]></column-value></column>");
545                    sb.append(
546                            "<column><column-name>creatorUserId</column-name><column-value><![CDATA[");
547                    sb.append(getCreatorUserId());
548                    sb.append("]]></column-value></column>");
549                    sb.append(
550                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
551                    sb.append(getClassNameId());
552                    sb.append("]]></column-value></column>");
553                    sb.append(
554                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
555                    sb.append(getClassPK());
556                    sb.append("]]></column-value></column>");
557                    sb.append(
558                            "<column><column-name>parentGroupId</column-name><column-value><![CDATA[");
559                    sb.append(getParentGroupId());
560                    sb.append("]]></column-value></column>");
561                    sb.append(
562                            "<column><column-name>liveGroupId</column-name><column-value><![CDATA[");
563                    sb.append(getLiveGroupId());
564                    sb.append("]]></column-value></column>");
565                    sb.append(
566                            "<column><column-name>name</column-name><column-value><![CDATA[");
567                    sb.append(getName());
568                    sb.append("]]></column-value></column>");
569                    sb.append(
570                            "<column><column-name>description</column-name><column-value><![CDATA[");
571                    sb.append(getDescription());
572                    sb.append("]]></column-value></column>");
573                    sb.append(
574                            "<column><column-name>type</column-name><column-value><![CDATA[");
575                    sb.append(getType());
576                    sb.append("]]></column-value></column>");
577                    sb.append(
578                            "<column><column-name>typeSettings</column-name><column-value><![CDATA[");
579                    sb.append(getTypeSettings());
580                    sb.append("]]></column-value></column>");
581                    sb.append(
582                            "<column><column-name>friendlyURL</column-name><column-value><![CDATA[");
583                    sb.append(getFriendlyURL());
584                    sb.append("]]></column-value></column>");
585                    sb.append(
586                            "<column><column-name>active</column-name><column-value><![CDATA[");
587                    sb.append(getActive());
588                    sb.append("]]></column-value></column>");
589    
590                    sb.append("</model>");
591    
592                    return sb.toString();
593            }
594    
595            private long _groupId;
596            private long _companyId;
597            private long _originalCompanyId;
598            private boolean _setOriginalCompanyId;
599            private long _creatorUserId;
600            private String _creatorUserUuid;
601            private long _classNameId;
602            private long _originalClassNameId;
603            private boolean _setOriginalClassNameId;
604            private long _classPK;
605            private long _originalClassPK;
606            private boolean _setOriginalClassPK;
607            private long _parentGroupId;
608            private long _liveGroupId;
609            private long _originalLiveGroupId;
610            private boolean _setOriginalLiveGroupId;
611            private String _name;
612            private String _originalName;
613            private String _description;
614            private int _type;
615            private String _typeSettings;
616            private String _friendlyURL;
617            private String _originalFriendlyURL;
618            private boolean _active;
619            private transient ExpandoBridge _expandoBridge;
620    }