Ejemplo n.º 1
0
  // 子节点列表
  @RequestMapping(value = "/path/list")
  public void getChildren(HttpServletRequest request, HttpServletResponse response) {
    String searchPath = request.getParameter("searchPath"); // 搜索路径

    /*
     * 第一层 searchPath =/content/* 第二层 searchPath
     * =/content/folder[@name='总经理组']/*
     */
    CRNConnect connection = this.getConnect(); // cognos8连接
    if (connection != null) {

      try {

        JSONArray result = new JSONArray(); // 返回结果
        if (searchPath != null) { // 非根节点
          BaseClass[] queryList = cognos8Service.getChildren(connection, searchPath); // 查询子节点

          if (queryList != null && queryList.length > 0) {

            for (BaseClass c : queryList) {
              result.add(
                  new JSONObject()
                      .element("searchPath", c.getSearchPath().getValue())
                      // searchPath
                      .element("name", c.getDefaultName().getValue())
                      // 节点名称
                      .element("isexpand", false)
                      // 不自动展开
                      .element("children", new JSONArray())
                      // 类型
                      .element("className", c.getClass().getName())
                      .element("id", c.getStoreID().getValue().getValue())); // ID
            }
          }
        } else { // 根节点
          result.add(
              new JSONObject()
                  .element("searchPath", "/content")
                  // searchPath
                  .element("name", "公共文件夹")
                  // 节点名称
                  .element("isexpand", false)
                  // 不自动展开
                  .element("children", new JSONArray())
                  // 类型
                  .element("className", "com.cognos.developer.schemas.bibus._3.Folder")
                  .element("id", "-1"));
        }

        response.getWriter().print(result.toString());
      } catch (Exception e) {
        // TODO Auto-generated catch block
        logger.error("", e);
      }
    }
  }
Ejemplo n.º 2
0
  // 子节点列表
  @RequestMapping(value = "/report/list")
  public void getChildren(
      HttpServletRequest request, HttpServletResponse response, int page, int pagesize) {
    String searchPath = request.getParameter("searchPath"); // 搜索路径
    CRNConnect connection = this.getConnect(); // cognos8连接

    if (connection != null) {
      /*
       * 第一层 searchPath =/content/* 第二层 searchPath
       * =/content/folder[@name='总经理组']/*
       */
      try {
        JSONObject result = new JSONObject();

        JSONArray Rows = new JSONArray(); // 返回结果列表
        if (searchPath != null) { // 非根节点
          BaseClass[] queryList = cognos8Service.getChildren(connection, searchPath);

          if (queryList != null && queryList.length > 0) {

            for (int i = (page * pagesize - pagesize);
                i < (page * pagesize) && i < queryList.length;
                i++) {

              BaseClass c = queryList[i]; // 节点
              Rows.add(
                  new JSONObject()
                      .element("searchPath", c.getSearchPath().getValue())
                      // searchPath
                      .element("reportName", c.getDefaultName().getValue())
                      // 节点名称
                      .element("isexpand", false)
                      // 不自动展开
                      .element("icon", this.getIconURL(request, c))
                      // 图标
                      .element("children", new JSONArray())
                      // 类型
                      .element("className", c.getClass().getName())
                      .element("id", c.getStoreID().getValue().getValue())); // ID
            }
            result.put("Total", queryList.length); // 总行数
          } else {
            result.put("Total", 0); // 总行数
          }
        } else { // 根节点
          Rows.add(
              new JSONObject()
                  .element("searchPath", "/content")
                  // searchPath
                  .element("reportName", "公共文件夹")
                  // 节点名称
                  .element("isexpand", false)
                  // 不自动展开
                  .element("children", new JSONArray())
                  // 类型
                  .element("className", "com.cognos.developer.schemas.bibus._3.Folder")
                  .element(
                      "icon", request.getContextPath() + "/static/images/icon_folder.gif") // 图标
                  .element("id", "-1"));

          result.put("Total", 1); // 总行数
        }

        result.put("Rows", Rows); // 查询结果列表

        response.getWriter().print(result.toString()); // 输出
      } catch (Exception e) {
        // TODO Auto-generated catch block
        logger.error("", e);
      }
    }
  }