Example usage for com.liferay.portal.kernel.model Group getUnambiguousName

List of usage examples for com.liferay.portal.kernel.model Group getUnambiguousName

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Group getUnambiguousName.

Prototype

public String getUnambiguousName(String name, java.util.Locale locale);

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.java

License:Open Source License

@Override
public String getUnambiguousName(List<DDMStructure> structures, long groupId, final Locale locale)
        throws PortalException {

    if (getGroupId() == groupId) {
        return getName(locale);
    }// ww  w.  j a v a2  s  . c om

    boolean hasAmbiguousName = ListUtil.exists(structures, new PredicateFilter<DDMStructure>() {

        @Override
        public boolean filter(DDMStructure structure) {
            if (structure.getStructureId() == getStructureId()) {
                return false;
            }

            String name = structure.getName(locale);

            if (name.equals(getName(locale))) {
                return true;
            }

            return false;
        }

    });

    if (hasAmbiguousName) {
        Group group = GroupLocalServiceUtil.getGroup(getGroupId());

        return group.getUnambiguousName(getName(locale), locale);
    }

    return getName(locale);
}