From 2eb7cca7688fbbe22b5068163a0e06528785db75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Sun, 23 May 2010 13:44:18 +0200 Subject: [PATCH] ItEr58S14RecalculosConexionEscenariosItEr57S15: Avoid the creation of spurious domain dependencies. When creating a Dependency is automatically added to the tasks. This was causing the invisible dependencies to be created. --- .../web/common/TemplateModel.java | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/TemplateModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/TemplateModel.java index f5cdf3ffc..7a6b7c2f5 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/common/TemplateModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/common/TemplateModel.java @@ -89,10 +89,14 @@ public class TemplateModel implements ITemplateModel { private static class DependencyWithVisibility { public static DependencyWithVisibility createInvisible( - Dependency dependency) { - DependencyWithVisibility result = new DependencyWithVisibility( - dependency, false); - return result; + TaskElement source, TaskElement destination, DependencyType type) { + return new DependencyWithVisibility(source, destination, type, + false); + } + + public static DependencyWithVisibility existent(Dependency each) { + return new DependencyWithVisibility(each.getOrigin(), each + .getDestination(), toGraphicalType(each.getType()), true); } public static List> getStartConstraintsGiven( @@ -119,13 +123,22 @@ public class TemplateModel implements ITemplateModel { return result; } - private final Dependency dependency; + private final TaskElement source; + + private final TaskElement destination; + + private final DependencyType type; private final boolean visible; - public DependencyWithVisibility(Dependency dependency, boolean visible) { - Validate.notNull(dependency); - this.dependency = dependency; + private DependencyWithVisibility(TaskElement source, + TaskElement destination, DependencyType type, boolean visible) { + Validate.notNull(source); + Validate.notNull(destination); + Validate.notNull(type); + this.source = source; + this.destination = destination; + this.type = type; this.visible = visible; } @@ -134,15 +147,18 @@ public class TemplateModel implements ITemplateModel { } public TaskElement getSource() { - return dependency.getOrigin(); + return source; } public TaskElement getDestination() { - return dependency.getDestination(); + return destination; } public DependencyType getGraphicalType() { - Type domainDependencyType = dependency.getType(); + return type; + } + + private static DependencyType toGraphicalType(Type domainDependencyType) { switch (domainDependencyType) { case END_START: return DependencyType.END_START; @@ -165,19 +181,6 @@ public class TemplateModel implements ITemplateModel { } - private Dependency.Type convert(DependencyType type) { - switch (type) { - case END_START: - return Dependency.Type.END_START; - case END_END: - return Dependency.Type.END_END; - case START_START: - return Dependency.Type.START_START; - default: - throw new RuntimeException("can't handle " + type); - } - } - private static IDatesInterceptor asIntercerptor( final IDependenciesEnforcerHook hook) { return new IDatesInterceptor() { @@ -210,10 +213,8 @@ public class TemplateModel implements ITemplateModel { @Override public DependencyWithVisibility createInvisibleDependency( TaskElement origin, TaskElement destination, DependencyType type) { - Dependency transientDependency = Dependency.create(origin, - destination, convert(type)); - return DependencyWithVisibility - .createInvisible(transientDependency); + return DependencyWithVisibility.createInvisible(origin, + destination, type); } @Override @@ -523,8 +524,8 @@ public class TemplateModel implements ITemplateModel { TaskSource taskSource = order.getTaskSource(); graph.addTopLevel(taskSource.getTask()); for (Dependency each : getAllDependencies(order)) { - graph.addWithoutEnforcingConstraints(new DependencyWithVisibility( - each, true)); + graph.addWithoutEnforcingConstraints(DependencyWithVisibility + .existent(each)); } }