Exemplo n.º 1
0
 /**
  * 在一个集合中查找子
  *
  * @param menuList 所有菜单集合
  * @param parentid 父id
  * @return 找到的子集合
  */
 private List<Menu> getChildren(List<Menu> menuList, Integer parentid) {
   List<Menu> children = new ArrayList<Menu>();
   for (Menu menu : menuList) {
     if (menu.getPid().compareTo(parentid) == 0) {
       menu.setChildren(this.getChildren(menuList, menu.getId()));
       children.add(menu);
     }
   }
   return children;
 }
Exemplo n.º 2
0
 @Override
 public Integer add(Menu menu) {
   if (menu.getTitle() == null) throw new IllegalArgumentException("title argument is null");
   if (menu.getPid() == null) throw new IllegalArgumentException("pid argument is null");
   if (menu.getUrl() == null) throw new IllegalArgumentException("url argument is null");
   if (menu.getSorder() == null) throw new IllegalArgumentException("sorder argument is null");
   menu.setDeleteflag(0);
   this.baseDaoSupport.insert("menu", menu);
   return this.baseDaoSupport.getLastId("menu");
 }
Exemplo n.º 3
0
 @Override
 public List<Menu> getMenuTree(Integer menuid) {
   if (menuid == null) throw new IllegalArgumentException("menuid argument is null");
   List<Menu> menuList = this.getMenuList();
   List<Menu> topMenuList = new ArrayList<Menu>();
   for (Menu menu : menuList) {
     if (menu.getPid().compareTo(menuid) == 0) {
       List<Menu> children = this.getChildren(menuList, menu.getId());
       menu.setChildren(children);
       topMenuList.add(menu);
     }
   }
   return topMenuList;
 }
Exemplo n.º 4
0
 @Override
 public void edit(Menu menu) {
   if (menu.getId() == null) throw new IllegalArgumentException("id argument is null");
   if (menu.getTitle() == null) throw new IllegalArgumentException("title argument is null");
   if (menu.getPid() == null) throw new IllegalArgumentException("pid argument is null");
   if (menu.getUrl() == null) throw new IllegalArgumentException("url argument is null");
   if (menu.getSorder() == null) throw new IllegalArgumentException("sorder argument is null");
   menu.setDeleteflag(0);
   this.baseDaoSupport.update("menu", menu, "id=" + menu.getId());
 }
Exemplo n.º 5
0
  /**
   * 将一个menu结点数据保存在库中
   *
   * @param ele
   * @param parentId
   */
  private void addMenu(Element ele, Integer parentId) {
    try {
      Menu menu = new Menu();
      menu.setPid(parentId);

      String text = ele.getAttribute("text");
      String url = ele.getAttribute("url");
      String type = ele.getAttribute("type");
      String selected = ele.getAttribute("selected");
      String target = ele.getAttribute("target");
      String mode = ele.getAttribute("mode");
      if (type == null) {
        type = ((Element) ele.getParentNode()).getAttribute("type");
      }

      if (target != null) {
        menu.setTarget(target);
      }

      int menuType = Menu.MENU_TYPE_APP;
      if ("sys".equals(type)) menuType = Menu.MENU_TYPE_SYS;
      if ("app".equals(type)) menuType = Menu.MENU_TYPE_APP;
      if ("ext".equals(type)) menuType = Menu.MENU_TYPE_EXT;

      menu.setMenutype(menuType);
      menu.setTitle(text);
      if ((selected != null) && (!selected.equals(""))) {
        menu.setSelected(Integer.valueOf(selected));
      }
      if (url != null) menu.setUrl(url);
      menu.setSorder(50);
      if (mode != null) menu.setAppid(mode);

      Integer menuid = this.menuManager.add(menu);
      NodeList children = ele.getChildNodes();

      if (children != null) {
        this.addMenu(children, menuid);
      }
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException("install menu error");
    }
  }
Exemplo n.º 6
0
 /*     */ private void fillChildMenu(List<Menu> menuList, Element parentEl) /*     */ {
   /* 179 */ for (Menu menu : menuList)
     /* 180 */ if (menu.getMenutype().intValue() != 1) {
       /* 181 */ Element menuEl = new Element("menu");
       /* 182 */ menuEl.setAttribute("text", menu.getTitle());
       /* 183 */ String url = menu.getUrl();
       /* 184 */ if (!StringUtil.isEmpty(url)) {
         /* 185 */ menuEl.setAttribute("url", url);
         /*     */ }
       /*     */
       /* 188 */ String target = menu.getTarget();
       /* 189 */ if (!StringUtil.isEmpty(target)) {
         /* 190 */ menuEl.setAttribute("target", target);
         /*     */ }
       /*     */
       /* 193 */ List children = menu.getChildren();
       /* 194 */ if ((children != null) && (!children.isEmpty())) {
         /* 195 */ fillChildMenu(children, menuEl);
         /*     */ }
       /* 197 */ parentEl.addContent(menuEl);
       /*     */ }
   /*     */ }