public static Result restWorkflowFromFlowId(String flowId) {

    if (flowId == null || flowId.isEmpty()) {
      JsonObject parent = new JsonObject();
      parent.add(JsonKeys.WORKFLOWS, new JsonObject());
      return notFound(new Gson().toJson(parent));
    }

    JsonArray jobSeverityArray = new JsonArray();
    JsonArray jobSummaryArray = new JsonArray();
    JsonObject data = new JsonObject();

    String flowExecId = flowId;
    String username = "";
    long totalFlowResourceUsed = 0;
    long totalFlowResourceWasted = 0;
    long totalFlowRuntime = 0;
    long totalFlowDelay = 0;
    Severity flowSeverity = Severity.NONE;
    long flowStartTime = Long.MAX_VALUE;
    long flowEndTime = 0;
    String flowDefinitionId = "";
    Map<Severity, Long> jobSeverityCount = new HashMap<Severity, Long>();
    String wfQueueName = "";
    String wfSchedulerName = "";

    List<AppResult> results = getRestFlowResultsFromFlowExecutionId(flowId);

    if (results.isEmpty()) {
      JsonObject parent = new JsonObject();
      parent.add(JsonKeys.WORKFLOWS, data);
      return notFound(new Gson().toJson(parent));
    }

    Map<IdUrlPair, List<AppResult>> jobExecIdToJobsMap =
        ControllerUtil.groupJobs(results, ControllerUtil.GroupBy.JOB_EXECUTION_ID);

    for (IdUrlPair jobDefPair : jobExecIdToJobsMap.keySet()) {
      long totalJobMemoryUsed = 0;
      long totalJobMemoryWasted = 0;
      long totalJobDelay = 0;
      long totalJobRuntime = 0;
      long jobStartTime = Long.MAX_VALUE;
      long jobEndTime = 0;
      Severity jobSeverity = Severity.NONE;
      String jobType = null;
      String jobId = jobDefPair.getId();
      String jobName = "";
      String queueName = "";
      String schedulerName = "";

      Map<Severity, Long> taskSeverityCount = new HashMap<Severity, Long>();

      for (AppResult task : jobExecIdToJobsMap.get(jobDefPair)) {
        totalJobMemoryUsed += task.resourceUsed;
        totalJobMemoryWasted += task.resourceWasted;
        username = task.username;
        jobType = task.jobType;
        jobName = task.jobName;
        flowDefinitionId = task.flowDefId;
        queueName = task.queueName;
        schedulerName = task.scheduler;

        if (task.startTime < jobStartTime) {
          jobStartTime = task.startTime;
        }

        if (task.finishTime > jobEndTime) {
          jobEndTime = task.finishTime;
        }
        if (task.severity.getValue() > jobSeverity.getValue()) {
          jobSeverity = task.severity;
        }

        if (taskSeverityCount.containsKey(task.severity)) {
          taskSeverityCount.put(task.severity, taskSeverityCount.get(task.severity) + 1L);
        } else {
          taskSeverityCount.put(task.severity, 1L);
        }
      } // task scope ends here

      if (jobSeverityCount.containsKey(jobSeverity)) {
        jobSeverityCount.put(jobSeverity, jobSeverityCount.get(jobSeverity) + 1L);
      } else {
        jobSeverityCount.put(jobSeverity, 1L);
      }

      JsonArray taskSeverity = new JsonArray();
      List<Severity> keys = getSortedSeverityKeys(taskSeverityCount.keySet());
      for (Severity key : keys) {
        JsonObject severityObject = new JsonObject();
        severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
        severityObject.addProperty(JsonKeys.COUNT, taskSeverityCount.get(key));
        taskSeverity.add(severityObject);
      }

      wfQueueName = queueName;
      wfSchedulerName = schedulerName;
      totalJobDelay = Utils.getTotalWaittime(jobExecIdToJobsMap.get(jobDefPair));
      totalJobRuntime = Utils.getTotalRuntime(jobExecIdToJobsMap.get(jobDefPair));

      JsonObject jobObject = new JsonObject();
      jobObject.addProperty(JsonKeys.ID, jobId);
      jobObject.addProperty(JsonKeys.JOB_NAME, jobName);
      jobObject.addProperty(JsonKeys.JOB_TYPE, jobType);
      jobObject.addProperty(JsonKeys.USERNAME, username);
      jobObject.addProperty(JsonKeys.START_TIME, jobStartTime);
      jobObject.addProperty(JsonKeys.FINISH_TIME, jobEndTime);
      jobObject.addProperty(JsonKeys.RUNTIME, totalJobRuntime);
      jobObject.addProperty(JsonKeys.WAITTIME, totalJobDelay);
      jobObject.addProperty(JsonKeys.RESOURCE_USED, totalJobMemoryUsed);
      jobObject.addProperty(JsonKeys.RESOURCE_WASTED, totalJobMemoryWasted);
      jobObject.addProperty(JsonKeys.QUEUE, queueName);
      jobObject.addProperty(JsonKeys.SCHEDULER, schedulerName);
      jobObject.addProperty(JsonKeys.SEVERITY, jobSeverity.getText());
      jobObject.add(JsonKeys.TASKS_SEVERITY, taskSeverity);

      jobSummaryArray.add(jobObject);

      totalFlowResourceUsed += totalJobMemoryUsed;
      totalFlowResourceWasted += totalJobMemoryWasted;
      if (jobSeverity.getValue() > flowSeverity.getValue()) {
        flowSeverity = jobSeverity;
      }

      if (flowStartTime > jobStartTime) {
        flowStartTime = jobStartTime;
      }

      if (flowEndTime < jobEndTime) {
        flowEndTime = jobEndTime;
      }
    }// job map scope ends here

    List<Severity> keys = getSortedSeverityKeys(jobSeverityCount.keySet());
    for (Severity key : keys) {
      JsonObject severityObject = new JsonObject();
      severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
      severityObject.addProperty(JsonKeys.COUNT, jobSeverityCount.get(key));
      jobSeverityArray.add(severityObject);
    }

    totalFlowDelay = Utils.getTotalWaittime(results);
    totalFlowRuntime = Utils.getTotalRuntime(results);
    data.addProperty(JsonKeys.ID, flowExecId);
    data.addProperty(JsonKeys.USERNAME, username);
    data.addProperty(JsonKeys.START_TIME, flowStartTime);
    data.addProperty(JsonKeys.FINISH_TIME, flowEndTime);
    data.addProperty(JsonKeys.RUNTIME, totalFlowRuntime);
    data.addProperty(JsonKeys.WAITTIME, totalFlowDelay);
    data.addProperty(JsonKeys.RESOURCE_USED, totalFlowResourceUsed);
    data.addProperty(JsonKeys.RESOURCE_WASTED, totalFlowResourceWasted);
    data.addProperty(JsonKeys.SEVERITY, flowSeverity.getText());
    data.addProperty(JsonKeys.FLOW_EXEC_ID, flowExecId);
    data.addProperty(JsonKeys.FLOW_DEF_ID, flowDefinitionId);
    data.addProperty(JsonKeys.QUEUE, wfQueueName);
    data.addProperty(JsonKeys.SCHEDULER, wfSchedulerName);
    data.add(JsonKeys.JOBSSUMMARIES, jobSummaryArray);
    data.add(JsonKeys.JOBS_SEVERITY, jobSeverityArray);
    JsonObject parent = new JsonObject();
    parent.add(JsonKeys.WORKFLOWS, data);
    return ok(new Gson().toJson(parent));
  }
This method returns the workflow response object based on the flow execution id
@param flowId The flow execution id for which the flow should be returned
@return Return the workflow detail based on the flow execution id

response object:
<pre>
*{
   "workflows": {
   "id": "flowid",
       "username": "username",
       "starttime": 1471910835628,
       "finishtime": 1471911099238,
       "runtime": 263610,
       "waittime": 46234,
       "resourceused": 101382144,
       "resourcewasted": 15993417,
       "severity": "Moderate",
       "flowexecid": "flowexecid",
       "flowdefid": "flowdefid",
       "jobssummaries": [
         {
           "id": "jobid",
           "jobname": "jobname",
           "jobtype": "Pig",
           "username": "username",
           "starttime": 1471910835628,
           "finishtime": 1471911099238,
           "runtime": 263610,
           "waittime": 46234,
           "resourceused": 101382144,
           "resourcewasted": 15993417,
           "severity": "Moderate",
           "tasksseverity": [
             {
               "severity": "Moderate",
               "count": 1
             }
            ]
       }
     ],
       "jobsseverity": [
         {
           "severity": "Moderate",
           "count": 1
         }
     ]
 }
}
</pre>
app/controllers/api/v1/Web.java