Initialize the start filtering date with the task start date and the end filtering date with the task end date.

It has been improved the performance so that the search of the resources and their
load ratios calculation is done from this moment on when the advanced search tab is made visible. This is
the moment when the task start date and task end date are available (not
sooner).

FEA: ItEr77S10ResourceAllocationLoadInformation
This commit is contained in:
Javier Moran Rua 2012-10-13 17:36:38 +02:00 committed by Manuel Rego Casasnovas
parent c650fcb013
commit 8f5622acf1
5 changed files with 88 additions and 49 deletions

View file

@ -21,6 +21,7 @@
package org.libreplan.web.common.components;
import java.util.Date;
import java.util.List;
import org.libreplan.business.resources.daos.IResourcesSearcher;
@ -36,6 +37,7 @@ import org.zkoss.zul.Radiogroup;
/**
* @author Diego Pino García <dpino@igalia.com>
* @author Javier Moran Rua <jmoran@igalia.com>
*
* ZK macro component for searching {@link Worker} entities
*
@ -148,6 +150,7 @@ public class NewAllocationSelector extends AllocationSelector {
} // AllocationType
@Override
public NewAllocationSelectorController getController() {
if (selectorController == null) {
selectorController = new NewAllocationSelectorController(behaviour);
@ -164,4 +167,12 @@ public class NewAllocationSelector extends AllocationSelector {
this.behaviour = ResourceAllocationBehaviour.valueOf(behaviour);
}
public void setEndFilteringDate(Date d) {
selectorController.setEndFilteringDate(d);
}
public void setStartFilteringDate(Date d) {
selectorController.setStartFilteringDate(d);
}
}

View file

@ -38,6 +38,7 @@ import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
*
* @author Manuel Rego Casasnovas <mrego@igalia.com>
* @author Diego Pino García <dpino@igalia.com>
* @author Javier Moran Rua <jmoran@igalia.com>
*/
public interface IResourceAllocationModel extends INewAllocationsAdder {
@ -84,4 +85,6 @@ public interface IResourceAllocationModel extends INewAllocationsAdder {
Date getTaskEnd();
}
Date getTaskStart();
}

View file

