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