Esempio n. 1
0
  public MobileDashboard(
      IParameterProvider pathParams, DashboardDesignerContentGenerator generator) {
    super(pathParams, generator);
    IPentahoSession userSession = PentahoSessionHolder.getSession();
    final ISolutionRepository solutionRepository =
        PentahoSystem.get(ISolutionRepository.class, userSession);

    final String absRoot =
        pathParams.hasParameter("root")
            ? !pathParams.getParameter("root").toString().isEmpty()
                ? "http://" + pathParams.getParameter("root").toString()
                : ""
            : "";
    final boolean absolute =
        (!absRoot.isEmpty())
            || pathParams.hasParameter("absolute")
                && pathParams.getParameter("absolute").equals("true");

    final RenderMobileLayout layoutRenderer = new RenderMobileLayout();
    final RenderComponents componentsRenderer = new RenderComponents();

    try {
      final JSONObject json =
          (JSONObject)
              JsonUtils.readJsonFromInputStream(
                  solutionRepository.getResourceInputStream(dashboardLocation, true));

      json.put("settings", getWcdf().toJSON());
      final JXPathContext doc = JXPathContext.newContext(json);

      final StringBuilder dashboardBody = new StringBuilder();

      dashboardBody.append(layoutRenderer.render(doc));
      dashboardBody.append(componentsRenderer.render(doc));

      // set all dashboard members
      this.content = replaceTokens(dashboardBody.toString(), absolute, absRoot);

      this.header = renderHeaders(pathParams, this.content.toString());
      this.loaded = new Date();
    } catch (Exception e) {
      logger.error(e);
    }
  }
Esempio n. 2
0
  public Dashboard loadDashboard(Map<String, IParameterProvider> params)
      throws FileNotFoundException {
    IParameterProvider pathParams = params.get("path"), requestParams = params.get("request");
    String scheme =
        requestParams.hasParameter("inferScheme")
                && requestParams.getParameter("inferScheme").equals("false")
            ? ""
            : DashboardDesignerContentGenerator.getScheme(pathParams);
    String root = requestParams.getStringParameter("root", "");
    boolean
        absolute =
            (!root.equals(""))
                || requestParams.hasParameter("absolute")
                    && requestParams.getParameter("absolute").equals("true"),
        bypassCache =
            requestParams.hasParameter("bypassCache")
                && requestParams.getParameter("bypassCache").equals("true");
    final boolean debug =
        requestParams.hasParameter("debug") && requestParams.getParameter("debug").equals("true");

    String wcdfPath = getWcdfPath(requestParams);
    return loadDashboard(wcdfPath, debug, absolute, scheme, root, bypassCache, "");
  }