/** * @param issue * @return */ private boolean checkIfPdfGenerationCompleted(Issue issue, BreezeImportToken breezeToken) { List<Article> issueArticles = issue.getArticles(); boolean breezeStatus = false; for (Article article : issueArticles) { // breezeStatus = IConstants.MSG_SUCCESS_PDF_GEN.equals(article // .getString(Article.ARTICLE_STATUS)); // IConstants.MSG_BREEZE_PDF_INI breezeStatus = AppConfig.getConfigValue(AppConfigContant.AJWF_BREEZE_STATUS_, breezeToken.getSession()) .equals(article.getString(Article.ARTICLE_STATUS)); // if (breezeStatus == false) { // return false; // } if (breezeStatus == true) { return false; } } // return breezeStatus; return true; }
/** * Checks whether breeze output is correct for all articles. In case there are errors from Breeze * it generates the list of articles with Error. * * @param issue * @return */ private String identifyErrorneouArticleFromBreeze(Issue issue) { log.debug("identifyErrorneouArticleFromBreeze: Start; Issue: " + issue); StringBuilder strb = new StringBuilder(); // strb.append(IConstants.MSG_AAU_REJECT_ARTICLE_LIST); List<Article> issueArticles = issue.getArticles(); for (Object element : issueArticles) { Article article = (Article) element; if (article.getString(Article.ARTICLE_STATUS).equalsIgnoreCase(IConstants.MSG_ERROR_PDF_GEN) || article .getString(Article.ARTICLE_STATUS) .equalsIgnoreCase(IConstants.MSG_BREEZE_FILE_MISSING) || article .getString(Article.ARTICLE_STATUS) .equalsIgnoreCase(IConstants.MSG_CORRUPT_PACKAGE_BREEZE) || article .getString(Article.ARTICLE_STATUS) .equalsIgnoreCase(IConstants.MSG_ERROR_UNEXPECTED_FILES)) { try { strb.append( (article.getObjectName().substring(0, article.getObjectName().lastIndexOf("_"))) + ","); } catch (DfException e) { // TODO Auto-generated catch block log.debug("Error while fetching the Object name for article in Issue: " + issue); e.printStackTrace(); } } } String errorArticleList = strb.toString().substring(0, strb.toString().lastIndexOf(",")); log.debug("identifyErrorneouArticleFromBreeze: End; Issue: " + issue); return errorArticleList; }
@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); } }