ItEr48S04ValidacionEProbasFuncionaisItEr47S04 : [Bug #297] Fixes the filter that applies to the company view mode and adds a new predicate
This commit is contained in:
parent
a3ab6e818f
commit
b8444d6c46
6 changed files with 105 additions and 24 deletions
|
|
@ -183,21 +183,21 @@ public class OrderPredicate implements IPredicate {
|
|||
return order.getCustomerReference().equals(filterCustomerReference);
|
||||
}
|
||||
|
||||
private boolean acceptFiltersDates(Order order) {
|
||||
protected boolean acceptFiltersDates(Order order) {
|
||||
// Check if exist work report items into interval between the start date
|
||||
// and finish date.
|
||||
return (acceptStartDate(order.getInitDate()) && (acceptFinishDate(order
|
||||
.getDeadline())));
|
||||
}
|
||||
|
||||
private boolean acceptStartDate(Date initDate) {
|
||||
protected boolean acceptStartDate(Date initDate) {
|
||||
if ((initDate == null) && (startDate == null)) {
|
||||
return true;
|
||||
}
|
||||
return isInTheRangeFilterDates(initDate);
|
||||
}
|
||||
|
||||
private boolean acceptFinishDate(Date deadLine) {
|
||||
protected boolean acceptFinishDate(Date deadLine) {
|
||||
if ((deadLine == null) && (finishDate == null)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
package org.navalplanner.web.planner;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.planner.entities.TaskGroup;
|
||||
import org.navalplanner.web.common.components.finders.FilterPair;
|
||||
import org.navalplanner.web.orders.IPredicate;
|
||||
import org.navalplanner.web.orders.OrderPredicate;
|
||||
|
||||
/**
|
||||
* Checks if {@link Order}, the start date and finish date from associated
|
||||
* {@link Task} matches attributes
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
public class CompanyPredicate extends OrderPredicate implements IPredicate {
|
||||
|
||||
public CompanyPredicate(List<FilterPair> filters, Date startDate,
|
||||
Date finishDate, Boolean includeOrderElements) {
|
||||
super(filters, startDate, finishDate, includeOrderElements);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean acceptFiltersDates(Order order) {
|
||||
TaskGroup associatedTaskElement = order.getAssociatedTaskElement();
|
||||
return (this.acceptStartDate(associatedTaskElement.getStartDate()) && (acceptFinishDate(associatedTaskElement
|
||||
.getEndDate())));
|
||||
}
|
||||
}
|
||||
|
|
@ -140,7 +140,9 @@ public abstract class EarnedValueChartFiller extends ChartFiller {
|
|||
.get(EarnedValueType.ACWP);
|
||||
|
||||
for (LocalDate day : bcwp.keySet()) {
|
||||
cv.put(day, bcwp.get(day).subtract(acwp.get(day)));
|
||||
if ((bcwp.get(day) != null) && (acwp.get(day) != null)) {
|
||||
cv.put(day, bcwp.get(day).subtract(acwp.get(day)));
|
||||
}
|
||||
}
|
||||
|
||||
indicators.put(EarnedValueType.CV, cv);
|
||||
|
|
@ -155,7 +157,9 @@ public abstract class EarnedValueChartFiller extends ChartFiller {
|
|||
.get(EarnedValueType.BCWS);
|
||||
|
||||
for (LocalDate day : bcwp.keySet()) {
|
||||
sv.put(day, bcwp.get(day).subtract(bcws.get(day)));
|
||||
if ((bcwp.get(day) != null) && (bcws.get(day) != null)) {
|
||||
sv.put(day, bcwp.get(day).subtract(bcws.get(day)));
|
||||
}
|
||||
}
|
||||
|
||||
indicators.put(EarnedValueType.SV, sv);
|
||||
|
|
@ -239,8 +243,12 @@ public abstract class EarnedValueChartFiller extends ChartFiller {
|
|||
|
||||
for (LocalDate day : bcwp.keySet()) {
|
||||
BigDecimal value = BigDecimal.ZERO;
|
||||
if (acwp.get(day).compareTo(BigDecimal.ZERO) != 0) {
|
||||
value = bcwp.get(day).divide(acwp.get(day), RoundingMode.DOWN);
|
||||
if ((acwp.get(day) != null)
|
||||
&& (acwp.get(day).compareTo(BigDecimal.ZERO) != 0)) {
|
||||
if ((bcwp.get(day) != null) && (acwp.get(day) != null)) {
|
||||
value = bcwp.get(day).divide(acwp.get(day),
|
||||
RoundingMode.DOWN);
|
||||
}
|
||||
}
|
||||
cpi.put(day, value);
|
||||
}
|
||||
|
|
@ -258,7 +266,8 @@ public abstract class EarnedValueChartFiller extends ChartFiller {
|
|||
|
||||
for (LocalDate day : bcwp.keySet()) {
|
||||
BigDecimal value = BigDecimal.ZERO;
|
||||
if (bcws.get(day).compareTo(BigDecimal.ZERO) != 0) {
|
||||
if ((bcws.get(day) != null)
|
||||
&& (bcws.get(day).compareTo(BigDecimal.ZERO) != 0)) {
|
||||
value = bcwp.get(day).divide(bcws.get(day), RoundingMode.DOWN);
|
||||
}
|
||||
spi.put(day, value);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
package org.navalplanner.web.planner.company;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -30,7 +32,8 @@ import org.apache.commons.lang.Validate;
|
|||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.common.components.bandboxsearch.BandboxMultipleSearch;
|
||||
import org.navalplanner.web.common.components.finders.FilterPair;
|
||||
import org.navalplanner.web.orders.OrderPredicate;
|
||||
import org.navalplanner.web.orders.IPredicate;
|
||||
import org.navalplanner.web.planner.CompanyPredicate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
|
@ -42,8 +45,10 @@ import org.zkoss.ganttz.util.OnZKDesktopRegistry;
|
|||
import org.zkoss.ganttz.util.script.IScriptsRegister;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.WrongValueException;
|
||||
import org.zkoss.zk.ui.util.Composer;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
import org.zkoss.zul.Constraint;
|
||||
import org.zkoss.zul.Datebox;
|
||||
import org.zkoss.zul.Vbox;
|
||||
|
||||
|
|
@ -103,7 +108,7 @@ public class CompanyPlanningController implements Composer{
|
|||
Component filterComponent = Executions.createComponents(
|
||||
"/orders/_orderFilter.zul", orderFilter,
|
||||
new HashMap<String, String>());
|
||||
filterComponent.setVariable("controller", this, true);
|
||||
filterComponent.setVariable("orderFilterController", this, true);
|
||||
filterStartDate = (Datebox) filterComponent
|
||||
.getFellow("filterStartDate");
|
||||
filterFinishDate = (Datebox) filterComponent
|
||||
|
|
@ -140,11 +145,49 @@ public class CompanyPlanningController implements Composer{
|
|||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations to filter the tasks by multiple filters
|
||||
*/
|
||||
|
||||
public Constraint checkConstraintFinishDate() {
|
||||
return new Constraint() {
|
||||
@Override
|
||||
public void validate(Component comp, Object value)
|
||||
throws WrongValueException {
|
||||
Date finishDate = (Date) value;
|
||||
if ((finishDate != null)
|
||||
&& (filterStartDate.getValue() != null)
|
||||
&& (finishDate.compareTo(filterStartDate.getValue()) < 0)) {
|
||||
filterFinishDate.setValue(null);
|
||||
throw new WrongValueException(comp,
|
||||
_("must be greater than start date"));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public Constraint checkConstraintStartDate() {
|
||||
return new Constraint() {
|
||||
@Override
|
||||
public void validate(Component comp, Object value)
|
||||
throws WrongValueException {
|
||||
Date startDate = (Date) value;
|
||||
if ((startDate != null)
|
||||
&& (filterFinishDate.getValue() != null)
|
||||
&& (startDate.compareTo(filterFinishDate.getValue()) > 0)) {
|
||||
filterStartDate.setValue(null);
|
||||
throw new WrongValueException(comp,
|
||||
_("must be lower than finish date"));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void onApplyFilter() {
|
||||
filterByPredicate(createPredicate());
|
||||
}
|
||||
|
||||
private OrderPredicate createPredicate() {
|
||||
private IPredicate createPredicate() {
|
||||
List<FilterPair> listFilters = (List<FilterPair>) bdFilters
|
||||
.getSelectedElements();
|
||||
Date startDate = filterStartDate.getValue();
|
||||
|
|
@ -154,11 +197,11 @@ public class CompanyPlanningController implements Composer{
|
|||
if (listFilters.isEmpty() && startDate == null && finishDate == null) {
|
||||
return null;
|
||||
}
|
||||
return new OrderPredicate(listFilters, startDate, finishDate,
|
||||
return new CompanyPredicate(listFilters, startDate, finishDate,
|
||||
includeOrderElements);
|
||||
}
|
||||
|
||||
private void filterByPredicate(OrderPredicate predicate) {
|
||||
private void filterByPredicate(IPredicate predicate) {
|
||||
// Recalculate predicate
|
||||
model.setConfigurationToPlanner(planner, additional,
|
||||
doubleClickCommand, predicate);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ import org.navalplanner.business.users.daos.IUserDAO;
|
|||
import org.navalplanner.business.users.entities.User;
|
||||
import org.navalplanner.business.workreports.daos.IWorkReportLineDAO;
|
||||
import org.navalplanner.business.workreports.entities.WorkReportLine;
|
||||
import org.navalplanner.web.orders.OrderPredicate;
|
||||
import org.navalplanner.web.orders.IPredicate;
|
||||
import org.navalplanner.web.planner.ITaskElementAdapter;
|
||||
import org.navalplanner.web.planner.chart.Chart;
|
||||
import org.navalplanner.web.planner.chart.ChartFiller;
|
||||
|
|
@ -180,7 +180,7 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
public void setConfigurationToPlanner(Planner planner,
|
||||
Collection<ICommandOnTask<TaskElement>> additional,
|
||||
ICommandOnTask<TaskElement> doubleClickCommand,
|
||||
OrderPredicate predicate) {
|
||||
IPredicate predicate) {
|
||||
PlannerConfiguration<TaskElement> configuration = createConfiguration(predicate);
|
||||
|
||||
Tabbox chartComponent = new Tabbox();
|
||||
|
|
@ -195,10 +195,12 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
addAdditionalCommands(additional, configuration);
|
||||
addPrintSupport(configuration);
|
||||
disableSomeFeatures(configuration);
|
||||
|
||||
ZoomLevel defaultZoomLevel = OrderPlanningModel
|
||||
.calculateDefaultLevel(configuration);
|
||||
OrderPlanningModel.configureInitialZoomLevelFor(planner,
|
||||
defaultZoomLevel);
|
||||
|
||||
configuration.setSecondLevelModificators(new BankHolidaysMarker());
|
||||
planner.setConfiguration(configuration);
|
||||
Timeplot chartLoadTimeplot = new Timeplot();
|
||||
|
|
@ -511,14 +513,11 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
}
|
||||
|
||||
private PlannerConfiguration<TaskElement> createConfiguration(
|
||||
OrderPredicate predicate) {
|
||||
IPredicate predicate) {
|
||||
ITaskElementAdapter taskElementAdapter = getTaskElementAdapter();
|
||||
List<TaskElement> toShow;
|
||||
if (predicate != null) {
|
||||
toShow = sortByStartDate(retainOnlyTopLevel(predicate));
|
||||
} else {
|
||||
toShow = sortByStartDate(retainOnlyTopLevel(null));
|
||||
}
|
||||
toShow = sortByStartDate(retainOnlyTopLevel(predicate));
|
||||
|
||||
forceLoadOfDataAssociatedTo(toShow);
|
||||
forceLoadOfDependenciesCollections(toShow);
|
||||
forceLoadOfWorkingHours(toShow);
|
||||
|
|
@ -550,7 +549,7 @@ public abstract class CompanyPlanningModel implements ICompanyPlanningModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
private List<TaskElement> retainOnlyTopLevel(OrderPredicate predicate) {
|
||||
private List<TaskElement> retainOnlyTopLevel(IPredicate predicate) {
|
||||
List<TaskElement> result = new ArrayList<TaskElement>();
|
||||
User user;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ package org.navalplanner.web.planner.company;
|
|||
import java.util.Collection;
|
||||
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.orders.OrderPredicate;
|
||||
import org.navalplanner.web.orders.IPredicate;
|
||||
import org.zkoss.ganttz.Planner;
|
||||
import org.zkoss.ganttz.extensions.ICommandOnTask;
|
||||
|
||||
|
|
@ -44,6 +44,6 @@ public interface ICompanyPlanningModel {
|
|||
public void setConfigurationToPlanner(Planner planner,
|
||||
Collection<ICommandOnTask<TaskElement>> additional,
|
||||
ICommandOnTask<TaskElement> doubleClickCommand,
|
||||
OrderPredicate predicate);
|
||||
IPredicate predicate);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue