use of org.obeonetwork.graal.AbstractTask in project InformationSystem by ObeoNetwork.
the class TaskUtils method getNextAvailableId.
/**
* Returns the next id for the specified type using the specified prefix
*
* @param system
* System to consider
* @param type
* Type of objects wanted
* @param prefix
* Prefix used for IDs
* @return the next available ID
*/
private String getNextAvailableId(System system, EClassifier type, String prefix) {
Pattern ptn = Pattern.compile("^" + prefix + "([0-9]*)$");
int max = 0;
for (Iterator<EObject> it = system.eAllContents(); it.hasNext(); ) {
EObject eObject = it.next();
if (type.isInstance(eObject)) {
String id = ((AbstractTask) eObject).getId();
if (id != null) {
Matcher m = ptn.matcher(id);
if (m.matches()) {
int numId = Integer.parseInt(m.group(1));
if (numId > max) {
max = numId;
}
}
}
}
}
return prefix + (max + 1);
}
use of org.obeonetwork.graal.AbstractTask in project InformationSystem by ObeoNetwork.
the class TaskUtils method candidatesExpresssionForExistingTask.
/**
* Calculate the candidateExpression defines in creation tool Existing Tasks
* in Task Graph.
*
* @param context
* the context of call
* @param diagram
* the representation
* @return list of existing Tasks
*/
public List<AbstractTask> candidatesExpresssionForExistingTask(EObject context, DSemanticDiagram diagram) {
TreeIterator<EObject> eAllContents = getSystem(context).eAllContents();
List<AbstractTask> abstractTasks = new ArrayList<AbstractTask>();
while (eAllContents.hasNext()) {
EObject element = eAllContents.next();
if (element instanceof AbstractTask) {
abstractTasks.add((AbstractTask) element);
}
}
List<Task> tasksDiagram = new ArrayList<Task>();
List<EObject> eContents = diagram.getTarget().eContents();
for (EObject obj : eContents) {
if (obj instanceof Task) {
tasksDiagram.add((Task) obj);
}
}
abstractTasks.removeAll(tasksDiagram);
abstractTasks.remove(context);
return abstractTasks;
}
use of org.obeonetwork.graal.AbstractTask in project InformationSystem by ObeoNetwork.
the class TaskUtils method computeNameFromTasks.
/**
* Computes a name from a list of abstract tasks
*
* @param abstractTasks
* List of abstract tasks for which we want a name
* @return The computed name depending on the main tasks
*/
public String computeNameFromTasks(List<AbstractTask> abstractTasks) {
String name = "";
List<Task> mainTasks = getMainTasks(abstractTasks);
for (Task task : mainTasks) {
name += task.getName() + ";";
}
if (name.length() <= 1) {
name = "";
} else {
name = name.substring(0, name.length() - 1);
}
return name;
}
Aggregations