Add method for retrieving the end constraints for a task
FEA: ItEr64OTS03PlanificacionHaciaAtras
This commit is contained in:
parent
1bd4cd7ae6
commit
0fb61dd2ac
9 changed files with 76 additions and 12 deletions
|
|
@ -187,6 +187,11 @@ public class DefaultFundamentalProperties implements ITaskFundamentalProperties
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Constraint<GanttDate>> getEndConstraints() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveTo(GanttDate date) {
|
||||
setBeginDate(date);
|
||||
|
|
|
|||
|
|
@ -105,6 +105,8 @@ public class GanttDiagramGraph<V, D extends IDependency<V>> implements
|
|||
|
||||
List<Constraint<GanttDate>> getStartConstraintsFor(V task);
|
||||
|
||||
List<Constraint<GanttDate>> getEndConstraintsFor(V task);
|
||||
|
||||
V getSource(D dependency);
|
||||
|
||||
V getDestination(D dependency);
|
||||
|
|
@ -221,6 +223,11 @@ public class GanttDiagramGraph<V, D extends IDependency<V>> implements
|
|||
return task.getStartConstraints();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Constraint<GanttDate>> getEndConstraintsFor(Task task) {
|
||||
return task.getEndConstraints();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GanttDate getSmallestBeginDateFromChildrenFor(Task container) {
|
||||
return ((TaskContainer) container)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,9 @@ public interface ITaskFundamentalProperties {
|
|||
|
||||
public String getResourcesText();
|
||||
|
||||
List<Constraint<GanttDate>> getStartConstraints();
|
||||
public List<Constraint<GanttDate>> getStartConstraints();
|
||||
|
||||
public List<Constraint<GanttDate>> getEndConstraints();
|
||||
|
||||
public void moveTo(GanttDate date);
|
||||
|
||||
|
|
|
|||
|
|
@ -118,6 +118,11 @@ public abstract class Task implements ITaskFundamentalProperties {
|
|||
.getStartConstraints());
|
||||
}
|
||||
|
||||
public List<Constraint<GanttDate>> getEndConstraints() {
|
||||
return violationNotificator.withListener(fundamentalProperties
|
||||
.getEndConstraints());
|
||||
}
|
||||
|
||||
public abstract boolean isLeaf();
|
||||
|
||||
public abstract boolean isContainer();
|
||||
|
|
|
|||
|
|
@ -36,6 +36,11 @@ public class ConstraintOnComparableValues<T extends Comparable<T>> extends
|
|||
return instantiate(ComparisonType.BIGGER_OR_EQUAL_THAN, value);
|
||||
}
|
||||
|
||||
public static <T extends Comparable<T>> Constraint<T> lessOrEqualThan(
|
||||
T value) {
|
||||
return instantiate(ComparisonType.LESS_OR_EQUAL_THAN, value);
|
||||
}
|
||||
|
||||
public static <T extends Comparable<T>> Constraint<T> equalTo(T value) {
|
||||
return instantiate(ComparisonType.EQUAL_TO, value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,9 +215,12 @@ public class TemplateModel implements ITemplateModel {
|
|||
|
||||
private final Scenario scenario;
|
||||
|
||||
private Adapter(Scenario scenario) {
|
||||
private LocalDate deadline;
|
||||
|
||||
private Adapter(Scenario scenario, LocalDate deadline) {
|
||||
Validate.notNull(scenario);
|
||||
this.scenario = scenario;
|
||||
this.deadline = deadline;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -293,6 +296,11 @@ public class TemplateModel implements ITemplateModel {
|
|||
return TaskElementAdapter.getStartConstraintsFor(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Constraint<GanttDate>> getEndConstraintsFor(TaskElement task) {
|
||||
return TaskElementAdapter.getEndConstraintsFor(task, deadline);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Constraint<GanttDate>> getStartConstraintsGiven(
|
||||
Set<DependencyWithVisibility> withDependencies) {
|
||||
|
|
@ -540,7 +548,8 @@ public class TemplateModel implements ITemplateModel {
|
|||
|
||||
private void doReassignationsOn(Order order, Scenario from, Scenario to) {
|
||||
copyAssignments(order, from, to);
|
||||
installDependenciesEnforcer(order, new Adapter(to));
|
||||
installDependenciesEnforcer(order,
|
||||
new Adapter(to, LocalDate.fromDateFields(order.getDeadline())));
|
||||
doReassignations(order, to);
|
||||
doTheSaving(order);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.web.planner;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.business.scenarios.entities.Scenario;
|
||||
import org.zkoss.ganttz.adapters.IAdapterToTaskFundamentalProperties;
|
||||
|
|
@ -32,6 +33,8 @@ public interface ITaskElementAdapter extends IAdapterToTaskFundamentalProperties
|
|||
|
||||
void useScenario(Scenario scenario);
|
||||
|
||||
void setDeadline(LocalDate deadline);
|
||||
|
||||
void setPreventCalculateResourcesText(boolean preventCalculateResourcesText);
|
||||
|
||||
boolean isPreventCalculateResourcesText();
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import static org.navalplanner.business.workingday.EffortDuration.zero;
|
|||
import static org.navalplanner.web.I18nHelper._;
|
||||
import static org.zkoss.ganttz.data.constraint.ConstraintOnComparableValues.biggerOrEqualThan;
|
||||
import static org.zkoss.ganttz.data.constraint.ConstraintOnComparableValues.equalTo;
|
||||
import static org.zkoss.ganttz.data.constraint.ConstraintOnComparableValues.lessOrEqualThan;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
|
|
@ -134,16 +135,29 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
return Collections
|
||||
.singletonList(biggerOrEqualThan(toGantt(startConstraint
|
||||
.getConstraintDate())));
|
||||
case AS_LATE_AS_POSSIBLE:
|
||||
return Collections.emptyList();
|
||||
case FINISH_NOT_LATER_THAN:
|
||||
return Collections.emptyList();
|
||||
default:
|
||||
throw new RuntimeException("can't handle " + constraintType);
|
||||
}
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public static List<Constraint<GanttDate>> getEndConstraintsFor(
|
||||
TaskElement taskElement, LocalDate deadline) {
|
||||
if (taskElement instanceof ITaskLeafConstraint) {
|
||||
ITaskLeafConstraint task = (ITaskLeafConstraint) taskElement;
|
||||
TaskStartConstraint endConstraint = task.getStartConstraint();
|
||||
StartConstraintType type = endConstraint.getStartConstraintType();
|
||||
switch (type) {
|
||||
case AS_LATE_AS_POSSIBLE:
|
||||
if (deadline != null) {
|
||||
return Collections
|
||||
.singletonList(lessOrEqualThan(toGantt(deadline)));
|
||||
}
|
||||
case FINISH_NOT_LATER_THAN:
|
||||
GanttDate date = toGantt(endConstraint.getConstraintDate());
|
||||
return Collections.singletonList(lessOrEqualThan(date));
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
@ -166,12 +180,19 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
|
||||
private Scenario scenario;
|
||||
|
||||
private LocalDate deadline;
|
||||
|
||||
|
||||
@Override
|
||||
public void useScenario(Scenario scenario) {
|
||||
this.scenario = scenario;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeadline(LocalDate deadline) {
|
||||
this.deadline = deadline;
|
||||
}
|
||||
|
||||
public TaskElementAdapter() {
|
||||
}
|
||||
|
||||
|
|
@ -824,6 +845,11 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
return getStartConstraintsFor(this.taskElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Constraint<GanttDate>> getEndConstraints() {
|
||||
return getEndConstraintsFor(this.taskElement, deadline);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Constraint<GanttDate>> getCurrentLengthConstraint() {
|
||||
if (taskElement instanceof Task) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ import org.joda.time.LocalDate;
|
|||
import org.navalplanner.business.common.IAdHocTransactionService;
|
||||
import org.navalplanner.business.common.IOnTransaction;
|
||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||
import org.navalplanner.business.common.entities.ProgressType;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.orders.daos.IOrderDAO;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
|
|
@ -1037,6 +1036,9 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
taskElementAdapter = getTaskElementAdapter();
|
||||
taskElementAdapter.useScenario(currentScenario);
|
||||
planningState = createPlanningStateFor(planner, orderReloaded);
|
||||
taskElementAdapter
|
||||
.setDeadline(orderReloaded.getDeadline() != null ? LocalDate
|
||||
.fromDateFields(orderReloaded.getDeadline()) : null);
|
||||
PlannerConfiguration<TaskElement> result = new PlannerConfiguration<TaskElement>(
|
||||
taskElementAdapter,
|
||||
new TaskElementNavigator(), planningState.getInitial());
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue