// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.tasktrees.treeimpl; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstanceList; import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo; import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; /** *
* this is the default implementation of the interface {@link ITaskModel}. It * does not do anything fancy except implementing the interface. *
* * @author Patrick Harms */ class TaskModel implements ITaskModel { /** ** default serial version UID *
*/ private static final long serialVersionUID = 1L; /** ** the user sessions belonging to the model *
*/ private List* the tasks contained in the user session belonging to the model as well as statistical infos * about them *
*/ private Map* initializes the task model with the user sessions out of which the tasks are extracted *
* * @param userSessions as described */ TaskModel(List* internal convenience method to recursively add the tasks of a task instance and its * children to the task model *
* * @param taskInstance the task instance of which the tasks shall be added */ private void addTasksToMap(ITaskInstance taskInstance) { addTaskToMap(taskInstance.getTask()); if (taskInstance instanceof ITaskInstanceList) { for (ITaskInstance child : (ITaskInstanceList) taskInstance) { addTasksToMap(child); } } } /** ** internal convenience method to build the task model during initialization *
*/ private void addTaskToMap(ITask task) { TaskInfo taskInfo = taskMap.get(task); if (taskInfo == null) { taskInfo = new TaskInfo(task); taskMap.put(task, taskInfo); } taskInfo.increaseCount(); /*if (task instanceof IStructuringTemporalRelationship) { for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) { addTaskToMap(child); } } else if (task instanceof IMarkingTemporalRelationship) { addTaskToMap(((IMarkingTemporalRelationship) task).getMarkedTask()); }*/ } }