Package org.beangle.ems.security.nav

Examples of org.beangle.ems.security.nav.Menu


  public String info() {
    Long entityId = getEntityId(getShortName());
    if (null == entityId) {
      logger.warn("cannot get paremeter {}Id or {}.id", getShortName(), getShortName());
    }
    Menu menu = (Menu) getModel(getEntityName(), entityId);
    put(getShortName(), menu);
    if (!menu.getResources().isEmpty()) {
      OqlBuilder<Authority> groupQuery = OqlBuilder.from(Authority.class, "auth");
      groupQuery.where("auth.resource in(:resources)", menu.getResources()).select(
          "distinct auth.group");
      put("groups", entityDao.search(groupQuery));
    }
    return forward();
  }
View Full Code Here


    }
    sibling.add(indexno, menu);
    int nolength = String.valueOf(sibling.size()).length();
    Set<Menu> menus = CollectUtils.newHashSet();
    for (int seqno = 1; seqno <= sibling.size(); seqno++) {
      Menu one = sibling.get(seqno - 1);
      generateCode(one, StringUtils.leftPad(String.valueOf(seqno), nolength, '0'), menus);
    }
    entityDao.saveOrUpdate(menus);
  }
View Full Code Here

  public MenuPropertyExtractor(TextResource textResource) {
    super(textResource);
  }

  public Object getPropertyValue(Object target, String property) throws Exception {
    Menu menu = (Menu) target;
    if ("enabled".equals(property)) {
      return menu.isEnabled() ? "激活" : "冻结";
    } else if ("resources".equals(property)) {
      return getPropertyIn(menu.getResources(), "title");
    } else return super.getPropertyValue(target, property);
  }
View Full Code Here

    entityDao.saveOrUpdate(parents);
    return super.removeAndForward(entities);
  }

  protected String saveAndForward(Entity<?> entity) {
    Menu menu = (Menu) entity;
    try {
      List<Resource> resources = entityDao.get(Resource.class, getAll("resourceId", Long.class));
      menu.getResources().clear();
      menu.getResources().addAll(resources);
      Long newParentId = getLong("parent.id");
      int indexno = getInteger("indexno");
      Menu parent = null;
      if (null != newParentId) {
        parent = entityDao.get(Menu.class, newParentId);
      }
      menuService.move(menu, parent, indexno);
      entityDao.saveOrUpdate(menu);
View Full Code Here

  public String info() {
    Long entityId = getEntityId(getShortName());
    if (null == entityId) {
      logger.warn("cannot get paremeter {}Id or {}.id", getShortName(), getShortName());
    }
    Menu menu = (Menu) getModel(getEntityName(), entityId);
    put(getShortName(), menu);
    if (!menu.getResources().isEmpty()) {
      OqlBuilder<Authority> groupQuery = OqlBuilder.from(Authority.class, "auth");
      groupQuery.where("auth.resource in(:resources)", menu.getResources()).select(
          "distinct auth.group");
      put("groups", entityDao.search(groupQuery));
    }
    return forward();
  }
View Full Code Here

  @Override
  public String index() throws Exception {
    final String name = get("name");
    final Long menuId = getLong("menu.id");
    final Set<Menu> family;
    final Menu givenMenu;
    if (null != menuId) {
      givenMenu = entityDao.get(Menu.class, menuId);
      family = HierarchyEntityUtils.getFamily(givenMenu);
    } else {
      family = null;
      givenMenu = null;
    }

    User user = entityDao.get(User.class, getUserId());
    MenuProfile profile = menuService.getProfile(user, getLong("security.menuProfileId"));
    List<Menu> menus = Collections.emptyList();
    if (null != profile) {
      menus = menuService.getMenus(profile, user);
    }
    CollectionUtils.filter(menus, new Predicate() {
      public boolean evaluate(Object object) {
        Menu amenu = (Menu) object;
        if (null != family && !family.contains(amenu)) return false;
        if (StringUtils.isNotEmpty(name)) {
          if (!amenu.getChildren().isEmpty()) return false;
          StringBuilder searchTarget = new StringBuilder(StrUtils.concat(amenu.getName(),
              amenu.getTitle(), amenu.getRemark()));
          for (Resource res : amenu.getResources()) {
            searchTarget.append(StrUtils.concat(res.getName(), res.getTitle(), res.getRemark()));
          }
          return searchTarget.toString().contains(name);
        } else return true;
      }
View Full Code Here

    MenuProfile profile = menuService.getProfile(user, getLong("security.menuProfileId"));
    List<Menu> menus = menuService.getMenus(profile, user);
    List<Menu> menuPath = CollectUtils.newArrayList();
    Long menuId = getLong("menu.id");
    if (null != menuId) {
      Menu menu = entityDao.get(Menu.class, menuId);
      menus.retainAll(HierarchyEntityUtils.getFamily(menu));
      menus.remove(menu);
      menuPath = HierarchyEntityUtils.getPath(menu);
    }
    put("menuPath", menuPath);
View Full Code Here

    return forward();
  }

  public String access() {
    Long menuId = getLong("menu.id");
    Menu menu = entityDao.get(Menu.class, menuId);
    List<Menu> paths = HierarchyEntityUtils.getPath(menu);
    put("menu", menu);
    put("paths", paths);
    return forward();
  }
View Full Code Here

    put("profiles", entityDao.getAll(MenuProfile.class));
  }

  protected void editSetting(Entity<?> entity) {
    put("profiles", entityDao.getAll(MenuProfile.class));
    Menu menu = (Menu) entity;
    List<Menu> folders = CollectUtils.newArrayList();
    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());
      // 查找可以作为父节点的菜单
      OqlBuilder<Menu> folderBuilder = OqlBuilder.from(Menu.class, "m");
      folderBuilder.where("m.entry is null and m.profile=:profile", profile);
      folderBuilder.orderBy("m.code");
      folders = entityDao.search(folderBuilder);
      if (null != menu.getParent() && !folders.contains(menu.getParent())) folders
          .add(menu.getParent());
      folders.removeAll(HierarchyEntityUtils.getFamily(menu));
    }
    List<Resource> resurces = entityDao.search(builder);
    Set<Resource> existResources = menu.getResources();
    if (null != resurces) {
      resurces.removeAll(existResources);
    }
    put("parents", folders);
    put("resources", resurces);
View Full Code Here

TOP

Related Classes of org.beangle.ems.security.nav.Menu

Copyright © 2018 www.massapicom. 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.