3.2 Creating a Custom Report List

The section illustrates how to use the Style Intelligence API to compile a list of reports and Viewsheets for a given user. You can use this module in your own server pages. However, before you invest resources in creating a custom report list, consider simply embedding the contents of the default User Portal's Report tab within your application. This is the recommended and simplest implementation. See Integrating Style Intelligence into Your Web Application for further details.

The code snippet below presents the generated list of reports and Viewsheets in a Java List object. Each value in the List is an array containing the display name and encoded request URI of the report or Viewsheet.

package com.inetsoft.demo;

 

import java.util.*;

import inetsoft.sree.RepositoryEntry;

import inetsoft.sree.AnalyticRepository;

import inetsoft.sree.security.SRPrincipal;

import inetsoft.sree.internal.SUtil;

import inetsoft.util.Tool;

 

public class RepositoryList {

  public RepositoryList(SRPrincipal principal, AnalyticRepository repository) {

    this.principal = principal;

    this.repository = repository;

  }

 

  public List getFolderEntryPaths(String folderName) throws Exception {

    List<String[]> entryPaths = new ArrayList<String[]>();

    String reportParam = "op=FrameReplet&name=";

    String archiveParam = "op=FrameReport&name=";

    String vsParam = "op=vs&path=/";

 

    RepositoryEntry[] repEntries = repository.getRepositoryEntries(folderName, principal, "r", RepositoryEntry.FOLDER|RepositoryEntry.REPLET|RepositoryEntry.VIEWSHEET|RepositoryEntry.ARCHIVE);

    for(int i=0; i < repEntries.length; i++) {

      String entryPath = repEntries[i].getPath();

 

      if(repEntries[i].getType() == RepositoryEntry.REPLET) {

        String encodedPath = reportParam + Tool.encodeURL(entryPath);

entryPaths.add(new String[]{ entryPath, encodedPath});

      }

      else if(repEntries[i].getType() == RepositoryEntry.VIEWSHEET) {

        String encodedPath = vsParam + Tool.encodeURL(entryPath);

        entryPaths.add(new String[]{ entryPath, encodedPath});

      }

      else if(repEntries[i].getType() == RepositoryEntry.ARCHIVE) {

        String encodedPath = archiveParam +         Tool.encodeURL(entryPath);

        entryPaths.add(new String[]{ entryPath, encodedPath});

      }

      else if(repEntries[i].getType() == RepositoryEntry.FOLDER){

        entryPaths.addAll(getFolderEntryPaths(entryPath));

      }

    }

    return entryPaths;

  }

  private SRPrincipal principal;

  private AnalyticRepository repository;

}

The following JSP code uses the above RepositoryList class to create a custom portal interface. The repository tree is then displayed as a drop-down selection list.

<%@ page language="java" contentType="text/html" %>

<%@ page

import="com.inetsoft.demo.RepositoryList"

import ="java.util.*"

import ="inetsoft.sree.security.SRPrincipal,inetsoft.sree.internal.SUtil"

import ="inetsoft.sree.RepletRepository,inetsoft.sree.AnalyticRepository"

%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

<title>InetSoft Portal</title>

 

<script>

  function generateReport() {

    document.getElementById('rFrame').src = "/sree/Reports?" + document.form1.userReportList.value;

  }

</script>

</head>

 

<body>

<p>InetSoft Portal</p>

<form name=form1 method="POST">

<select size="1" name="userReportList" >

<%

  // Get a handle to Repository for user (assume a valid session exists)

  SRPrincipal principal = (SRPrincipal)session.getAttribute(RepletRepository.PRINCIPAL_COOKIE);

  AnalyticRepository repository = (AnalyticRepository)SUtil.getRepletRepository();

  RepositoryList rList = new RepositoryList(principal, repository);

  List<String[]> paths = rList.getFolderEntryPaths("/");

  for(int i = 0; i < paths.size(); i++) {

    String[] pArray = (String[])paths.get(i);

    String displayName = pArray[0];

    String valueName = pArray[1];

%>

  <option value=<%=valueName%>>

  <%=displayName%>

  </option>

<%

  }

%>

</select>

<input type="button" value="Generate Report" name="B1" onClick="generateReport();"></p>

</form>

<iframe id=rFrame src="about:blank" width=95% height=90%></iframe>

</body>

</html>

<< 3.1 Security API: Configuring the File Security Provider © 1996-2013 InetSoft Technology Corporation (v11.4) 3.3 Managing the Data Repository (datasource.xml) >>