Bug #1474: Fix issue adding a new option Any to the report filers

FEA: ItEr76S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2012-07-03 13:21:02 +02:00
parent 4daabb9d71
commit f4c6684cae
4 changed files with 30 additions and 11 deletions

View file

@ -2,6 +2,7 @@
* This file is part of LibrePlan
*
* Copyright (C) 2011 - ComtecSF, S.L.
* Copyright (C) 2012 - Igalia, S.L.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -30,5 +31,5 @@ import org.libreplan.business.workreports.entities.WorkReport;
*
*/
public enum LabelFilterType {
WORK_REPORT, ORDER_ELEMENT, BOTH;
WORK_REPORT, ORDER_ELEMENT, BOTH, ANY;
}

View file

@ -3,7 +3,7 @@
*
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
* Copyright (C) 2010-2011 Igalia, S.L.
* Copyright (C) 2010-2012 Igalia, S.L.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -161,17 +161,28 @@ public class ResourceDAO extends IntegrationEntityDAO<Resource> implements
// Set labels
if (labels != null && !labels.isEmpty()) {
if (labelFilterType.equals(LabelFilterType.ORDER_ELEMENT)) {
switch (labelFilterType) {
case ORDER_ELEMENT:
strQuery += " AND ( EXISTS (FROM wrl.orderElement.labels as etq WHERE etq IN (:labels)) "
+ "OR EXISTS (FROM wrl.workReport.orderElement.labels as etqwr WHERE etqwr IN (:labels)) ) ";
} else if (labelFilterType.equals(LabelFilterType.WORK_REPORT)) {
break;
case WORK_REPORT:
strQuery += " AND ( EXISTS (FROM wrl.labels as etq WHERE etq IN (:labels)) "
+ "OR EXISTS (FROM wrl.workReport.labels as etqwr WHERE etqwr IN (:labels)) ) ";
} else {
break;
case BOTH:
strQuery += " AND ( EXISTS (FROM wrl.labels as etq WHERE etq IN (:labels)) "
+ "OR EXISTS (FROM wrl.workReport.labels as etqwr WHERE etqwr IN (:labels)) ) "
+ "AND ( EXISTS (FROM wrl.orderElement.labels as etq WHERE etq IN (:labels)) "
+ "OR EXISTS (FROM wrl.workReport.orderElement.labels as etqwr WHERE etqwr IN (:labels)) ) ";
break;
case ANY:
default:
strQuery += " AND ( ( EXISTS (FROM wrl.labels as etq WHERE etq IN (:labels)) "
+ "OR EXISTS (FROM wrl.workReport.labels as etqwr WHERE etqwr IN (:labels)) ) "
+ "OR ( EXISTS (FROM wrl.orderElement.labels as etq WHERE etq IN (:labels)) "
+ "OR EXISTS (FROM wrl.workReport.orderElement.labels as etqwr WHERE etqwr IN (:labels)) ) ) ";
break;
}
}

View file

@ -3,7 +3,7 @@
*
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
* Desenvolvemento Tecnolóxico de Galicia
* Copyright (C) 2010-2011 Igalia, S.L.
* Copyright (C) 2010-2012 Igalia, S.L.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@ -25,7 +25,6 @@ import static org.libreplan.web.I18nHelper._;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -88,6 +87,8 @@ public class HoursWorkedPerWorkerController extends LibrePlanReportController {
private Radio filterByOrderElements;
private Radio filterByBoth;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
@ -114,11 +115,16 @@ public class HoursWorkedPerWorkerController extends LibrePlanReportController {
}
private LabelFilterType getSelectedFilterLabels() {
if (filterByWorkReports.isChecked())
if (filterByWorkReports.isChecked()) {
return LabelFilterType.WORK_REPORT;
if (filterByOrderElements.isChecked())
}
if (filterByOrderElements.isChecked()) {
return LabelFilterType.ORDER_ELEMENT;
return LabelFilterType.BOTH;
}
if (filterByBoth.isChecked()) {
return LabelFilterType.BOTH;
}
return LabelFilterType.ANY;
}
private List<Resource> getSelectedResources() {

View file

@ -113,7 +113,8 @@
<label value="${i18n:_('Apply filter to')}:"/>
<radio id="filterByWorkReports" label="${i18n:_('Timesheets')}" />
<radio id="filterByOrderElements" label="${i18n:_('Tasks')}" />
<radio id="filterByBoth" label="${i18n:_('Both')}" checked="true" />
<radio id="filterByBoth" label="${i18n:_('Both')}" />
<radio id="filterByAny" label="${i18n:_('Any')}" checked="true" />
</radiogroup>
</hbox>
<separator spacing="10px"/>