This Java snippet demonstrates how the JobSource can be used to retrieve information on the current jobs in an Intelligence Server, tied to the current WebIServerSession:
// Fetch a WebObjectsFactory instance from the current WebIServerSession
WebObjectsFactory factory = serverSession.getFactory();
// 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());
// Loop through each job that we've found
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();
}