Line 1: |
|
|
+ |
This report has a row for each change in a build life as well as who requested the build and the date and project workflow names. This report has to be used in conjunction with a report template such as the [[HTML Template]].
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
''Meta-Data Script:''
|
|
|
|
|
|
|
+ |
<pre>import com.urbancode.anthill3.domain.project.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.reporting.*;
|
|
|
+ |
import java.text.*;
|
|
|
+ |
import java.util.*;
|
|
|
|
|
|
|
+ |
ReportMetaData rmd = new ReportMetaData();
|
|
|
|
|
|
|
+ |
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss z");
|
|
|
|
|
|
|
+ |
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);
|
|
|
|
|
|
|
+ |
Project[] projects = ProjectFactory.getInstance().restoreAllActive();
|
|
|
+ |
String[] labels = new String[projects.length + 1];
|
|
|
+ |
String[] values = new String[projects.length + 1];
|
|
|
|
|
|
|
+ |
labels[0] = "All";
|
|
|
+ |
values[0] = "all";
|
|
|
|
|
|
|
+ |
for (int i = 1; i < projects.length + 1; i++) {
|
|
|
+ |
labels[i] = projects[i - 1].getName();
|
|
|
+ |
values[i] = projects[i - 1].getId().toString();
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
SelectParamMetaData projectParams = new SelectParamMetaData();
|
|
|
|
|
|
|
+ |
projectParams.setLabels(labels);
|
|
|
+ |
projectParams.setValues(values);
|
|
|
+ |
projectParams.setName("projectId");
|
|
|
+ |
projectParams.setLabel("Project");
|
|
|
+ |
projectParams.setDescription("The Project To Report On Or All");
|
|
|
+ |
projectParams.setRequired(true);
|
|
|
|
|
|
|
+ |
rmd.addParameter(projectParams);
|
|
|
|
|
|
|
+ |
// Configure columns
|
|
|
+ |
rmd.addColumn("Build Life Id");
|
|
|
+ |
rmd.addColumn("Project");
|
|
|
+ |
rmd.addColumn("Workflow");
|
|
|
+ |
rmd.addColumn("Requestor");
|
|
|
+ |
rmd.addColumn("Changer");
|
|
|
+ |
rmd.addColumn("Date");
|
|
|
|
|
|
|
+ |
// Lastly, return the meta data
|
|
|
+ |
return rmd;
|
|
|
+ |
</pre>
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
''Report Script:''
|
|
|
|
|
|
|
+ |
<pre>import com.urbancode.anthill3.dashboard.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.reporting.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.project.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.workflow.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.buildlife.*;
|
|
|
+ |
import com.urbancode.anthill3.domain.workflow.WorkflowStatusEnum;
|
|
|
+ |
import java.util.*;
|
|
|
+ |
import java.text.*;
|
|
|
|
|
|
|
+ |
BuildLifeWorkflowCaseSummary[] retrieveBuildLifeWorkflowCaseSummary() {
|
|
|
+ |
BuildLifeWorkflowCaseSummary[] result = null;
|
|
|
|
|
|
|
+ |
SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss z");
|
|
|
|
|
|
|
+ |
Date startDate = DATE_FORMAT.parse(startDateStr);
|
|
|
+ |
Date endDate = DATE_FORMAT.parse(endDateStr);
|
|
|
|
|
|
|
+ |
if (projectId.equals("all")) {
|
|
|
+ |
result = DashboardFactory.getInstance().getBuildLifeWorkflowSummaries(null, startDate, endDate);
|
|
|
+ |
}
|
|
|
+ |
else {
|
|
|
+ |
result = DashboardFactory.getInstance().getBuildLifeWorkflowSummaries(new Long(projectId), startDate, endDate);
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
return result;
|
|
|
+ |
}
|
|
|
+ |
void createBuildLifeRow(BuildLife buildLife,
|
|
|
+ |
BuildLifeWorkflowCaseSummary summary,
|
|
|
+ |
ReportOutput output,
|
|
|
+ |
String changer) {
|
|
|
+ |
ReportRow row = new ReportRow(output, "Build Life");
|
|
|
+ |
row.setColumnValue("Build Life Id", summary.getBuildLifeId().toString());
|
|
|
+ |
row.setColumnValue("Project", summary.getProjectName());
|
|
|
+ |
row.setColumnValue("Workflow", summary.getWorkflowName());
|
|
|
+ |
row.setColumnValue("Requestor", buildLife.getOriginatingWorkflow().getRequest().getRequesterName());
|
|
|
+ |
row.setColumnValue("Changer", changer);
|
|
|
+ |
row.setColumnValue("Date", summary.getStartDate() != null ? buildLife.getStartDate().toString() : "");
|
|
|
|
|
|
|
+ |
output.addRow(row);
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
void createBuildLifeRows(BuildLife buildLife,
|
|
|
+ |
BuildLifeWorkflowCaseSummary summary,
|
|
|
+ |
ReportOutput output) {
|
|
|
+ |
BuildLifeChangeSet[] changeSets = buildLife.getChangeSetArray();
|
|
|
+ |
Set changersSet = new HashSet();
|
|
|
|
|
|
|
+ |
for (int i = 0; i < changeSets.length; i++) {
|
|
|
+ |
BuildLifeChangeSet changeSet = changeSets[i];
|
|
|
+ |
|
|
|
+ |
changersSet.add(changeSet.getChangeSet().getUsername());
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
Iterator itr = changersSet.iterator();
|
|
|
+ |
while (itr.hasNext()) {
|
|
|
+ |
String changer = (String) itr.next();
|
|
|
+ |
createBuildLifeRow(buildLife, summary, output, changer);
|
|
|
+ |
}
|
|
|
+ |
|
|
|
+ |
if (changersSet == null || changersSet.size() ==0) {
|
|
|
+ |
createBuildLifeRow(buildLife, summary, output, "-");
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
ReportOutput output = new ReportOutput(metaData);
|
|
|
+ |
BuildLifeWorkflowCaseSummary[] summaries = retrieveBuildLifeWorkflowCaseSummary();
|
|
|
|
|
|
|
+ |
for (int i = 0; i < summaries.length; i++) {
|
|
|
+ |
BuildLifeWorkflowCaseSummary summary = summaries[i];
|
|
|
|
|
|
|
+ |
boolean failed = (summary.getStatus() == WorkflowStatusEnum.FAILED || summary.getStatus() == WorkflowStatusEnum.ERROR);
|
|
|
+ |
|
|
|
+ |
if (!failed) {
|
|
|
+ |
Workflow workflow = WorkflowFactory.getInstance().restore(summary.getWorkflowId());
|
|
|
+ |
if (workflow.isOriginating()) {
|
|
|
+ |
BuildLife buildLife = BuildLifeFactory.getInstance().restore(summary.getBuildLifeId());
|
|
|
+ |
createBuildLifeRows(buildLife, summary, output);
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
+ |
}
|
|
|
|
|
|
|
+ |
return output;
|
|
|
+ |
</pre>
|
|
|
|
|
|
|
+ |
----
|
|
|
|
|
|
|
+ |
'''Related Content'''
|
|
|
|
|
|
|
+ |
[[AnthillPro Template Reports]]<br/>
|
|
|
+ |
[[Report Templates]]
|