@ -82,8 +82,10 @@ import org.zkoss.zul.Window;
/**
* Controller for {@link ResourceAllocation} view.
*
* @author Manuel Rego Casasnovas <mrego@igalia.com>
* @author Diego Pino Garcia <dpino@igalia.com>
* @author Javier Moran Rua <jmoran@igalia.com>
*/
@org.springframework.stereotype.Component("resourceAllocationController")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@ -162,6 +164,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
assignedEffortComponent.setWidth("80px");
}
@Override
public ResourceAllocationController getController() {
return this;
}
@ -228,12 +231,14 @@ public class ResourceAllocationController extends GenericForwardComposer {
return allocationConfiguration.getTaskWorkableDays();
}
private Label getTaskStart() {
return allocationConfiguration.getTaskStart();
public Label getTaskStart() {
return (allocationConfiguration != null) ? allocationConfiguration
.getTaskStart() : null;
}
private Label getTaskEnd() {
return allocationConfiguration.getTaskEnd();
public Label getTaskEnd() {
return (allocationConfiguration != null) ? allocationConfiguration
.getTaskEnd() : null;
}
private Radiogroup getCalculationTypeSelector() {
@ -317,8 +322,15 @@ public class ResourceAllocationController extends GenericForwardComposer {
}
public void goToAdvancedSearch() {
newAllocationSelector.setStartFilteringDate(resourceAllocationModel
.getTaskStart());
newAllocationSelector.setEndFilteringDate(resourceAllocationModel
.getTaskEnd());
applyButton.setVisible(false);
workerSearchTab.setSelected(true);
// The initial search and ratio load calculations is raised
// on going to advanced search
newAllocationSelector.clearAll();
}
/**
@ -679,4 +691,5 @@ public class ResourceAllocationController extends GenericForwardComposer {
|| formBinder.isTaskUpdatedFromTimesheets();
}
}

View file

@ -54,13 +54,14 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.zkoss.ganttz.data.GanttDate;
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
/**
* Model for UI operations related to {@link Task}
*
* @author Manuel Rego Casasnovas <mrego@igalia.com>
* @author Diego Pino García <dpino@igalia.com>
* @author Javier Moran Rua <jmoran@igalia.com>
*/
@Service
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@ -325,4 +326,17 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
return task.getEndDate();
}
@Override
public Date getTaskStart() {
Date result;
if (task == null) {
result = null;
} else {
result = task.getStartDate();
}
return result;
}
}

View file

@ -22,8 +22,6 @@
package org.libreplan.web.resources.search;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -72,7 +70,6 @@ import org.zkoss.zul.Treeitem;
import org.zkoss.zul.TreeitemRenderer;
import org.zkoss.zul.Treerow;
/**
* Controller for searching for {@link Resource}.
*
@ -101,6 +98,7 @@ public class NewAllocationSelectorController extends
private ResourceAllocationBehaviour behaviour;
public NewAllocationSelectorController(ResourceAllocationBehaviour behaviour) {
this.behaviour = behaviour;
}
@ -113,23 +111,11 @@ public class NewAllocationSelectorController extends
}
private void initializeComponents() {
initializeResourceLoadRatiosFilterDates();
initializeCriteriaTree();
initializeListboxResources();
initializeAllocationTypeSelector();
}
private void initializeResourceLoadRatiosFilterDates() {
try {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
startDateLoadRatiosDatebox.setValue(sdf.parse("01/09/2012"));
endDateLoadRatiosDatebox.setValue(sdf.parse("01/10/2012"));
} catch (ParseException e) {
System.out.println("Parse exception");
throw new RuntimeException();
}
}
private void initializeCriteriaTree() {
// Initialize criteria tree
if (criterionsTree != null) {
@ -152,14 +138,14 @@ public class NewAllocationSelectorController extends
listBoxResources.addEventListener(Events.ON_SELECT,
new EventListener() {
@Override
public void onEvent(Event event) {
if (isGenericType()) {
returnToSpecificDueToResourceSelection();
}
showSelectedAllocations();
}
});
@Override
public void onEvent(Event event) {
if (isGenericType()) {
returnToSpecificDueToResourceSelection();
}
showSelectedAllocations();
}
});
listBoxResources.setMultiple(behaviour.allowMultipleSelection());
listBoxResources.setItemRenderer(getListitemRenderer());
}
@ -183,7 +169,7 @@ public class NewAllocationSelectorController extends
}
});
// Feed with values
for (AllocationType each: behaviour.allocationTypes()) {
for (AllocationType each : behaviour.allocationTypes()) {
allocationTypeSelector.appendChild(radio(each));
}
doInitialSelection();
@ -224,18 +210,21 @@ public class NewAllocationSelectorController extends
private List<ResourceWithItsLoadRatios> getAllResources() {
List<? extends Resource> listResources = query().byResourceType(
getType()).execute();
List<ResourceWithItsLoadRatios> result = new ArrayList<ResourceWithItsLoadRatios>();
return addLoadRatiosCalculations(listResources);
}
// The search is only done in case that the endFilteringDate and
// startFilteringDate are initialized. This happens when the
// user does the advanced search visible by clicking on the
// AdvancedSearch button
if ((startDateLoadRatiosDatebox.getValue() != null)
&& (endDateLoadRatiosDatebox.getValue() != null)) {
public Date getStartDateForLoadRatiosCalc() {
return new Date();
}
List<? extends Resource> listResources = query().byResourceType(
getType()).execute();
public Date getEndDateForLoadRatiosCalc() {
return new Date();
result = addLoadRatiosCalculations(listResources);
}
return result;
}
private List<ResourceWithItsLoadRatios> addLoadRatiosCalculations(
@ -245,9 +234,12 @@ public class NewAllocationSelectorController extends
for (Resource each : listResources) {
ILoadRatiosDataType t = resourceLoadRatiosCalculator
.calculateLoadRatios(each, new LocalDate(
2012, 8, 1), new LocalDate(2012, 9, 30), scenarioManager
.getCurrent());
.calculateLoadRatios(each, LocalDate
.fromDateFields(startDateLoadRatiosDatebox
.getValue()),
LocalDate.fromDateFields(endDateLoadRatiosDatebox
.getValue()),
scenarioManager.getCurrent());
result.add(new ResourceWithItsLoadRatios(each, t));
}
@ -317,8 +309,8 @@ public class NewAllocationSelectorController extends
@SuppressWarnings("unchecked")
private void clearSelection(Listbox listBox) {
Set<Listitem> selectedItems = new HashSet<Listitem>(listBox
.getSelectedItems());
Set<Listitem> selectedItems = new HashSet<Listitem>(
listBox.getSelectedItems());
for (Listitem each : selectedItems) {
listBox.removeItemFromSelection(each);
}
@ -326,7 +318,8 @@ public class NewAllocationSelectorController extends
@SuppressWarnings("unchecked")
private void clearSelection(Tree tree) {
Set<Treeitem> selectedItems = new HashSet<Treeitem>(tree.getSelectedItems());
Set<Treeitem> selectedItems = new HashSet<Treeitem>(
tree.getSelectedItems());
for (Treeitem each : selectedItems) {
tree.removeItemFromSelection(each);
}
@ -349,9 +342,7 @@ public class NewAllocationSelectorController extends
*/
private void searchResources(String name, List<Criterion> criterions) {
final List<? extends Resource> resources = query().byName(name)
.byCriteria(criterions)
.byResourceType(getType())
.execute();
.byCriteria(criterions).byResourceType(getType()).execute();
refreshListBoxResources(addLoadRatiosCalculations(resources));
}
@ -585,7 +576,7 @@ public class NewAllocationSelectorController extends
BigDecimal overtime = dataToRender.getRatios().getOvertimeRatio();
cellOvertime.appendChild(new Label(overtime.toString()));
item.appendChild(cellOvertime);
}
}
}
public CriterionRenderer getCriterionRenderer() {
@ -646,4 +637,11 @@ public class NewAllocationSelectorController extends
return listBoxResources.isMultiple();
}
public void setEndFilteringDate(Date d) {
endDateLoadRatiosDatebox.setValue(d);
}
public void setStartFilteringDate(Date d) {
startDateLoadRatiosDatebox.setValue(d);
}
}