Commit 3dd97cb6 authored by Mohamed Khalil Labidi's avatar Mohamed Khalil Labidi
Browse files

Merge branch 'feature-application-graph' into 'master'

Feature application graph

See merge request !12
parents 34f62b84 f7c2e840
......@@ -143,6 +143,65 @@ public class PAGateway {
return parentTasks;
* Return the dot format of the application's graph
* @param jobId The ID of the job
* @return The graph in dot format
public String getGraphInDotFormat(String jobId) {
// StringBuilder used to write the syntax of the application graph in dot format
StringBuilder dotGraphSyntax = new StringBuilder();
// Get the job by jobId from the DB
Job applicationJob = EntityManagerHelper.find(Job.class, jobId);
LOGGER.debug("Dot graph creation for the job: "+applicationJob.toString());
// Write the dot file header
dotGraphSyntax.append("digraph g {\n");
// Get the job tasks
LinkedList<Task> jobTasks = new LinkedList<>(applicationJob.getTasks());
// Add the mandatory connections between the tasks
for(Task task : jobTasks){
// Write the dot representation of the task
dotGraphSyntax.append(task.getName() + ";\n");
// Get the current task name
String childTask = task.getName();
// Get the list of the parent tasks
List<String> parentTasks = task.getParentTasks();
// Check for Mandatory connections
// If the list is empty there are no mandatory connections
for (String parentTask : parentTasks) {
// Write the dot syntax of the connection between the two tasks
+ "->"
+ childTask
+ " [fillcolor=red, fontcolor=red, color=red]"
+ ";");
// Write the dot file end character
LOGGER.debug("Dot graph created");
return dotGraphSyntax.toString();
* Create a ProActive job skeleton
* @param job A job skeleton definition in JSON format
package org.activeeon.morphemic.model;
import lombok.*;
import javax.persistence.*;
import java.util.List;
import java.util.Map;
......@@ -37,4 +40,15 @@ public class Job implements Serializable {
.filter(task -> task.getName().equals(taskName)).findAny().orElse(null);
* Transform a job into JSON format
* @return the JSON representation of the job
public String getJobInJson() throws IOException{
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
return ow.writeValueAsString(this);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment