use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer in project Insights by CognizantOneDevOps.
the class WorkflowServiceImpl method getReportPDF.
/**
* Method to get Report PDF
*
* @param pdfDetailsJson
* @return byte[]
* @throws InsightsCustomException
*/
public byte[] getReportPDF(JsonObject pdfDetailsJson) throws InsightsCustomException {
byte[] pdfContent = null;
try {
String workflowId = pdfDetailsJson.get(AssessmentReportAndWorkflowConstants.WORKFLOW_ID).getAsString();
long executionId = pdfDetailsJson.get("executionId").getAsLong();
InsightsReportVisualizationContainer reportVisObject = workflowConfigDAL.getReportVisualizationContainerByWorkflowAndExecutionId(workflowId, executionId);
if (reportVisObject != null) {
pdfContent = reportVisObject.getAttachmentData();
} else {
throw new InsightsCustomException("PDF not generated");
}
} catch (Exception e) {
log.error("Error while updating report status.", e);
throw new InsightsCustomException(e.toString());
}
return pdfContent;
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer in project Insights by CognizantOneDevOps.
the class ReportEmailSubscriber method updateEmailHistoryWithStatus.
/**
* Method to update Email History record status
*
* @param executionId
* @param status
*/
private void updateEmailHistoryWithStatus(long executionId, String status) {
InsightsReportVisualizationContainer emailHistoryConfig = workflowDAL.getEmailExecutionHistoryByExecutionId(executionId);
if (emailHistoryConfig != null) {
emailHistoryConfig.setStatus(status);
emailHistoryConfig.setExecutionTime(InsightsUtils.getCurrentTimeInEpochMilliSeconds());
workflowDAL.updateEmailExecutionHistory(emailHistoryConfig);
}
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer in project Insights by CognizantOneDevOps.
the class ReportEmailSubscriber method updateEmailHistoryWithEmailTemplateValues.
/**
* Method to update values in Email History table
*
* @param incomingTaskMessage
* @param emailTemplate
* @return
*/
private MailReport updateEmailHistoryWithEmailTemplateValues(JsonObject incomingTaskMessage, InsightsEmailTemplates emailTemplate) {
try {
workflowId = incomingTaskMessage.get(AssessmentReportAndWorkflowConstants.WORKFLOW_ID).getAsString();
executionId = incomingTaskMessage.get(AssessmentReportAndWorkflowConstants.EXECUTIONID).getAsLong();
InsightsWorkflowConfiguration workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(workflowId);
Map<String, String> valuesMap = new HashMap<>();
if (workflowConfig.getAssessmentConfig() != null) {
valuesMap.put("ReportDisplayName", workflowConfig.getAssessmentConfig().getAsseementReportDisplayName());
}
valuesMap.put("TimeOfReportGeneration", InsightsUtils.specficTimeFormat(executionId, "yyyy-MM-dd"));
valuesMap.put("Schedule", workflowConfig.getScheduleType());
StringSubstitutor sub = new StringSubstitutor(valuesMap, "{", "}");
InsightsReportVisualizationContainer emailHistoryConfig = workflowDAL.getEmailExecutionHistoryByExecutionId(incomingTaskMessage.get(AssessmentReportAndWorkflowConstants.EXECUTIONID).getAsLong());
if (emailHistoryConfig != null) {
emailHistoryConfig.setMailFrom(emailTemplate.getMailFrom());
emailHistoryConfig.setMailTo(emailTemplate.getMailTo());
emailHistoryConfig.setMailCC(emailTemplate.getMailCC());
emailHistoryConfig.setMailBCC(emailTemplate.getMailBCC());
if (emailHistoryConfig.getMailBody() == null) {
emailHistoryConfig.setMailBody(sub.replace(emailTemplate.getMailBody()));
}
emailHistoryConfig.setSubject(sub.replace(emailTemplate.getSubject()));
emailHistoryConfig.setStatus(WorkflowTaskEnum.EmailStatus.IN_PROGRESS.toString());
emailHistoryConfig.setMailId(emailTemplate.getId());
workflowDAL.updateEmailExecutionHistory(emailHistoryConfig);
return collectInfoFromDataBase(incomingTaskMessage, emailHistoryConfig);
} else {
throw new InsightsJobFailedException("No record found in Email History table");
}
} catch (InsightsJobFailedException e) {
throw new InsightsJobFailedException(e.getMessage());
} catch (Exception e) {
log.error("Workflow Detail ==== ReportEmailSubscriber Incorrect email format found ===== ", e);
throw new InsightsJobFailedException("Error while updating values to Email History ");
}
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer in project Insights by CognizantOneDevOps.
the class SystemNotificationDetailSubscriber method setDetailsInEmailHistory.
/**
* Method to save Email details in Email History table
*
* @param incomingTaskMessageJson
* @param mailBody
*/
private void setDetailsInEmailHistory(JsonObject incomingTaskMessageJson, String mailBody) {
try {
InsightsReportVisualizationContainer emailHistoryConfig = new InsightsReportVisualizationContainer();
emailHistoryConfig.setExecutionId(incomingTaskMessageJson.get("executionId").getAsLong());
emailHistoryConfig.setStatus(WorkflowTaskEnum.EmailStatus.NOT_STARTED.name());
emailHistoryConfig.setWorkflowConfig(incomingTaskMessageJson.get("workflowId").getAsString());
emailHistoryConfig.setMailBody(mailBody);
emailHistoryConfig.setMailAttachmentName("");
workflowDAL.saveEmailExecutionHistory(emailHistoryConfig);
} catch (Exception e) {
log.error("Worlflow Detail ==== Error setting Email details in Email History table");
throw new InsightsJobFailedException("Worlflow Detail ==== Error setting Email details in Email History table");
}
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer in project Insights by CognizantOneDevOps.
the class PDFExecutionSubscriber method setPDFDetailsInEmailHistory.
private void setPDFDetailsInEmailHistory(JsonObject incomingTaskMessageJson) {
try {
long startTime = System.nanoTime();
String workflowId = incomingTaskMessageJson.get(AssessmentReportAndWorkflowConstants.WORKFLOW_ID).getAsString();
InsightsReportVisualizationContainer emailHistoryConfig = new InsightsReportVisualizationContainer();
emailHistoryConfig.setExecutionId(assessmentReportDTO.getExecutionId());
emailHistoryConfig.setMailAttachmentName(assessmentReportDTO.getAsseementreportname());
File attachedFile = new File(assessmentReportDTO.getPdfExportedFilePath());
if (attachedFile.exists()) {
emailHistoryConfig.setAttachmentData(FileUtils.readFileToByteArray(attachedFile));
} else {
throw new InsightsJobFailedException("Worlflow Detail ==== Error setting PDF details in Email History table");
}
if (incomingTaskMessageJson.get("nextTaskId").getAsInt() == -1) {
emailHistoryConfig.setStatus(WorkflowTaskEnum.WorkflowStatus.COMPLETED.name());
emailHistoryConfig.setExecutionTime(InsightsUtils.getCurrentTimeInEpochMilliSeconds());
} else {
emailHistoryConfig.setStatus(WorkflowTaskEnum.EmailStatus.NOT_STARTED.name());
}
emailHistoryConfig.setWorkflowConfig(workflowId);
workflowDAL.saveEmailExecutionHistory(emailHistoryConfig);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), "-", "-", "-", processingTime, "reportId: " + assessmentReportDTO.getReportId() + "reportName: " + assessmentReportDTO.getReportName() + "VisualizationUtil" + assessmentReportDTO.getVisualizationutil());
} catch (Exception e) {
log.error("Worlflow Detail ==== Error setting PDF details in Email History table");
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), "-", "-", "-", 0, "reportId: " + assessmentReportDTO.getReportId() + "reportName: " + assessmentReportDTO.getReportName() + "VisualizationUtil" + assessmentReportDTO.getVisualizationutil() + "Error setting PDF details in Email History table" + e.getMessage());
throw new InsightsJobFailedException("Worlflow Detail ==== Error setting PDF details in Email History table");
}
}
Aggregations