[Anthill-pro] JasperException in Custom Agent Activity report script

Pacileo, Kenneth kenneth_pacileo at uhc.com
Fri Mar 14 16:05:52 CST 2008


False alarm... Had a missing ; on the import, wrong method call for
restoreAll and wrong array name in the for loop. 

Correct section: 
// Add the agents to choose from 
SelectParamMetaData agentParams = new SelectParamMetaData();
Agent[] allAgentsArray = AgentFactory.getInstance().restoreAll();
String[] labels = new String[allAgentsArray.length + 1];
String[] values = new String[allAgentsArray.length + 1];
for (int i = 0; i < allAgentsArray.length; i++) {
   labels[i] = allAgentsArray[i].getName();
   values[i] = allAgentsArray[i].getId().toString();
}
labels[allAgentsArray.length] = "All";
values[allAgentsArray.length] = "all";
agentParams.setLabels(labels);
agentParams.setValues(values);
agentParams.setName("agent");
agentParams.setLabel("Agent");
agentParams.setDescription("Select the agent to run this report against.
Or select 'All' to display all agents together.");
rmd.addParameter(agentParams);

Regards,
Ken

-----Original Message-----
From: anthill-pro-bounces at lists.urbancode.com
[mailto:anthill-pro-bounces at lists.urbancode.com] On Behalf Of Pacileo,
Kenneth
Sent: Friday, March 14, 2008 5:52 PM
To: AnthillPro user and support list.
Subject: [Anthill-pro] JasperException in Custom Agent Activity report
script

All,

I'm trying to create a report that will show me all the activity of
originating workflows on a specific agent. The metat-data script I'm
using is throwing a JasperExcetion. I used the format of the "Deployment
Log" script and changed the month selection section to agent selection.
I then used the AgentFactory class to get the instance and restore all
the active agents. The script throws the exception on the
AgentFactory.getInstance().restoreAll() method call. What should I be
using instead?

I need this report so I can review activity on the agents and make sure
they are all being utilized as expected.

Regards,
Ken

JasperException: javax.servlet.jsp.el.ELException: An error occurred
while getting property "metaData" from an instance of class
com.urbancode.anthill3.domain.reporting.Report

Meta-Data Script:
import com.urbancode.anthill3.domain.agent.*
import com.urbancode.anthill3.domain.project.*;
import com.urbancode.anthill3.domain.reporting.*;
import com.urbancode.anthill3.domain.userprofile.*;
import java.text.SimpleDateFormat;
import java.util.*;

ReportMetaData rmd = new ReportMetaData();

// Add some projects to choose from
SelectParamMetaData params = new SelectParamMetaData();
Project[] allMyProjectsArray =
ProjectFactory.getInstance().restoreAllActive();
String[] labels = new String[allMyProjectsArray.length + 1];
String[] values = new String[allMyProjectsArray.length + 1];
for (int i = 0; i < allMyProjectsArray.length; i++) {
   labels[i] = allMyProjectsArray[i].getName();
   values[i] = allMyProjectsArray[i].getId().toString();
}
labels[allMyProjectsArray.length] = "All";
values[allMyProjectsArray.length] = "all";
params.setLabels(labels);
params.setValues(values);
params.setName("project");
params.setLabel("Project");
params.setDescription("Select the project to evaluate successful and
failed executions of that project. Or select 'All' to display all
projects together.");
rmd.addParameter(params);

// Add the agents to choose from 
SelectParamMetaData agentParams = new SelectParamMetaData();
Agent[] allAgentsArray = AgentFactory.getInstance().restoreAllActive();
//Exception being thrown on this statement
String[] labels = new String[allAgentsArray.length + 1];
String[] values = new String[allAgentsArray.length + 1];
for (int i = 0; i < allMyProjectsArray.length; i++) {
   labels[i] = allAgentsArray[i].getName();
   values[i] = allAgentsArray[i].getId().toString();
}
labels[allAgentsArray.length] = "All";
values[allAgentsArray.length] = "all";
agentParams.setLabels(labels);
agentParams.setValues(values);
agentParams.setName("agent");
agentParams.setLabel("Agent");
agentParams.setDescription("Select the agent to run this report against.
Or select 'All' to display all agents together.");
rmd.addParameter(agentParams);

// Configure columns
// May need to change the columns later. Not sure what is needed right
now.
rmd.addColumn("Project");
rmd.addColumn("Action");
rmd.addColumn("Environment");
rmd.addColumn("Latest Stamp");
rmd.addColumn("Agent(s)");
rmd.addColumn("Status");
rmd.addColumn("Build Date");

return rmd;


Report Script: // This script works when I remove the agent array
section from the Meta-Data Script
import com.urbancode.anthill3.dashboard.*;
import com.urbancode.anthill3.domain.reporting.*;
import com.urbancode.anthill3.domain.userprofile.*;
import com.urbancode.anthill3.domain.workflow.*;
import com.urbancode.anthill3.domain.buildlife.*;
import com.urbancode.commons.util.Duration;
import java.util.*;
 
// Figure out the project to use. "project" is the name of the parameter
in the meta data script. It's provided here.

Long projectId = null;
if (project == null || project.equals("all")) {
   // leave as null;
}
else {
   projectId = Long.parseLong(project);
}

BuildLifeWorkflowCaseSummary[] summaries =
DashboardFactory.getInstance().getBuildLifeWorkflowSummariesForProject(p
rojectId);

ReportOutput output = new ReportOutput(metaData);

System.out.println("Number of WorkflowSummaries for Project = " +
summaries.length);
for (int i = 0; i < summaries.length; i++) {
    
buildLife =
BuildLifeFactory.getInstance().restore(summaries[i].getBuildLifeId());
  workflow =
WorkflowCaseFactory.getInstance().restore(summaries[i].getCaseId());
  originating =
WorkflowCaseFactory.getInstance().restoreOriginatingForBuildLife(buildLi
fe); 
    
// Only include originating workflows 
  if (workflow.getWorkflow().isOriginating() &&
      workflow.getServerGroup().getShortName() != null ) {

    // calculate the agent(s) invloved
    jobs = workflow.getJobTraceArray();
    String agents = "";
    for (int j = 0; j < jobs.length; j++) {
      agents += (jobs[j].getAgent().getName() + " ");
    }

ReportRow row = new ReportRow(output, "1");
    row.setColumnValue("Project", summaries[i].getProjectName());
    row.setColumnValue("Action", summaries[i].getWorkflowName());
    row.setColumnValue("Environment",
workflow.getServerGroup().getName());
    row.setColumnValue("Latest Stamp", summaries[i].getLatestStamp());
    row.setColumnValue("Agent(s)",agents); 
    row.setColumnValue("Status", summaries[i].getStatus().getName());
    row.setColumnValue("Build Date", originating.getEndDate() == null ?
"Running": String.valueOf(originating.getEndDate()));
    

    output.addRow(row);
  }
}

return output;




This e-mail, including attachments, may include confidential and/or 
proprietary information, and may be used only by the person or entity to

which it is addressed. If the reader of this e-mail is not the intended 
recipient or his or her authorized agent, the reader is hereby notified 
that any dissemination, distribution or copying of this e-mail is 
prohibited. If you have received this e-mail in error, please notify the

sender by replying to this message and delete this e-mail immediately.

_______________________________________________
Anthill-pro mailing list
Anthill-pro at lists.urbancode.com
http://lists.urbancode.com/mailman/listinfo/anthill-pro


This e-mail, including attachments, may include confidential and/or 
proprietary information, and may be used only by the person or entity to 
which it is addressed. If the reader of this e-mail is not the intended 
recipient or his or her authorized agent, the reader is hereby notified 
that any dissemination, distribution or copying of this e-mail is 
prohibited. If you have received this e-mail in error, please notify the 
sender by replying to this message and delete this e-mail immediately.



More information about the Anthill-pro mailing list