Add option to do not filter by project if you are filtering by labels or criteria
FEA: ItEr77S09WBSReport
This commit is contained in:
parent
535d2e3423
commit
1f4a6e98f8
4 changed files with 44 additions and 12 deletions
|
|
@ -63,4 +63,6 @@ public interface IProjectStatusReportModel {
|
|||
|
||||
Set<Criterion> getSelectedCriteria();
|
||||
|
||||
boolean isNotFiltering();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ import org.libreplan.business.labels.entities.Label;
|
|||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.business.reports.dtos.ProjectStatusReportDTO;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
import org.libreplan.web.common.IMessagesForUser;
|
||||
import org.libreplan.web.common.Level;
|
||||
import org.libreplan.web.common.MessagesForUser;
|
||||
import org.libreplan.web.common.Util;
|
||||
import org.libreplan.web.common.components.bandboxsearch.BandboxSearch;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
|
@ -63,10 +66,16 @@ public class ProjectStatusReportController extends LibrePlanReportController {
|
|||
|
||||
private Listbox listboxCriteria;
|
||||
|
||||
private IMessagesForUser messagesForUser;
|
||||
|
||||
private Component messagesContainer;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
comp.setAttribute("controller", this);
|
||||
|
||||
messagesForUser = new MessagesForUser(messagesContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -85,14 +94,18 @@ public class ProjectStatusReportController extends LibrePlanReportController {
|
|||
|
||||
return new JRBeanCollectionDataSource(dtos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showReport(JasperreportComponent jasperreport) {
|
||||
final Order order = getSelectedOrder();
|
||||
if (order == null) {
|
||||
throw new WrongValueException(bandboxSelectOrder,
|
||||
_("Please, select a project"));
|
||||
if (order == null && projectStatusReportModel.isNotFiltering()) {
|
||||
messagesForUser
|
||||
.showMessage(
|
||||
Level.ERROR,
|
||||
_("You should filter the report by project, labels or criteria"));
|
||||
} else {
|
||||
super.showReport(jasperreport);
|
||||
}
|
||||
super.showReport(jasperreport);
|
||||
}
|
||||
|
||||
private Order getSelectedOrder() {
|
||||
|
|
@ -108,7 +121,10 @@ public class ProjectStatusReportController extends LibrePlanReportController {
|
|||
Map<String, Object> result = super.getParameters();
|
||||
|
||||
Order order = getSelectedOrder();
|
||||
result.put("project", order.getName() + " (" + order.getCode() + ")");
|
||||
if (order != null) {
|
||||
result.put("project", order.getName() + " (" + order.getCode()
|
||||
+ ")");
|
||||
}
|
||||
|
||||
ProjectStatusReportDTO totalDTO = projectStatusReportModel
|
||||
.getTotalDTO();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import java.util.Set;
|
|||
import org.libreplan.business.labels.daos.ILabelDAO;
|
||||
import org.libreplan.business.labels.entities.Label;
|
||||
import org.libreplan.business.orders.daos.IOrderDAO;
|
||||
import org.libreplan.business.orders.daos.IOrderElementDAO;
|
||||
import org.libreplan.business.orders.entities.Order;
|
||||
import org.libreplan.business.orders.entities.OrderElement;
|
||||
import org.libreplan.business.planner.entities.IMoneyCostCalculator;
|
||||
|
|
@ -64,6 +65,9 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
@Autowired
|
||||
private ICriterionDAO criterionDAO;
|
||||
|
||||
@Autowired
|
||||
private IOrderElementDAO orderElementDAO;
|
||||
|
||||
@Autowired
|
||||
private IScenarioManager scenarioManager;
|
||||
|
||||
|
|
@ -90,16 +94,23 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<ProjectStatusReportDTO> getProjectStatusReportDTOs(Order order) {
|
||||
orderDAO.reattach(order);
|
||||
List<OrderElement> orderElements;
|
||||
if (order != null) {
|
||||
orderDAO.reattach(order);
|
||||
order.useSchedulingDataFor(scenarioManager.getCurrent());
|
||||
orderElements = order.getAllChildren();
|
||||
} else {
|
||||
orderElements = new ArrayList<OrderElement>();
|
||||
for (Order each : orderDAO.findAll()) {
|
||||
each.useSchedulingDataFor(scenarioManager.getCurrent());
|
||||
orderElements.addAll(each.getAllChildren());
|
||||
}
|
||||
}
|
||||
|
||||
order.useSchedulingDataFor(scenarioManager.getCurrent());
|
||||
|
||||
List<ProjectStatusReportDTO> dtos = new ArrayList<ProjectStatusReportDTO>();
|
||||
|
||||
List<OrderElement> orderElements = order.getAllChildren();
|
||||
orderElements = filterBySelectedLabels(orderElements);
|
||||
orderElements = filterBySelectedCriteria(orderElements);
|
||||
|
||||
List<ProjectStatusReportDTO> dtos = new ArrayList<ProjectStatusReportDTO>();
|
||||
for (OrderElement child : orderElements) {
|
||||
dtos.add(calculateDTO(child));
|
||||
}
|
||||
|
|
@ -222,7 +233,8 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isNotFiltering() {
|
||||
@Override
|
||||
public boolean isNotFiltering() {
|
||||
return isNotFilteringByLabels() && isNotFilteringByCriteria();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@
|
|||
title="${i18n:_('Project Status Report')}"
|
||||
border="normal" >
|
||||
|
||||
<vbox id="messagesContainer" />
|
||||
|
||||
<!-- Select project -->
|
||||
<panel title="${i18n:_('Project')}"
|
||||
border="normal"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue