MicroStrategy ONE
Obtaining a Count of Jobs, grouped first by User, then by Project
The sample code below illustrates how to obtain a count of jobs on an Intelligence Server. The count is grouped first by user, then by project. The count does not include the detailed information. A common use case for this type of API interaction is a dashboard-type application where summary data is being displayed.
// create a WebObjectsFactory instance
WebObjectsFactory factory = WebObjectsFactory.getInstance();
// Get the job source object
JobSource source = (JobSource) factory.getMonitorSource(EnumWebMonitorType.WebMonitorTypeJob);
// Set up the count settings to group the counts by user name, then by project name
CountSettings settings = source.getCountSettings();
settings.add(EnumDSSXMLJobInfo.DssXmlJobInfoUserName);
settings.add(EnumDSSXMLJobInfo.DssXmlJobInfoProjectName);
// Set level flag to only obtain count information
source.setLevel(EnumDSSXMLLevelFlags.DssXmlCountLevel);
try {
// Sends the request to Intelligence Server to retrieve job information
JobResults results = source.getJobs();
// Retrieve the count summary object and loop through it
CountSummary summary = results.getCountSummary();
System.out.println("Total Jobs: " + summary.getCount());
for (int i=0; i < summary.size(); i++) {
// Get the count info object and print out its information
CountInfo outerInfo = summary.get(i);
System.out.println("\tUser " + outerInfo.getValue() + ": " + outerInfo.getCount() + " job(s)");
// Loop through its children count info objects
for (int j=0; j < outerInfo.size(); j++) {
CountInfo innerInfo = outerInfo.get(j);
System.out.println("\t\tProject \"" + innerInfo.getValue() + "\":" + innerInfo.getCount() + " job(s)");
}
}
} catch (WebObjectsAdminException woae) {
woae.printStackTrace();
}
Sample output
The output would look something like the following:
Total Jobs: 12
User Web Tester: 7 job(s)
Project "MicroStrategy Tutorial": 4 job(s)
Project "My First Project": 3 job(s)
User Administrator: 5 jobs
Project "MicroStrategy Tutorial": 1 job(s)
Project "My First Project": 2 job(s)
Project "Duplicated Feature Testing Vmall": 2 job(s)