/*
 * This file is part of LibrePlan
 *
 * Copyright (C) 2011 Igalia, S.L.
 *
 * 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/>.
 */

package org.libreplan.business.planner.entities.visitors;

import java.util.HashMap;
import java.util.Map;

import org.libreplan.business.planner.entities.Task;
import org.libreplan.business.planner.entities.TaskElement;
import org.libreplan.business.planner.entities.TaskGroup;
import org.libreplan.business.planner.entities.TaskStatusEnum;
import org.libreplan.business.util.Visitor;

public class AccumulateTasksStatusVisitor extends Visitor {

    private Map<TaskStatusEnum, Integer> taskStatusData;

    public AccumulateTasksStatusVisitor() {
        this.taskStatusData = new HashMap<TaskStatusEnum, Integer>();
    }

    public Map<TaskStatusEnum, Integer> getTaskStatusData() {
        return taskStatusData;
    }

    public void visit(Task task) {
        TaskStatusEnum status = task.getTaskStatus();
        Integer currentValue = getTaskStatusData().get(status);
        taskStatusData.put(status, currentValue++);
    }

    public void visit(TaskGroup taskGroup) {
        for(TaskElement each: taskGroup.getAllChildren()) {
            each.acceptVisitor(this);
        }
    }

}

@@ -819,20 +819,20 @@
 va.util.
-Hash
+Enum
 Map;%0Aimp
@@ -1331,12 +1331,12 @@
 new 
-Hash
+Enum
 Map%3C
@@ -1360,18 +1360,171 @@
 nteger%3E(
-);
+TaskStatusEnum.class);%0A        for(TaskStatusEnum status: TaskStatusEnum.values()) %7B%0A            this.taskStatusData.put(status, new Integer(0));%0A        %7D
 %0A    %7D%0A%0A

Initialize Map before traversing task tree.