Examples of MenuProfile


Examples of org.beangle.security.blueprint.MenuProfile

    Long menuProfileId = Params.getLong("menuProfileId");
    if (null == menuProfileId && !menuProfiles.isEmpty()) {
      menuProfileId = ((MenuProfile) (menuProfiles.get(0))).getId();
    }
    if (null != menuProfileId) {
      MenuProfile menuProfile = (MenuProfile) entityDao.get(MenuProfile.class, menuProfileId);
      List<Menu> menus = authorityService.getMenus(menuProfile, user);
      Set<Resource> resources = CollectUtils
          .newHashSet(authorityService.getResources(user));
      Map<String, Group> groupMap = CollectUtils.newHashMap();
      Map<String, List<Menu>> groupMenusMap = CollectUtils.newHashMap();
View Full Code Here

Examples of org.beangle.security.blueprint.MenuProfile

  protected void editSetting(Entity<?> entity) {
    put("profiles", entityDao.getAll(MenuProfile.class));
    Menu menu = (Menu) entity;
    OqlBuilder<Resource> builder = OqlBuilder.from(Resource.class, "r");
    if (null != menu.getProfile() && null != menu.getProfile().getId()) {
      MenuProfile profile = entityDao.get(MenuProfile.class, menu.getProfile().getId());
      builder.where("exists(from r.categories as rc where rc=:category)",
          profile.getCategory());
    }
    List<Resource> resurces = entityDao.search(builder);
    Set<Resource> existResources = menu.getResources();
    if (null != resurces) {
      resurces.removeAll(existResources);
View Full Code Here

Examples of org.beangle.security.blueprint.MenuProfile

    query.where("menuProfile.category in(:categories)", categories);
    List<MenuProfile> menuProfiles = entityDao.search(query);
    put("menuProfiles", menuProfiles);

    Long menuProfileId = getLong("menuProfileId");
    MenuProfile menuProfile = null;
    if (null != menuProfileId) {
      menuProfile = entityDao.get(MenuProfile.class, menuProfileId);
      if (!menuProfile.getCategory().equals(ao.getCategory())) {
        menuProfile = (menuProfiles.get(0));
      }
    } else {
      menuProfile = (menuProfiles.get(0));
    }
    if (null != menuProfile) {
      List<Menu> menus = null;
      Collection<Resource> resources = null;
      if (isAdmin(user)) {
        menus = menuProfile.getMenus();
        resources = entityDao.getAll(Resource.class);
      } else {
        menus = authorityService.getMenus(menuProfile, user);
        resources = authorityService.getResources(user);
      }
View Full Code Here

Examples of org.beangle.security.blueprint.MenuProfile

   * @return
   * @throws Exception
   */
  public String save() {
    Group mao = entityDao.get(Group.class, getLong("group.id"));
    MenuProfile menuProfile = (MenuProfile) entityDao.get(MenuProfile.class,
        getLong("menuProfileId"));
    Set<Resource> newResources = CollectUtils.newHashSet(entityDao.get(Resource.class,
        SeqStrUtils.transformToLong(get("resourceId"))));

    // 管理员拥有的菜单权限和系统资源
    User manager = getUser();
    Set<Menu> mngMenus = null;
    Set<Resource> mngResources = CollectUtils.newHashSet();
    if (isAdmin(manager)) {
      mngMenus = CollectUtils.newHashSet(menuProfile.getMenus());
    } else {
      mngMenus = CollectUtils.newHashSet(authorityService.getMenus(menuProfile,
          (User) manager));
    }
    for (final Menu m : mngMenus) {
      mngResources.addAll(m.getResources());
    }

    // 确定要删除的菜单和系统资源
    // Set<MenuAuthority> removedMenus = CollectionUtil.newHashSet();
    // for (MenuAuthority ma : mao.getMenuAuthorities()) {
    // if (mngMenus.contains(ma.getMenu()) &&
    // ma.getMenu().getProfile().equals(menuProfile)) {
    // if (!newMenus.contains(ma.getMenu())) {
    // removedMenus.add(ma);
    // } else {
    // newMenus.remove(ma.getMenu());
    // }
    // }
    // }

    Set<Authority> removedResources = CollectUtils.newHashSet();
    for (final Authority au : mao.getAuthorities()) {
      if (mngResources.contains(au.getResource())) {
        if (!newResources.contains(au.getResource())) {
          removedResources.add(au);
        } else {
          newResources.remove(au.getResource());
        }
      }
    }

    // 删除菜单和系统资源
    // mao.getMenuAuthorities().removeAll(removedMenus);
    mao.getAuthorities().removeAll(removedResources);

    // 添加新的菜单和系统资源
    // for (Menu menu : newMenus) {
    // MenuAuthority authority = Model.newInstance(MenuAuthority.class);
    // authority.setGroup(mao);
    // authority.setMenu(menu);
    // mao.getMenuAuthorities().add(authority);
    // }

    for (Resource resource : newResources) {
      Authority authority = Model.newInstance(Authority.class);
      authority.setGroup(mao);
      authority.setResource(resource);
      mao.getAuthorities().add(authority);
    }

    entityDao.saveOrUpdate(mao);
    authorityManager.refreshGroupAuthorities(new GrantedAuthorityBean(mao.getName()));

    Action redirect = Action.to(this).method("edit");
    redirect.param("group.id", mao.getId()).param("menuProfileId", menuProfile.getId());
    String displayFreezen = get("displayFreezen");
    if (null != displayFreezen) {
      redirect.param("displayFreezen", displayFreezen);
    }
    return redirect(redirect, "info.save.success");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.