use of org.obeonetwork.graal.TasksGroup in project InformationSystem by ObeoNetwork.
the class TaskUtils method getMainTasks.
/**
* Gets the main tasks from a list of abstract tasks
*
* @param abstractTasks
* List of abstract tasks to be considered
* @return the main tasks from the list, considering the "use" relationships
* between tasks
*/
private List<Task> getMainTasks(List<AbstractTask> abstractTasks) {
List<Task> mainTasks = new ArrayList<Task>();
// We have to consider every task in groups or not
List<Task> tasks = new ArrayList<Task>();
for (AbstractTask abstractTask : abstractTasks) {
if (abstractTask instanceof Task) {
tasks.add((Task) abstractTask);
} else {
tasks.addAll(getAllEnclosedTasks((TasksGroup) abstractTask));
}
}
// Get all tasks in the group
for (Task task : tasks) {
boolean usedByInnerTask = false;
for (Task usingTask : task.getUsedBy()) {
if (tasks.contains(usingTask)) {
usedByInnerTask = true;
break;
}
}
if (usedByInnerTask == false) {
mainTasks.add(task);
}
}
return mainTasks;
}
use of org.obeonetwork.graal.TasksGroup in project InformationSystem by ObeoNetwork.
the class TaskUtils method deleteTaskUseTaskEdge.
/**
* This service is used to remove the "use" relationship between 2 abstract
* tasks and remove the corresponding elements on the using task's Actions
* Plan when needed
*
* @param usingTask
* Source AbstractTask instance of the relationship
* @param usedTask
* Target AbstractTask instance of the relationship
*/
public void deleteTaskUseTaskEdge(AbstractTask usingTask, AbstractTask usedTask) {
Session session = SessionManager.INSTANCE.getSession(usingTask);
ModelAccessor modelAccessor = session.getModelAccessor();
// Get all potentially concerned used Tasks
List<Task> usedTasks = new ArrayList<Task>();
if (usedTask instanceof Task) {
usedTasks.add((Task) usedTask);
} else {
usedTasks.addAll(getAllUsedTasks((TasksGroup) usedTask));
}
// Check if the using "task" is a Task or a Group
if (usingTask instanceof Task) {
for (Task realUsedTask : usedTasks) {
deleteUseRelationship((Task) usingTask, realUsedTask, session, modelAccessor);
}
} else {
for (Task realUsedTask : usedTasks) {
for (Task realUsingTask : getTasksFromGroupUsingTask((TasksGroup) usingTask, realUsedTask)) {
deleteUseRelationship(realUsingTask, realUsedTask, session, modelAccessor);
}
}
}
}
use of org.obeonetwork.graal.TasksGroup in project InformationSystem by ObeoNetwork.
the class ActorUtils method internalGetVisibleActors.
/**
* Collect the visible actors for a task, using an internal cache
* @param abstractTask
* @param cache Map to store already calculated links between Tasks and Actors
* @param actorsLeft List of actors not yet in the final list (used to improve performance)
* @return
*/
private Set<Actor> internalGetVisibleActors(AbstractTask abstractTask, Map<Task, Set<Actor>> cache, List<Actor> actorsLeft) {
if (!actorsLeft.isEmpty()) {
if (abstractTask instanceof Task) {
Task task = (Task) abstractTask;
if (cache.containsKey(task)) {
return cache.get(task);
} else {
Set<Actor> actors = new LinkedHashSet<Actor>();
cache.put(task, actors);
if (task.getActors().isEmpty()) {
for (Task usingTask : task.getUsedBy()) {
if (!cache.containsKey(usingTask) && !actorsLeft.isEmpty()) {
actors.addAll(internalGetVisibleActors(usingTask, cache, actorsLeft));
}
}
} else {
actors.addAll(task.getActors());
actorsLeft.removeAll(actors);
}
cache.put(task, actors);
return actors;
}
} else if (abstractTask instanceof TasksGroup) {
Set<Actor> actors = new LinkedHashSet<Actor>();
TasksGroup group = (TasksGroup) abstractTask;
for (AbstractTask subTask : group.getTasks()) {
if (!actorsLeft.isEmpty()) {
actors.addAll(internalGetVisibleActors(subTask, cache, actorsLeft));
}
}
return actors;
}
}
return new LinkedHashSet<Actor>();
}
use of org.obeonetwork.graal.TasksGroup in project InformationSystem by ObeoNetwork.
the class TaskUtils method deleteChildrenTasksAndTasksGroups.
/**
* Deletes the children tasks and groups in a TasksContainer
*
* @param container
*/
public void deleteChildrenTasksAndTasksGroups(TasksContainer container) {
// Deletion of sub-groups
List<TasksGroup> childrenGroups = new ArrayList<TasksGroup>(container.getOwnedGroups());
for (TasksGroup childGroup : childrenGroups) {
deleteChildrenTasksAndTasksGroups(childGroup);
}
// Deletion of tasks
List<Task> childrenTasks = new ArrayList<Task>(container.getOwnedTasks());
for (Task childTask : childrenTasks) {
deleteTask(childTask);
}
}
use of org.obeonetwork.graal.TasksGroup in project InformationSystem by ObeoNetwork.
the class RelatedActorsTests method addGroup.
private TasksGroup addGroup(TasksContainer container, String name) {
TasksGroup group = GraalFactory.eINSTANCE.createTasksGroup();
group.setName(name);
container.getTasks().add(group);
return group;
}
Aggregations