Add information about filter in project status report header if no project is selected

FEA: ItEr77S09WBSReport
This commit is contained in:
Manuel Rego Casasnovas 2012-10-23 14:33:48 +02:00
parent 8f49d3b00a
commit 33eb2ddcd0
3 changed files with 54 additions and 1 deletions

View file

@ -18,6 +18,7 @@
</style>
<parameter name="logo" class="java.lang.String"/>
<parameter name="project" class="java.lang.String"/>
<parameter name="filter" class="java.lang.String"/>
<parameter name="estimatedHours" class="java.lang.String"/>
<parameter name="plannedHours" class="java.lang.String"/>
<parameter name="imputedHours" class="java.lang.String"/>
@ -72,6 +73,24 @@
</textElement>
<textFieldExpression><![CDATA[$P{project}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="a3d6bdd8-5c6f-462b-aebd-033e0f89211d" x="0" y="15" width="60" height="12">
<printWhenExpression><![CDATA[$P{project} == null]]></printWhenExpression>
</reportElement>
<textElement>
<font size="10"/>
</textElement>
<textFieldExpression><![CDATA[$R{filter}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement uuid="24abd130-337a-4a7c-aa87-7f8e063487a3" x="60" y="15" width="562" height="12">
<printWhenExpression><![CDATA[$P{project} == null]]></printWhenExpression>
</reportElement>
<textElement textAlignment="Left" verticalAlignment="Middle">
<font size="10" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$P{filter}]]></textFieldExpression>
</textField>
<textField>
<reportElement uuid="9048c4a2-964c-4863-a30e-36b520a9d54b" x="0" y="28" width="100" height="12"/>
<textElement>

View file

@ -1,6 +1,7 @@
# Locale for projectStatusReport.jrxml
title = Project status report
project = Project:
filter = Filter:
project_estimated_hours = Estimated hours:
project_planned_hours = Planned hours:
project_imputed_hours = Imputed hours:
@ -16,4 +17,4 @@ project_total_cost = Total cost:
budget = Budget
hours_cost = Hours cost
expenses_cost = Expenses cost
total_cost = Total cost
total_cost = Total cost

View file

@ -21,6 +21,7 @@ package org.libreplan.web.reports;
import static org.libreplan.web.I18nHelper._;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -29,6 +30,7 @@ import net.sf.jasperreports.engine.JRDataSource;
import net.sf.jasperreports.engine.JREmptyDataSource;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;
import org.codehaus.plexus.util.StringUtils;
import org.libreplan.business.labels.entities.Label;
import org.libreplan.business.orders.entities.Order;
import org.libreplan.business.reports.dtos.ProjectStatusReportDTO;
@ -124,6 +126,8 @@ public class ProjectStatusReportController extends LibrePlanReportController {
if (order != null) {
result.put("project", order.getName() + " (" + order.getCode()
+ ")");
} else {
result.put("filter", getFilterSummary());
}
ProjectStatusReportDTO totalDTO = projectStatusReportModel
@ -142,6 +146,35 @@ public class ProjectStatusReportController extends LibrePlanReportController {
return result;
}
private String getFilterSummary() {
String filter = "";
Set<Label> labels = projectStatusReportModel.getSelectedLabels();
if (!labels.isEmpty()) {
List<String> labelNames = new ArrayList<String>();
for (Label label : labels) {
labelNames.add(label.getName());
}
filter += _("Labels") + ": "
+ StringUtils.join(labelNames.toArray(), ", ");
}
Set<Criterion> criteria = projectStatusReportModel.getSelectedCriteria();
if (!criteria.isEmpty()){
List<String> criterionNames = new ArrayList<String>();
for (Criterion criterion : criteria) {
criterionNames.add(criterion.getName());
}
if (!filter.isEmpty()) {
filter += ". ";
}
filter += _("Criteria") + ": "
+ StringUtils.join(criterionNames.toArray(), ", ");
}
return filter;
}
public List<Label> getAllLabels() {
return projectStatusReportModel.getAllLabels();
}