All Downloads are FREE. Search and download functionalities are using the official Maven repository.

woko.ext.usermanagement.facets.usermanager.RenderPropertyValueEditUserRoles Maven / Gradle / Ivy

There is a newer version: 2.4-beta7
Show newest version
package woko.ext.usermanagement.facets.usermanager;

import net.sourceforge.jfacets.IFacetDescriptorManager;
import net.sourceforge.jfacets.annotations.FacetKey;
import woko.ext.usermanagement.core.User;
import woko.facets.builtin.RenderPropertyValueEdit;
import woko.facets.builtin.all.BaseRenderPropertyValueEdit;
import woko.persistence.ObjectStore;
import woko.users.UserManager;
import woko.users.UsernameResolutionStrategy;

import java.util.Iterator;
import java.util.List;

@FacetKey(name="renderPropertyValueEdit_roles", profileId="usermanager", targetObjectType = User.class)
public class RenderPropertyValueEditUserRoles<
        OsType extends ObjectStore,
        UmType extends UserManager,
        UnsType extends UsernameResolutionStrategy,
        FdmType extends IFacetDescriptorManager
        > extends BaseRenderPropertyValueEdit implements RenderPropertyValueEdit {

    @Override
    public String getPath() {
        return "/WEB-INF/woko/ext/usermanagement/renderPropertyValueEditUserRoles.jsp";
    }

    public String getRolesStr() {
        User user = (User)getOwningObject();
        List roles = user.getRoles();
        if (roles==null) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        for (Iterator it = roles.iterator(); it.hasNext(); ) {
            String role = it.next();
            sb.append(role);
            if (it.hasNext()) {
                sb.append(", ");
            }
        }
        return sb.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy