Ejemplo n.º 1
0
  @RequestMapping(value = "{source}/move", method = RequestMethod.GET)
  @PageableDefaults(sort = {"parentIds=asc", "weight=asc"})
  public String showMoveForm(
      HttpServletRequest request,
      @RequestParam(value = "async", required = false, defaultValue = "false") boolean async,
      @PathVariable("source") M source,
      Searchable searchable,
      Model model) {

    if (this.permissionList != null) {
      this.permissionList.assertHasEditPermission();
    }

    List<M> models = null;

    // 排除自己及子子孙孙
    searchable.addSearchFilter("id", SearchOperator.ne, source.getId());
    searchable.addSearchFilter(
        "parentIds", SearchOperator.notLike, source.makeSelfAsNewParentIds() + "%");

    if (!async) {
      models = baseService.findAllWithSort(searchable);
    } else {
      models = baseService.findRootAndChild(searchable);
    }

    model.addAttribute("trees", convertToZtreeList(request.getContextPath(), models, async, true));

    model.addAttribute(Constants.OP_NAME, "移动节点");

    return viewName("moveForm");
  }
Ejemplo n.º 2
0
  public void testLoadM() throws Exception {
    Database database = _category.getDatabase();

    database.begin();
    M m = (M) database.load(M.class, new Integer(1));
    database.commit();

    assertNotNull(m);
    assertEquals(1, m.getId());
    assertEquals("m1", m.getName());

    Collection ns = m.getNs();
    assertNotNull(ns);
    assertEquals(2, ns.size());

    database.close();
  }
Ejemplo n.º 3
0
  private ZTree convertToZtree(M m, boolean open, boolean onlyCheckLeaf) {
    ZTree<ID> zTree = new ZTree<ID>();
    zTree.setId(m.getId());
    zTree.setpId(m.getParentId());
    zTree.setName(m.getName());
    zTree.setIconSkin(m.getIcon());
    zTree.setOpen(open);
    zTree.setRoot(m.isRoot());
    zTree.setIsParent(m.isHasChildren());

    if (onlyCheckLeaf && zTree.isIsParent()) {
      zTree.setNocheck(true);
    } else {
      zTree.setNocheck(false);
    }

    return zTree;
  }
Ejemplo n.º 4
0
  @RequestMapping(value = "{parent}/children", method = RequestMethod.GET)
  @PageableDefaults(sort = {"parentIds=asc", "weight=asc"})
  public String list(
      HttpServletRequest request,
      @PathVariable("parent") M parent,
      Searchable searchable,
      Model model)
      throws UnsupportedEncodingException {

    if (permissionList != null) {
      permissionList.assertHasViewPermission();
    }

    if (parent != null) {
      searchable.addSearchFilter("parentId", SearchOperator.eq, parent.getId());
    }

    model.addAttribute("page", baseService.findAll(searchable));

    return viewName("listChildren");
  }