public static Map < String , String > buildJobContextInfoMap ( final Event event , final String server ) { if ( event . getRunner ( ) instanceof JobRunner ) { final JobRunner jobRunner = ( JobRunner ) event . getRunner ( ) ; final ExecutableNode node = jobRunner . getNode ( ) ; final EventData eventData = event . getData ( ) ; final String projectName = node . getParentFlow ( ) . getProjectName ( ) ; final String flowName = node . getParentFlow ( ) . getFlowId ( ) ; final String executionId = String . valueOf ( node . getParentFlow ( ) . getExecutionId ( ) ) ; final String jobId = node . getId ( ) ; final Map < String , String > result = new HashMap <> ( ) ; result . put ( CONTEXT_SERVER_TOKEN , server ) ; result . put ( CONTEXT_PROJECT_TOKEN , projectName ) ; result . put ( CONTEXT_FLOW_TOKEN , flowName ) ; result . put ( CONTEXT_EXECUTION_ID_TOKEN , executionId ) ; result . put ( CONTEXT_JOB_TOKEN , jobId ) ; result . put ( CONTEXT_JOB_STATUS_TOKEN , eventData . getStatus ( ) . name ( ) . toLowerCase ( ) ) ; /* * if (node.getStatus() == Status.SUCCEEDED || node.getStatus() == * Status.FAILED) { result.put(JOB_STATUS_TOKEN, * node.getStatus().name().toLowerCase()); } else if (node.getStatus() == * Status.PREPARING) { result.put(JOB_STATUS_TOKEN, "started"); } */ return result ; } else { throw new IllegalArgumentException ( "Provided event is not a job event" ) ; } }
This method takes the job context info . and put the values into a map with keys as the tokens .