Remove tasks that are not really initial from the initial and end tasks

FEA: ItEr74S04BugFixing
This commit is contained in:
Óscar González Fernández 2011-05-15 21:05:59 +02:00
parent f1f9074647
commit f82b20bbd1
3 changed files with 48 additions and 3 deletions

View file

@ -1930,6 +1930,23 @@ public class GanttDiagramGraph<V, D extends IDependency<V>> implements
return result;
}
public boolean hasVisibleIncomingDependencies(V task) {
return isSomeVisible(graph.incomingEdgesOf(task));
}
public boolean hasVisibleOutcomingDependencies(V task) {
return isSomeVisible(graph.outgoingEdgesOf(task));
}
private boolean isSomeVisible(Set<D> dependencies) {
for (D each : dependencies) {
if (adapter.isVisible(each)) {
return true;
}
}
return false;
}
public List<V> getLatestTasks() {
List<V> tasks = new ArrayList<V>();

View file

@ -121,13 +121,37 @@ public class CriticalPathCalculator<T, D extends IDependency<T>> {
}
private InitialNode<T, D> createBeginningOfProjectNode() {
return new InitialNode<T, D>(new HashSet<T>(removeContainers(graph
return new InitialNode<T, D>(
removeWithVisibleIncomingDependencies(removeContainers(graph
.getInitialTasks())));
}
private Set<T> removeWithVisibleIncomingDependencies(Collection<T> tasks) {
Set<T> result = new HashSet<T>();
for (T each : tasks) {
if (!graph.hasVisibleIncomingDependencies(each)) {
result.add(each);
}
}
return result;
}
private LastNode<T, D> createEndOfProjectNode() {
return new LastNode<T, D>(new HashSet<T>(removeContainers(graph
.getLatestTasks())));
return new LastNode<T, D>(
removeWithVisibleOutcomingDependencies(removeContainers(graph
.getLatestTasks())));
}
private Set<T> removeWithVisibleOutcomingDependencies(
Collection<T> removeContainers) {
Set<T> result = new HashSet<T>();
for (T each : removeContainers) {
if (!graph.hasVisibleOutcomingDependencies(each)) {
result.add(each);
}
}
return result;
}
private Map<T, Node<T, D>> createGraphNodes() {

View file

@ -42,6 +42,10 @@ public interface ICriticalPathCalculable<T> {
List<T> getLatestTasks();
boolean hasVisibleIncomingDependencies(T task);
boolean hasVisibleOutcomingDependencies(T task);
Set<T> getIncomingTasksFor(T task);
Set<T> getOutgoingTasksFor(T task);