Line 1: |
- |
This report shows a user the total number of builds during times of the day. This report has to be used in conjunction with a report template such as the [[Bar Chart Template]].
|
+ |
This only report on the successes and the failures for a provided time interval. This report has to be used in conjunction with a report template such as the [[Bar Chart Template]].
|
|
|
|
|
|
---- |
|
---- |
Line 6: |
|
|
|
|
|
<pre>import com.urbancode.anthill3.domain.reporting.*; |
|
<pre>import com.urbancode.anthill3.domain.reporting.*; |
|
|
+ |
import java.text.*;
|
|
|
+ |
import java.util.*;
|
|
|
|
|
|
ReportMetaData rmd = new ReportMetaData(); |
|
ReportMetaData rmd = new ReportMetaData(); |
Line 11: |
- |
rmd.addColumn("12a");
|
+ |
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss z");
|
- |
rmd.addColumn("1a");
|
|
|
- |
rmd.addColumn("2a");
|
|
|
- |
rmd.addColumn("3a");
|
|
|
- |
rmd.addColumn("4a");
|
|
|
- |
rmd.addColumn("5a");
|
|
|
- |
rmd.addColumn("6a");
|
|
|
- |
rmd.addColumn("7a");
|
|
|
- |
rmd.addColumn("8a");
|
|
|
- |
rmd.addColumn("9a");
|
|
|
- |
rmd.addColumn("10a");
|
|
|
- |
rmd.addColumn("11a");
|
|
|
- |
rmd.addColumn("12p");
|
|
|
- |
rmd.addColumn("1p");
|
|
|
- |
rmd.addColumn("2p");
|
|
|
- |
rmd.addColumn("3p");
|
|
|
- |
rmd.addColumn("4p");
|
|
|
- |
rmd.addColumn("5p");
|
|
|
- |
rmd.addColumn("6p");
|
|
|
- |
rmd.addColumn("7p");
|
|
|
- |
rmd.addColumn("8p");
|
|
|
- |
rmd.addColumn("9p");
|
|
|
- |
rmd.addColumn("10p");
|
|
|
- |
rmd.addColumn("11p");
|
|
|
|
|
|
|
- |
return rmd;
|
+ |
TextParamMetaData startDateParam = new TextParamMetaData();
|
|
|
|
|
|
|
+ |
startDateParam.setName("startDateStr");
|
|
|
+ |
startDateParam.setLabel("Start Date");
|
|
|
+ |
startDateParam.setDescription("The Interval Start Date yyyy-MM-dd kk:mm:ss z");
|
|
|
+ |
startDateParam.setRequired(true);
|
|
|
|
|
|
|
+ |
Calendar cal = Calendar.getInstance();
|
|
|
+ |
cal.add(Calendar.MONTH, -1);
|
|
|
|
|
|
|
+ |
startDateParam.setDefaultValue(DATE_FORMAT.format(cal.getTime()));
|
|
|
|
|
|
|
+ |
rmd.addParameter(startDateParam);
|
|
|
|
|
|
|
+ |
TextParamMetaData endDateParam = new TextParamMetaData();
|
|
|
|
|
|
|
+ |
endDateParam.setName("endDateStr");
|
|
|
+ |
endDateParam.setLabel("End Date");
|
|
|
+ |
endDateParam.setDescription("The Interval End Date yyyy-MM-dd kk:mm:ss z");
|
|
|
+ |
endDateParam.setRequired(true);
|
|
|
+ |
endDateParam.setDefaultValue(DATE_FORMAT.format(new Date()));
|
|
|
|
|
|
|
+ |
rmd.addParameter(endDateParam);
|
|
|
|
|
|
|
+ |
// Configure columns
|
|
|
+ |
rmd.addColumn("Project");
|
|
|
+ |
rmd.addColumn("Workflow");
|
|
|
+ |
rmd.addColumn("Successes");
|
|
|
+ |
rmd.addColumn("Failures");
|
|
|
|
|
|
|
+ |
// Lastly, return the meta data
|
|
|
+ |
return rmd;
|
|
</pre> |
|
</pre> |
|
|
|
|
Line 43: |
|
<pre>import com.urbancode.anthill3.dashboard.*; |
|
<pre>import com.urbancode.anthill3.dashboard.*; |
|
import com.urbancode.anthill3.domain.reporting.*; |
|
import com.urbancode.anthill3.domain.reporting.*; |
- |
import com.urbancode.anthill3.domain.userprofile.*;
|
+ |
import com.urbancode.anthill3.domain.project.*;
|
|
import com.urbancode.anthill3.domain.workflow.WorkflowStatusEnum; |
|
import com.urbancode.anthill3.domain.workflow.WorkflowStatusEnum; |
|
import java.util.*; |
|
import java.util.*; |
|
|
+ |
import java.text.*;
|
|
|
|
|
|
|
+ |
class WorkflowSummary {
|
|
|
+ |
Long id = null;
|
|
|
+ |
String name = null;
|
|
|
+ |
int successes = 0;
|
|
|
+ |
int failures = 0;
|
|
|
+ |
}
|
|
|
|
|
- |
BuildLifeWorkflowCaseSummary[] summaries = DashboardFactory.getInstance().getBuildLifeWorkflowSummaries(null, null, new Integer(100));
|
+ |
ReportOutput output = new ReportOutput(metaData);
|
|
|
|
|
- |
// Get the timezone for the current user
|
+ |
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss z");
|
- |
TimeZone timeZone = UserProfileFactory.getTimeZone();
|
|
|
- |
Calendar cal = Calendar.getInstance(timeZone);
|
|
|
|
|
|
|
- |
int[] hoursCount = new int[24];
|
+ |
Date startDate = DATE_FORMAT.parse(startDateStr);
|
- |
int[] hoursCountFailed = new int[24];
|
+ |
Date endDate = DATE_FORMAT.parse(endDateStr);
|
|
|
+ |
Project[] projects = ProjectFactory.getInstance().restoreAllActive();
|
|
|
|
|
- |
for (int i = 0; i < summaries.length; i++) {
|
+ |
for (int i = 0; i < projects.length; i++) {
|
- |
if (summaries[i].getEndDate() != null) {
|
+ |
Project project = projects[i];
|
- |
Calendar tempCal = Calendar.getInstance(timeZone);
|
+ |
Map workflowNameToSummary = new HashMap();
|
- |
tempCal.setTime(summaries[i].getEndDate());
|
|
|
- |
boolean failed = (summaries[i].getStatus() == WorkflowStatusEnum.FAILED);
|
|
|
|
|
|
|
- |
if (failed) {
|
+ |
BuildLifeWorkflowCaseSummary[] summaries = DashboardFactory.getInstance().getBuildLifeWorkflowSummaries(project.getId(), startDate, endDate);
|
- |
hoursCountFailed[tempCal.get(Calendar.HOUR_OF_DAY)]++;
|
|
|
- |
}
|
|
|
- |
else {
|
|
|
- |
hoursCount[tempCal.get(Calendar.HOUR_OF_DAY)]++;
|
|
|
- |
}
|
|
|
- |
}
|
|
|
- |
}
|
|
|
|
|
|
|
- |
ReportOutput output = new ReportOutput(metaData);
|
+ |
for (int j = 0; j < summaries.length; j++) {
|
|
|
+ |
BuildLifeWorkflowCaseSummary summary = summaries[j];
|
|
|
|
|
|
|
+ |
boolean failed = (summary.getStatus() == WorkflowStatusEnum.FAILED || summary.getStatus() == WorkflowStatusEnum.ERROR);
|
|
|
+ |
|
|
|
+ |
WorkflowSummary wfSummary = null;
|
|
|
+ |
if (workflowNameToSummary.containsKey(summary.getWorkflowName())) {
|
|
|
+ |
wfSummary = (WorkflowSummary) workflowNameToSummary.get(summary.getWorkflowName());
|
|
|
+ |
}
|
|
|
+ |
else {
|
|
|
+ |
wfSummary = new WorkflowSummary();
|
|
|
+ |
wfSummary.name = summary.getWorkflowName();
|
|
|
+ |
wfSummary.id = summary.getWorkflowId();
|
|
|
+ |
workflowNameToSummary.put(summary.getWorkflowName(), wfSummary);
|
|
|
+ |
}
|
|
|
|
|
- |
ReportRow row = new ReportRow(output, "Failed");
|
+ |
if (failed) {
|
- |
row.setColumnValue("12a", hoursCountFailed[0] + "");
|
+ |
wfSummary.failures++;
|
- |
row.setColumnValue("1a", hoursCountFailed[1] + "");
|
+ |
}
|
- |
row.setColumnValue("2a", hoursCountFailed[2] + "");
|
+ |
else {
|
- |
row.setColumnValue("3a", hoursCountFailed[3] + "");
|
+ |
wfSummary.successes++;
|
- |
row.setColumnValue("4a", hoursCountFailed[4] + "");
|
+ |
}
|
- |
row.setColumnValue("5a", hoursCountFailed[5] + "");
|
|
|
- |
row.setColumnValue("6a", hoursCountFailed[6] + "");
|
|
|
- |
row.setColumnValue("7a", hoursCountFailed[7] + "");
|
|
|
- |
row.setColumnValue("8a", hoursCountFailed[8] + "");
|
|
|
- |
row.setColumnValue("9a", hoursCountFailed[9] + "");
|
|
|
- |
row.setColumnValue("10a", hoursCountFailed[10] + "");
|
|
|
- |
row.setColumnValue("11a", hoursCountFailed[11] + "");
|
|
|
- |
row.setColumnValue("12p", hoursCountFailed[12] + "");
|
|
|
- |
row.setColumnValue("1p", hoursCountFailed[13] + "");
|
|
|
- |
row.setColumnValue("2p", hoursCountFailed[14] + "");
|
|
|
- |
row.setColumnValue("3p", hoursCountFailed[15] + "");
|
|
|
- |
row.setColumnValue("4p", hoursCountFailed[16] + "");
|
|
|
- |
row.setColumnValue("5p", hoursCountFailed[17] + "");
|
|
|
- |
row.setColumnValue("6p", hoursCountFailed[18] + "");
|
|
|
- |
row.setColumnValue("7p", hoursCountFailed[19] + "");
|
|
|
- |
row.setColumnValue("8p", hoursCountFailed[20] + "");
|
|
|
- |
row.setColumnValue("9p", hoursCountFailed[21] + "");
|
|
|
- |
row.setColumnValue("10p", hoursCountFailed[22] + "");
|
|
|
- |
row.setColumnValue("11p", hoursCountFailed[23] + "");
|
|
|
- |
output.addRow(row);
|
|
|
|
|
|
|
- |
ReportRow row = new ReportRow(output, "Successful");
|
+ |
}
|
- |
row.setColumnValue("12a", hoursCount[0] + "");
|
|
|
- |
row.setColumnValue("1a", hoursCount[1] + "");
|
|
|
- |
row.setColumnValue("2a", hoursCount[2] + "");
|
|
|
- |
row.setColumnValue("3a", hoursCount[3] + "");
|
|
|
- |
row.setColumnValue("4a", hoursCount[4] + "");
|
|
|
- |
row.setColumnValue("5a", hoursCount[5] + "");
|
|
|
- |
row.setColumnValue("6a", hoursCount[6] + "");
|
|
|
- |
row.setColumnValue("7a", hoursCount[7] + "");
|
|
|
- |
row.setColumnValue("8a", hoursCount[8] + "");
|
|
|
- |
row.setColumnValue("9a", hoursCount[9] + "");
|
|
|
- |
row.setColumnValue("10a", hoursCount[10] + "");
|
|
|
- |
row.setColumnValue("11a", hoursCount[11] + "");
|
|
|
- |
row.setColumnValue("12p", hoursCount[12] + "");
|
|
|
- |
row.setColumnValue("1p", hoursCount[13] + "");
|
|
|
- |
row.setColumnValue("2p", hoursCount[14] + "");
|
|
|
- |
row.setColumnValue("3p", hoursCount[15] + "");
|
|
|
- |
row.setColumnValue("4p", hoursCount[16] + "");
|
|
|
- |
row.setColumnValue("5p", hoursCount[17] + "");
|
|
|
- |
row.setColumnValue("6p", hoursCount[18] + "");
|
|
|
- |
row.setColumnValue("7p", hoursCount[19] + "");
|
|
|
- |
row.setColumnValue("8p", hoursCount[20] + "");
|
|
|
- |
row.setColumnValue("9p", hoursCount[21] + "");
|
|
|
- |
row.setColumnValue("10p", hoursCount[22] + "");
|
|
|
- |
row.setColumnValue("11p", hoursCount[23] + "");
|
|
|
|
|
|
|
- |
output.addRow(row);
|
+ |
Iterator itr = workflowNameToSummary.values().iterator();
|
|
|
+ |
while (itr.hasNext()) {
|
|
|
+ |
WorkflowSummary summary = (WorkflowSummary) itr.next();
|
|
|
+ |
if (project.getWorkflow(summary.id).isOriginating()) {
|
|
|
+ |
ReportRow row = new ReportRow(output, project.getName() + "-" + summary.name);
|
|
|
+ |
row.setColumnValue("Project", project.getName());
|
|
|
+ |
row.setColumnValue("Workflow", summary.name);
|
|
|
+ |
row.setColumnValue("Successes", summary.successes + "");
|
|
|
+ |
row.setColumnValue("Failures", summary.failures + "");
|
|
|
|
|
- |
return output;
|
+ |
output.addRow(row);
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
+ |
|
|
|
+ |
}
|
|
|
+ |
return output;
|
|
</pre> |
|
</pre> |
|
|
|
|