Пример #1
0
  @SuppressWarnings("unchecked")
  public static ExecutableFlow createExecutableFlowFromObject(Object obj) {
    ExecutableFlow exFlow = new ExecutableFlow();

    HashMap<String, Object> flowObj = (HashMap<String, Object>) obj;
    exFlow.executionId = (Integer) flowObj.get("executionId");
    exFlow.executionPath = (String) flowObj.get("executionPath");
    exFlow.flowId = (String) flowObj.get("flowId");
    exFlow.projectId = (Integer) flowObj.get("projectId");
    exFlow.submitTime = JSONUtils.getLongFromObject(flowObj.get("submitTime"));
    exFlow.startTime = JSONUtils.getLongFromObject(flowObj.get("startTime"));
    exFlow.endTime = JSONUtils.getLongFromObject(flowObj.get("endTime"));
    exFlow.flowStatus = Status.valueOf((String) flowObj.get("status"));
    exFlow.submitUser = (String) flowObj.get("submitUser");
    exFlow.version = (Integer) flowObj.get("version");

    if (flowObj.containsKey("flowParameters")) {
      exFlow.flowParameters =
          new HashMap<String, String>((Map<String, String>) flowObj.get("flowParameters"));
    }
    // Failure notification
    if (flowObj.containsKey("notifyOnFirstFailure")) {
      exFlow.notifyOnFirstFailure = (Boolean) flowObj.get("notifyOnFirstFailure");
    }
    if (flowObj.containsKey("notifyOnLastFailure")) {
      exFlow.notifyOnLastFailure = (Boolean) flowObj.get("notifyOnLastFailure");
    }

    // Failure action
    if (flowObj.containsKey("failureAction")) {
      exFlow.failureAction = FailureAction.valueOf((String) flowObj.get("failureAction"));
    }
    exFlow.pipelineLevel = (Integer) flowObj.get("pipelineLevel");

    // Copy nodes
    List<Object> nodes = (List<Object>) flowObj.get("nodes");
    for (Object nodeObj : nodes) {
      ExecutableNode node = ExecutableNode.createNodeFromObject(nodeObj, exFlow);
      exFlow.executableNodes.put(node.getJobId(), node);
    }

    List<Object> properties = (List<Object>) flowObj.get("properties");
    for (Object propNode : properties) {
      HashMap<String, Object> fprop = (HashMap<String, Object>) propNode;
      String source = (String) fprop.get("source");
      String inheritedSource = (String) fprop.get("inherited");

      FlowProps flowProps = new FlowProps(inheritedSource, source);
      exFlow.flowProps.put(source, flowProps);
    }

    // Success emails
    exFlow.setSuccessEmails((List<String>) flowObj.get("successEmails"));
    // Failure emails
    exFlow.setFailureEmails((List<String>) flowObj.get("failureEmails"));

    if (flowObj.containsKey("proxyUsers")) {
      ArrayList<String> proxyUserList = (ArrayList<String>) flowObj.get("proxyUsers");
      exFlow.setProxyUsers(new HashSet<String>(proxyUserList));
    }

    return exFlow;
  }