[Bug #604] Review movements of milestones with dependencies.
FEA: ItEr60S04ValidacionEProbasFuncionaisItEr59S04
This commit is contained in:
parent
c1364d4ccc
commit
c0593e2cec
7 changed files with 79 additions and 14 deletions
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents the start constraints of the TaskElement which are leafs
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
package org.navalplanner.business.planner.entities;
|
||||
|
||||
public interface ITaskLeafConstraint {
|
||||
|
||||
TaskStartConstraint getStartConstraint();
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ import org.navalplanner.business.util.deepcopy.AfterCopy;
|
|||
/**
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public class Task extends TaskElement {
|
||||
public class Task extends TaskElement implements ITaskLeafConstraint {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(Task.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import org.navalplanner.business.scenarios.entities.Scenario;
|
|||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
* @author Javier Moran Rua <jmoran@igalia.com>
|
||||
*/
|
||||
public class TaskMilestone extends TaskElement {
|
||||
public class TaskMilestone extends TaskElement implements ITaskLeafConstraint {
|
||||
|
||||
public static TaskMilestone create(Date initialDate) {
|
||||
Validate.notNull(initialDate);
|
||||
|
|
@ -47,6 +47,8 @@ public class TaskMilestone extends TaskElement {
|
|||
|
||||
private CalculatedValue calculatedValue = CalculatedValue.END_DATE;
|
||||
|
||||
private TaskStartConstraint startConstraint = new TaskStartConstraint();
|
||||
|
||||
/**
|
||||
* Constructor for hibernate. Do not use!
|
||||
*/
|
||||
|
|
@ -142,4 +144,15 @@ public class TaskMilestone extends TaskElement {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void explicityMoved(Date date) {
|
||||
getStartConstraint().explicityMovedTo(date);
|
||||
}
|
||||
|
||||
public TaskStartConstraint getStartConstraint() {
|
||||
if (startConstraint == null) {
|
||||
startConstraint = new TaskStartConstraint();
|
||||
}
|
||||
return startConstraint;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -96,6 +96,15 @@
|
|||
|
||||
<joined-subclass name="TaskMilestone">
|
||||
<key column="TASK_ELEMENT_ID"></key>
|
||||
|
||||
<component name="startConstraint">
|
||||
<property name="startConstraintType">
|
||||
<type name="org.hibernate.type.EnumType">
|
||||
<param name="enumClass">org.navalplanner.business.planner.entities.StartConstraintType</param>
|
||||
</type>
|
||||
</property>
|
||||
<property name="constraintDate" />
|
||||
</component>
|
||||
</joined-subclass>
|
||||
|
||||
</class>
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ import org.navalplanner.business.planner.daos.ITaskElementDAO;
|
|||
import org.navalplanner.business.planner.entities.Dependency;
|
||||
import org.navalplanner.business.planner.entities.DerivedAllocation;
|
||||
import org.navalplanner.business.planner.entities.GenericResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.ITaskLeafConstraint;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.StartConstraintType;
|
||||
|
|
@ -89,8 +90,8 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
|
||||
public static List<Constraint<Date>> getStartConstraintsFor(
|
||||
TaskElement taskElement) {
|
||||
if (taskElement instanceof Task) {
|
||||
Task task = (Task) taskElement;
|
||||
if (taskElement instanceof ITaskLeafConstraint) {
|
||||
ITaskLeafConstraint task = (ITaskLeafConstraint) taskElement;
|
||||
TaskStartConstraint startConstraint = task.getStartConstraint();
|
||||
final StartConstraintType constraintType = startConstraint
|
||||
.getStartConstraintType();
|
||||
|
|
@ -108,9 +109,6 @@ public class TaskElementAdapter implements ITaskElementAdapter {
|
|||
default:
|
||||
throw new RuntimeException("can't handle " + constraintType);
|
||||
}
|
||||
} else if (taskElement.isMilestone()) {
|
||||
return Collections.singletonList(DateConstraint
|
||||
.biggerOrEqualThan(taskElement.getStartDate()));
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.joda.time.LocalDate;
|
|||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.planner.entities.AggregateOfResourceAllocations;
|
||||
import org.navalplanner.business.planner.entities.CalculatedValue;
|
||||
import org.navalplanner.business.planner.entities.ITaskLeafConstraint;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
|
|
@ -418,11 +419,16 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
public Date getStartConstraintDate() {
|
||||
if ((taskElement == null) || (!isTask())) {
|
||||
if ((taskElement == null) || (!isTaskLeafConstraint())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ((Task) taskElement).getStartConstraint().getConstraintDate();
|
||||
return ((ITaskLeafConstraint) taskElement).getStartConstraint()
|
||||
.getConstraintDate();
|
||||
}
|
||||
|
||||
private boolean isTaskLeafConstraint() {
|
||||
return (taskElement != null && taskElement instanceof ITaskLeafConstraint);
|
||||
}
|
||||
|
||||
public void setStartConstraintDate(Date date) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.util.Date;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.planner.entities.ITaskLeafConstraint;
|
||||
import org.navalplanner.business.planner.entities.StartConstraintType;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
|
|
@ -245,7 +246,11 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
showResourceAllocationTypeRow(task);
|
||||
} else {
|
||||
hideDurationRow();
|
||||
hideStartConstraintRow();
|
||||
if (currentTaskElement instanceof ITaskLeafConstraint) {
|
||||
showStartConstraintRow((ITaskLeafConstraint) currentTaskElement);
|
||||
} else {
|
||||
hideStartConstraintRow();
|
||||
}
|
||||
hideResourceAllocationTypeRow();
|
||||
}
|
||||
hours.setValue(currentTaskElement.getWorkHours());
|
||||
|
|
@ -264,7 +269,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
startConstraint.setVisible(false);
|
||||
}
|
||||
|
||||
private void showStartConstraintRow(Task task) {
|
||||
private void showStartConstraintRow(ITaskLeafConstraint task) {
|
||||
startConstraint.setVisible(true);
|
||||
StartConstraintType type = task.getStartConstraint()
|
||||
.getStartConstraintType();
|
||||
|
|
@ -286,13 +291,13 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
|
||||
private void constraintTypeChoosen(WebStartConstraintType constraint) {
|
||||
startConstraintDate.setVisible(constraint.isAssociatedDateRequired());
|
||||
TaskStartConstraint taskStartConstraint = currentTaskElementAsTask()
|
||||
TaskStartConstraint taskStartConstraint = currentTaskElementAsTaskLeafConstraint()
|
||||
.getStartConstraint();
|
||||
startConstraintDate.setValue(taskStartConstraint.getConstraintDate());
|
||||
}
|
||||
|
||||
private boolean saveConstraintChanges() {
|
||||
TaskStartConstraint taskConstraint = currentTaskElementAsTask()
|
||||
TaskStartConstraint taskConstraint = currentTaskElementAsTaskLeafConstraint()
|
||||
.getStartConstraint();
|
||||
WebStartConstraintType type = (WebStartConstraintType) startConstraintTypes
|
||||
.getSelectedItemApi().getValue();
|
||||
|
|
@ -309,6 +314,10 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
private ITaskLeafConstraint currentTaskElementAsTaskLeafConstraint() {
|
||||
return (ITaskLeafConstraint) currentTaskElement;
|
||||
}
|
||||
|
||||
private Task currentTaskElementAsTask() {
|
||||
return (Task) currentTaskElement;
|
||||
}
|
||||
|
|
@ -388,7 +397,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
|
||||
public void accept() {
|
||||
boolean ok = true;
|
||||
if (currentTaskElement instanceof Task) {
|
||||
if (currentTaskElement instanceof ITaskLeafConstraint) {
|
||||
ok = saveConstraintChanges();
|
||||
}
|
||||
if (ok) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue