001    /**
002     * Copyright (c) 2000-2013 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.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.Group;
022    import com.liferay.portal.service.GroupLocalServiceUtil;
023    
024    import java.util.ArrayList;
025    import java.util.List;
026    
027    /**
028     * The extended model base implementation for the Group service. Represents a row in the "Group_" database table, with each column mapped to a property of this class.
029     *
030     * <p>
031     * This class exists only as a container for the default extended model level methods generated by ServiceBuilder. Helper methods and all application logic should be put in {@link GroupImpl}.
032     * </p>
033     *
034     * @author Brian Wing Shun Chan
035     * @see GroupImpl
036     * @see com.liferay.portal.model.Group
037     * @generated
038     */
039    public abstract class GroupBaseImpl extends GroupModelImpl implements Group {
040            /*
041             * NOTE FOR DEVELOPERS:
042             *
043             * Never modify or reference this class directly. All methods that expect a group model instance should use the {@link Group} interface instead.
044             */
045            @Override
046            public void persist() throws SystemException {
047                    if (this.isNew()) {
048                            GroupLocalServiceUtil.addGroup(this);
049                    }
050                    else {
051                            GroupLocalServiceUtil.updateGroup(this);
052                    }
053            }
054    
055            @Override
056            @SuppressWarnings("unused")
057            public String buildTreePath() throws PortalException, SystemException {
058                    List<Group> groups = new ArrayList<Group>();
059    
060                    Group group = this;
061    
062                    while (group != null) {
063                            groups.add(group);
064    
065                            group = GroupLocalServiceUtil.fetchGroup(group.getParentGroupId());
066                    }
067    
068                    StringBundler sb = new StringBundler((groups.size() * 2) + 1);
069    
070                    sb.append(StringPool.SLASH);
071    
072                    for (int i = groups.size() - 1; i >= 0; i--) {
073                            group = groups.get(i);
074    
075                            sb.append(group.getGroupId());
076                            sb.append(StringPool.SLASH);
077                    }
078    
079                    return sb.toString();
080            }
081    
082            @Override
083            public void updateTreePath(String treePath) throws SystemException {
084                    Group group = this;
085    
086                    group.setTreePath(treePath);
087    
088                    GroupLocalServiceUtil.updateGroup(group);
089            }
090    }