private Map<String, String> getRunningWorkflowId(
     final DeliveryImportToken token, final String strComponentId)
     throws TooManyObjectsException, DfException {
   final String strDql =
       "select distinct p.object_name ,wf.r_object_id from dmi_package pkg,"
           + "dm_workflow wf,dm_process p where any pkg.r_component_id='"
           + strComponentId
           + "'  and pkg.r_workflow_id=wf.r_object_id and wf.process_id=p.r_object_id";
   final StringTable table = token.getSession().query(strDql);
   final Map<String, String> map = new HashMap<String, String>();
   for (int i = 0; i < table.getRowCount(); i++) {
     map.put(table.get(0, i), table.get(1, i));
   }
   return map;
 }
  @Override
  public void execute(final DeliveryImportToken token)
      throws FileProcessingFailedException, SkipFileException, StopJobException, Exception {
    boolean executeWorkflow = false;
    final Map<String, Object> processVariables = new HashMap<String, Object>();
    final BreezeImportToken breezeToken = (BreezeImportToken) token;
    String processName = "";
    WorkflowObject wfObject = token.getWorkflowObject();
    final Stage stage = wfObject.getStage();
    DfLogger.debug(this, stage.name(), null, null);
    final Map<String, String> workflowMap =
        getRunningWorkflowId(token, breezeToken.getWorkflowObject().getObjectId().getId());
    switch (stage) {
      case STAGE_200:
        if (workflowMap.get(WFPaginationConst.WF_AJWF_PAGINATION) != null) {
          updateProcessVariable(
              breezeToken,
              workflowMap.get(WFPaginationConst.WF_AJWF_PAGINATION),
              wfObject.getState(),
              "ss_pagination_status");

        } else if (workflowMap.get(WFFinalQualityCheckConst.WF_AJWF_FINAL_QUALITY_CHECK) != null) {
          updateProcessVariable(
              breezeToken,
              workflowMap.get(WFFinalQualityCheckConst.WF_AJWF_FINAL_QUALITY_CHECK),
              wfObject.getState(),
              "ss_breeze_status");

        } else if (breezeToken.getBreezePojo().isMandatoryFileExists(stage)
            && breezeToken.getLog() == null) {
          processName = WFFinalQualityCheckConst.WF_AJWF_FINAL_QUALITY_CHECK;
          if (workflowMap.get(processName) != null) {
            updateProcessVariable(
                breezeToken, workflowMap.get(processName), wfObject.getState(), "ss_breeze_status");
          }
          processVariables.put("ss_breeze_status", wfObject.getState());
          executeWorkflow = true;

        } else {
          processName = WFPaginationConst.WF_AJWF_PAGINATION;
          if (workflowMap.get(processName) != null) {
            updateProcessVariable(
                breezeToken,
                workflowMap.get(processName),
                wfObject.getState(),
                "ss_pagination_status");
          }
          processVariables.put("isb_is_redo_task", new Boolean(false));
          processVariables.put("ss_copy_editing_folder_id", wfObject.getworkFolder());
          processVariables.put("ss_pagination_status", wfObject.getState());
          executeWorkflow = true;
        }

        break;
      case STAGE_300:
        if (workflowMap.get(WFPaginationPerformProofConst.WF_AJWF_PAGINATION_PERFORM_PROOF)
            != null) {
          updateProcessVariable(
              breezeToken,
              workflowMap.get(WFPaginationPerformProofConst.WF_AJWF_PAGINATION_PERFORM_PROOF),
              wfObject.getState(),
              "ss_pagination_status");

        } else if (workflowMap.get(
                WFQualityCheckPerformProofConst.WF_AJWF_QUALITY_CHECK_PERFORM_PROOF)
            != null) {
          updateProcessVariable(
              breezeToken,
              workflowMap.get(WFQualityCheckPerformProofConst.WF_AJWF_QUALITY_CHECK_PERFORM_PROOF),
              wfObject.getState(),
              "ss_breeze_status");

        } else if (breezeToken.getBreezePojo().isMandatoryFileExists(stage)
            && breezeToken.getLog() == null) {
          processName = WFQualityCheckPerformProofConst.WF_AJWF_QUALITY_CHECK_PERFORM_PROOF;

          if (workflowMap.get(processName) != null) {

            updateProcessVariable(
                breezeToken, workflowMap.get(processName), wfObject.getState(), "ss_breeze_status");
          }

          processVariables.put("ss_breeze_status", wfObject.getState());
          executeWorkflow = true;
        } else {
          processName = WFPaginationPerformProofConst.WF_AJWF_PAGINATION_PERFORM_PROOF;
          if (workflowMap.get(processName) != null) {

            updateProcessVariable(
                breezeToken,
                workflowMap.get(processName),
                wfObject.getState(),
                "ss_pagination_status");
          }
          processVariables.put("isb_is_redo_task", new Boolean(false));
          processVariables.put("ss_work_folder_id", wfObject.getworkFolder());
          processVariables.put("ss_pagination_status", wfObject.getState());
          executeWorkflow = true;
        }

        break;
      case STAGE_600:
        // if (breezeToken.getBreezePojo().isMandatoryFileExists(stage)
        // && breezeToken.getLog() == null) {
        Article article = (Article) breezeToken.getWorkflowObject();
        Issue issue = article.getIssue();
        // WorkflowObject issue=article.getIssue();

        if (checkIfPdfGenerationCompleted(issue, breezeToken)
            && AppConfig.getConfigValue(
                    AppConfigContant.AJWF_QC_COMPLETED_I, breezeToken.getSession())
                .equals(issue.getString(Issue.ZSS_ISSUE_STATUS))) {

          String errorArticleList = identifyErrorneouArticleFromBreeze(issue);

          if (errorArticleList.length() == 0) {
            processName = WFContentDeliveryStage600Const.WF_AJWF_CONTENT_DELIVERY___STAGE_600;
          } else {
            processName =
                WFInitiateAPagesQualityCheckIssueBuildingConst
                    .WF_AJWF_INITIATE_A_PAGES_QUALITY_CHECK___ISSUE_BUILDING;
            processVariables.put("zss_breeze_err_art_lst", errorArticleList);
            processVariables.put(
                "is_rejected",
                AppConfig.getConfigValue(
                    AppConfigContant.AJWF_ARTICLE_LIFE_1, breezeToken.getSession()));
            // IConstants.ARTICLE_LIFECYCLE_STATE_REJECTED);
          }

          log.debug("Starting workflow : " + processName);

          /* Setting the status for Issue and starting the workflow for issues */

          issue.setState(IConstants.ISSUE_STATUS_REJECTED_DUE_TO_BREEZE_ERROR);
          issue.save();

          new StartWorkFlow(processName, null, processVariables, issue).execute(breezeToken);

          // executeWorkflow = true;
          executeWorkflow = false;
        }

        // } else {
        // processName = WFSupportWorkflowConst.WF_AJWF_SUPPORT_WORKFLOW;
        // log.debug("Starting workflow : " + processName);
        // executeWorkflow = true;
        // }
        break;
      case STAGE_DEFAULT:
        throw new IllegalArgumentException("Stage[" + stage + "] is currently not supported ");
    }
    if (executeWorkflow) {
      log.debug("Starting workflow : " + processName);
      new StartWorkFlow(processName, null, processVariables).execute(breezeToken);
    }
  }