use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class BaseContentCategoryImpl method saveContentResult.
/**
* Merge content json and result JSON. Prepare content json object and store it
* in Graph or ES DB
*
* @param contentResult
*/
public void saveContentResult(InsightsContentDetail contentResult) {
try {
long startTime = System.nanoTime();
String json = oMapper.writeValueAsString(contentResult);
JsonObject contentDataJson = JsonUtils.parseStringAsJsonObject(json);
if (!contentResult.getResultValuesMap().isEmpty() && contentDataJson != null) {
JsonObject resultValueJson = JsonUtils.parseStringAsJsonObject(oMapper.writeValueAsString(contentResult.getResultValuesMap()));
contentDataJson = ReportEngineUtils.mergeTwoJson(contentDataJson, resultValueJson);
} else {
log.debug("Worlflow Detail {}==== In Content, no result foundg and data json is null {} ", contentResult.getResultValuesMap(), contentDataJson);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", contentConfigDefinition.getExecutionId(), contentConfigDefinition.getWorkflowId(), contentConfigDefinition.getReportId(), "-", contentConfigDefinition.getKpiId(), contentConfigDefinition.getCategory(), 0, "ContentId :" + contentConfigDefinition.getContentId() + "ContentName :" + contentConfigDefinition.getContentName() + "action :" + contentConfigDefinition.getAction() + "ContentResult :" + contentConfigDefinition.getNoOfResult() + "In Content, no result foundg and data json is null");
}
datasourceDataHandler.saveContentResult(contentDataJson);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", contentConfigDefinition.getExecutionId(), contentConfigDefinition.getWorkflowId(), contentConfigDefinition.getReportId(), "-", contentConfigDefinition.getKpiId(), contentConfigDefinition.getCategory(), processingTime, "ContentId :" + contentConfigDefinition.getContentId() + "ContentName :" + contentConfigDefinition.getContentName() + "action :" + contentConfigDefinition.getAction() + "ContentResult :" + contentConfigDefinition.getNoOfResult());
} catch (Exception e) {
log.error(" Error while saveContentResult ", e);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", contentConfigDefinition.getExecutionId(), contentConfigDefinition.getWorkflowId(), contentConfigDefinition.getReportId(), "-", contentConfigDefinition.getKpiId(), contentConfigDefinition.getCategory(), 0, "ContentId :" + contentConfigDefinition.getContentId() + "ContentName :" + contentConfigDefinition.getContentName() + "action :" + contentConfigDefinition.getAction() + "ContentResult :" + contentConfigDefinition.getNoOfResult() + "Error while saveContentResult " + e.getMessage());
throw new InsightsJobFailedException(" Error while saveContentResult for content Id " + contentResult.getContentId());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class GrafanaPDFExecutionSubscriber method handleTaskExecution.
@Override
public void handleTaskExecution(byte[] body) throws IOException {
try {
long startTime = System.nanoTime();
String incomingTaskMessage = new String(body, StandardCharsets.UTF_8);
log.debug("Worlflow Detail ==== GrafanaPDFExecutionSubscriber started ... " + "routing key message handleDelivery ===== {} ", incomingTaskMessage);
JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(incomingTaskMessage);
String workflowId = incomingTaskMessageJson.get("workflowId").getAsString();
long executionId = incomingTaskMessageJson.get("executionId").getAsLong();
workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(workflowId);
log.debug("Worlflow Detail ==== scheduleType {} ", workflowConfig.getScheduleType());
assessmentReportDTO = new InsightsAssessmentConfigurationDTO();
assessmentReportDTO.setIncomingTaskMessageJson(incomingTaskMessage);
assessmentReportDTO.setExecutionId(executionId);
assessmentReportDTO.setWorkflowId(workflowId);
BasePDFProcessor chartHandler = ReportPDFVisualizationHandlerFactory.getChartHandler("GrafanaPDF");
chartHandler.generatePDF(assessmentReportDTO);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type = Grafana PDF ");
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), workflowConfig.getWorkflowType(), "-", "-", processingTime, " ReportName :" + assessmentReportDTO.getReportName() + " Visualizationutil :" + assessmentReportDTO.getVisualizationutil());
} catch (InsightsJobFailedException ie) {
log.error("Worlflow Detail ==== GrafanaPDFExecutionSubscriber Completed with error ", ie);
log.error("Type = Grafana PDF");
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), workflowConfig.getWorkflowType(), "-", "-", 0, " ReportName :" + assessmentReportDTO.getReportName() + " Visualizationutil :" + assessmentReportDTO.getVisualizationutil() + "GrafanaPDFExecutionSubscriber Completed with error" + ie.getMessage());
statusLog = ie.getMessage();
throw ie;
} catch (Exception e) {
log.error("Worlflow Detail ==== GrafanaPDFExecutionSubscriber Completed with error ", e);
log.error("Type = Grafana PDF");
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), workflowConfig.getWorkflowType(), "-", "-", 0, " ReportName :" + assessmentReportDTO.getReportName() + " Visualizationutil :" + assessmentReportDTO.getVisualizationutil() + "GrafanaPDFExecutionSubscriber Completed with error" + e.getMessage());
throw new InsightsJobFailedException(e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class HyperLedgerExecutionSubscriber method handleTaskExecution.
@Override
public void handleTaskExecution(byte[] body) throws IOException {
try {
String incomingTaskMessage = new String(body, MQMessageConstants.MESSAGE_ENCODING);
log.debug("Worlflow Detail ==== HyperLedgerExecutionSubscriber started ... " + "routing key message handleDelivery ===== {} ", incomingTaskMessage);
assessmentReportDTO = new InsightsAssessmentConfigurationDTO();
assessmentReportDTO.setIncomingTaskMessageJson(incomingTaskMessage);
JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(incomingTaskMessage);
String workflowId = incomingTaskMessageJson.get("workflowId").getAsString();
workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(workflowId);
log.debug("Worlflow Detail ==== scheduleType {} ", workflowConfig.getScheduleType());
long startDate = 0;
long endDate = 0;
long startDateEpoch = 0;
if (workflowConfig.getScheduleType().equals(WorkflowTaskEnum.WorkflowSchedule.ONETIME.name())) {
startDate = workflowConfig.getAssessmentConfig().getStartDate();
endDate = workflowConfig.getAssessmentConfig().getEndDate();
} else {
startDateEpoch = workflowConfig.getNextRun();
startDate = InsightsUtils.getStartFromTime(startDateEpoch, workflowConfig.getScheduleType()) - 1;
endDate = startDateEpoch;
}
log.debug("Worlflow Detail ==== startDate & endDate in Epoch {} {}", startDate, endDate);
String ledgerStartDate = InsightsUtils.epochToDateFormat(startDate, "yyyy-MM-dd");
String ledgerEndDate = InsightsUtils.epochToDateFormat(endDate, "yyyy-MM-dd");
log.debug("Worlflow Detail ==== ledgerStartDate & ledgerEndDate {} {}", ledgerStartDate, ledgerEndDate);
prepareAssestmentDTO(incomingTaskMessageJson);
List<JsonObject> ledgerList = fetchLedgerRecords(ledgerStartDate, ledgerEndDate);
assessmentReportDTO.setLedgerRecords(ledgerList);
BasePDFProcessor chartHandler = ReportPDFVisualizationHandlerFactory.getChartHandler(assessmentReportDTO.getVisualizationutil());
chartHandler.generatePDF(assessmentReportDTO);
log.debug("Worlflow Detail ==== HyperLedgerExecutionSubscriber Completed {} ", incomingTaskMessageJson);
} catch (InsightsJobFailedException ijfe) {
log.error("Worlflow Detail ==== HyperLedgerExecutionSubscriber Completed with error ", ijfe);
statusLog = ijfe.getMessage();
throw ijfe;
} catch (Exception e) {
log.error("Worlflow Detail ==== HyperLedgerExecutionSubscriber Completed with error ", e);
throw new InsightsJobFailedException(e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class MileStoneExecutionSubscriber method handleTaskExecution.
@Override
public void handleTaskExecution(byte[] body) throws IOException {
try {
String incomingTaskMessage = new String(body, StandardCharsets.UTF_8);
log.debug("Worlflow Detail ==== MileStoneExecutionSubscriber started ... " + "routing key message handleDelivery ===== {} ", incomingTaskMessage);
JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(incomingTaskMessage);
String workflowId = incomingTaskMessageJson.get("workflowId").getAsString();
long executionId = incomingTaskMessageJson.get("executionId").getAsLong();
workflowConfig = workflowDAL.getWorkflowConfigByWorkflowId(workflowId);
log.debug("Worlflow Detail ==== scheduleType {} ", workflowConfig.getScheduleType());
assessmentReportDTO = new InsightsAssessmentConfigurationDTO();
assessmentReportDTO.setIncomingTaskMessageJson(incomingTaskMessage);
assessmentReportDTO.setExecutionId(executionId);
assessmentReportDTO.setWorkflowId(workflowId);
MileStoneConfig mileStoneConfig = mileStoneConfigDAL.fetchMileStoneByWorkflowId(assessmentReportDTO.getWorkflowId());
Long startDate = mileStoneConfig.getStartDate();
if (startDate < Instant.now().getEpochSecond()) {
mileStoneConfig.setStatus("IN_PROGRESS");
mileStoneConfigDAL.updateMileStoneConfig(mileStoneConfig);
List<JsonObject> listOfMilestoneJson = createToolBasedJson(mileStoneConfig);
for (JsonObject milestone : listOfMilestoneJson) {
publishMessageInMQ(milestone.get("queueName").getAsString(), milestone.toString());
}
}
} catch (Exception e) {
log.error("Worlflow Detail ==== MileStoneExecutionSubscriber Completed with error ", e);
throw new InsightsJobFailedException(e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException 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