Version Differences for Durations

Line 1:
    + This is based on a count of how many results you want back. It returns only successes and can be tailored to one or all projects. It provides the start and end dates as well as a duration. This report has to be used in conjunction with a report template such as the [[Bar Chart Template]].  
       
    + ----  
       
    + ''Meta-Data Script:''  
       
    + <pre>import com.urbancode.anthill3.domain.project.*;  
    + import com.urbancode.anthill3.domain.reporting.*;  
       
    + ReportMetaData rmd = new ReportMetaData();  
       
    + 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);  
       
    + labels = new String[]{"All", "Originating", "Secondary"};  
    + values = new String[]{"all", "orig", "sec"};  
       
    + SelectParamMetaData workflowParams = new SelectParamMetaData();  
       
    + workflowParams.setLabels(labels);  
    + workflowParams.setValues(values);  
    + workflowParams.setName("workflowType");  
    + workflowParams.setLabel("Workflow Type");  
    + workflowParams.setDescription("Whether to Report On All Workflows Or just Originating/Secondary");  
    + workflowParams.setRequired(true);  
       
    + rmd.addParameter(workflowParams);  
       
    + TextParamMetaData countParam = new TextParamMetaData();  
       
    + countParam.setName("count");  
    + countParam.setLabel("Count");  
    + countParam.setDescription("The Number of Summaries to Pull In");  
    + countParam.setRequired(true);  
       
    + countParam.setDefaultValue("50");  
       
    + rmd.addParameter(countParam);  
       
    + // Configure columns  
    + rmd.addColumn("Project");  
    + rmd.addColumn("Workflow");  
    + rmd.addColumn("Start Date");  
    + rmd.addColumn("End Date");  
    + rmd.addColumn("Duration");  
    + rmd.addColumn("Is Secondary");  
       
    + // Lastly, return the meta data  
    + return rmd;  
    + </pre>  
       
    + ----  
       
    + ''Context Script:''  
       
    + <pre>import com.urbancode.anthill3.dashboard.*;  
    + import com.urbancode.anthill3.domain.reporting.*;  
    + import com.urbancode.anthill3.domain.workflow.*;  
       
    + class SummaryHolder {  
    + BuildLifeWorkflowCaseSummary summary = null;  
    + boolean isOriginating = false;  
    + }  
       
    + BuildLifeWorkflowCaseSummary[] retrieveBuildLifeSummaries(int start) {  
    + BuildLifeWorkflowCaseSummary[] result = null;  
       
    + if (projectId.equals("all")) {  
    + result = DashboardFactory.getInstance().getBuildLifeWorkflowSummaries(null, new Integer(start), new Integer(count));  
    + }  
    + else {  
    + result = DashboardFactory.getInstance().getBuildLifeWorkflowSummaries(new Long(projectId), new Integer(start), new Integer(count));  
    + }  
       
    + return result;  
    + }  
       
    + Integer retrieveTotalSummariesCount() {  
    + Integer result = null;  
       
    + if (projectId.equals("all")) {  
    + result = DashboardFactory.getInstance().getBuildLifeWorkflowSummaryCount(null);  
    + }  
    + else {  
    + result = DashboardFactory.getInstance().getBuildLifeWorkflowSummaryCount(new Long(projectId));  
    + }  
       
    + return result;  
    + }  
       
    + ReportOutput output = new ReportOutput(metaData);  
       
    + List summaryList = new ArrayList();  
    + int countInt = new Integer(count).intValue();  
    + int maxInt = retrieveTotalSummariesCount().intValue();  
    + int start = 0;  
       
    + BuildLifeWorkflowCaseSummary[] summaries = null;  
       
    + while (summaryList.size() < countInt.intValue() &&  
    + start + countInt < maxInt.intValue()) {  
    + summaries = retrieveBuildLifeSummaries(start);  
    + start += countInt;  
       
    + if (summaries == null || summaries.length == 0) {  
    + break;  
    + }  
       
    + for (int i = 0; i < summaries.length && summaryList.size < countInt.intValue(); i++) {  
    + boolean failed = (summaries[i].getStatus() == WorkflowStatusEnum.FAILED  
    + || summaries[i].getStatus() == WorkflowStatusEnum.ERROR);  
    + if (!failed) {  
    + Workflow workflow = WorkflowFactory.getInstance().restore(summaries[i].getWorkflowId());  
    + if (workflow.isOriginating() && (workflowType.equals("orig") || workflowType.equals("all"))) {  
    + SummaryHolder holder = new SummaryHolder();  
    + holder.summary = summaries[i];  
    + holder.isOriginating = true;  
    + summaryList.add(holder);  
    + }  
    + else if (!workflow.isOriginating() && (workflowType.equals("sec") || workflowType.equals("all"))) {  
    + SummaryHolder holder = new SummaryHolder();  
    + holder.summary = summaries[i];  
    + holder.isOriginating = false;  
    + summaryList.add(holder);  
    + }  
    + }  
    + }  
    + }  
       
    + for (int i =0; i < summaryList.size(); i++) {  
    + SummaryHolder holder = (SummaryHolder) summaryList.get(i);  
    + BuildLifeWorkflowCaseSummary summary = holder.summary;  
       
    + ReportRow row = new ReportRow(output, "Summary");  
    + row.setColumnValue("Project", summary.getProjectName());  
    + row.setColumnValue("Workflow", summary.getWorkflowName());  
    + row.setColumnValue("Start Date", summary.getStartDate() != null ? summary.getStartDate().toString() : "");  
    + row.setColumnValue("End Date", summary.getEndDate() != null ? summary.getEndDate().toString() : "");  
    + row.setColumnValue("Duration", summary.getDuration());  
    + row.setColumnValue("Is Secondary", holder.isOriginating ? "false" : "true");  
    + output.addRow(row);  
    + }  
       
    + return output;  
    + </pre>  
       
    + ----  
       
    + '''Related Content'''  
       
    + [[AnthillPro Template Reports]]<br/>  
    + [[Report Templates]]