Bug #1546: Force recalculation of critical path progresses on saving project

They were only calculated when you visited the dashboard perspective. Now they
are calculated always when you save the project.

FEA: ItEr77S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2012-11-23 13:33:05 +01:00
parent 7ab8e7f07c
commit 2bdcb409d9
3 changed files with 12 additions and 2 deletions

View file

@ -70,6 +70,7 @@ import org.libreplan.business.planner.entities.consolidations.CalculatedConsolid
import org.libreplan.business.requirements.entities.CriterionRequirement;
import org.libreplan.business.resources.daos.ICriterionDAO;
import org.libreplan.business.resources.daos.IResourceDAO;
import org.libreplan.business.resources.daos.IResourcesSearcher;
import org.libreplan.business.resources.entities.Criterion;
import org.libreplan.business.resources.entities.CriterionSatisfaction;
import org.libreplan.business.resources.entities.IAssignmentsOnResourceCalculator;
@ -87,6 +88,7 @@ import org.libreplan.business.users.entities.UserOrderAuthorization;
import org.libreplan.web.UserUtil;
import org.libreplan.web.calendars.BaseCalendarModel;
import org.libreplan.web.planner.TaskElementAdapter;
import org.libreplan.web.planner.tabs.CriticalPathBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
@ -179,6 +181,9 @@ public class PlanningStateCreator {
@Autowired
private IMoneyCostCalculator moneyCostCalculator;
@Autowired
private IResourcesSearcher resourcesSearcher;
void synchronizeWithSchedule(Order order, IOptionalPersistence persistence) {
List<TaskSourceSynchronization> synchronizationsNeeded = order
.calculateSynchronizationsNeeded();
@ -1115,6 +1120,10 @@ public class PlanningStateCreator {
savedOrderState = order.getState();
}
public List<TaskElement> getCriticalPath() {
return CriticalPathBuilder.criticalPathFor(this, resourcesSearcher);
}
}
public interface IAllocationCriteria {

View file

@ -384,6 +384,7 @@ public class SaveCommandBuilder {
// the deletes on cascade a new root task is fetched causing a
// NonUniqueObjectException later
taskElementDAO.reattach(rootTask);
rootTask.updateCriticalPathProgress(state.getCriticalPath());
}
orderDAO.save(order);

View file

@ -95,7 +95,7 @@ public class CriticalPathBuilder {
});
}
private List<TaskElement> criticalPathFor(PlanningState state,
public static List<TaskElement> criticalPathFor(PlanningState state,
IResourcesSearcher resourcesSearcher) {
final Order order = state.getOrder();
final Scenario currentScenario = state.getCurrentScenario();
@ -110,7 +110,7 @@ public class CriticalPathBuilder {
return criticalPathCalculator.calculateCriticalPath(graph);
}
private LocalDate asLocalDate(Date date) {
private static LocalDate asLocalDate(Date date) {
return date != null ? LocalDate.fromDateFields(date) : null;
}