Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Andreas Tsagkaropoulos
morphemic-preprocessor
Commits
3dd97cb6
Commit
3dd97cb6
authored
Feb 11, 2021
by
Mohamed Khalil Labidi
Browse files
Merge branch 'feature-application-graph' into 'master'
Feature application graph See merge request
!12
parents
34f62b84
f7c2e840
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/activeeon/morphemic/PAGateway.java
View file @
3dd97cb6
...
...
@@ -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
dotGraphSyntax
.
append
(
parentTask
+
"->"
+
childTask
+
" [fillcolor=red, fontcolor=red, color=red]"
+
";"
);
dotGraphSyntax
.
append
(
"\n"
);
}
}
// Write the dot file end character
dotGraphSyntax
.
append
(
"}\n"
);
LOGGER
.
debug
(
"Dot graph created"
);
return
dotGraphSyntax
.
toString
();
}
/**
* Create a ProActive job skeleton
* @param job A job skeleton definition in JSON format
...
...
src/main/java/org/activeeon/morphemic/model/Job.java
View file @
3dd97cb6
package
org.activeeon.morphemic.model
;
import
lombok.*
;
import
org.codehaus.jackson.map.ObjectMapper
;
import
org.codehaus.jackson.map.ObjectWriter
;
import
javax.persistence.*
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -37,4 +40,15 @@ public class Job implements Serializable {
return
tasks
.
stream
()
.
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
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment