use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class OpenPDFChartHandler method generatePDF.
@Override
public void generatePDF(InsightsAssessmentConfigurationDTO assessmentReportDTO) {
try {
createPDFDirectory(assessmentReportDTO);
prepareAndExportPDFFile(assessmentReportDTO);
} catch (Exception e) {
log.error(e);
throw new InsightsJobFailedException(e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class PDFExecutionUtils method saveToVisualizationContainer.
/**
* Method use to update PDF details in Email execution table in database.
*
* @param assessmentReportDTO
* @param pdf
*/
public void saveToVisualizationContainer(InsightsAssessmentConfigurationDTO assessmentReportDTO, byte[] pdf) {
try {
InsightsReportVisualizationContainer emailHistoryConfig = new InsightsReportVisualizationContainer();
emailHistoryConfig.setExecutionId(assessmentReportDTO.getExecutionId());
emailHistoryConfig.setAttachmentData(pdf);
JsonObject incomingTaskMessageJson = JsonUtils.parseStringAsJsonObject(assessmentReportDTO.getIncomingTaskMessageJson());
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.setMailAttachmentName(assessmentReportDTO.getAsseementreportname());
emailHistoryConfig.setWorkflowConfig(assessmentReportDTO.getWorkflowId());
workflowDAL.saveEmailExecutionHistory(emailHistoryConfig);
} catch (Exception e) {
log.error("Worlflow Detail ==== Error setting PDF details in Email History table");
throw new InsightsJobFailedException("Worlflow Detail ==== Error setting PDF details in Email History table");
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class ContentExecutor method executeContentJob.
public static JsonArray executeContentJob(List<InsightsContentConfig> contentConfigList, InsightsKPIConfigDTO kpiConfigDTO) {
long startTime = System.nanoTime();
ReportPostgresDataHandler contentProcessing = new ReportPostgresDataHandler();
AssessmentReportContentProcesser contentProcessor = new AssessmentReportContentProcesser();
JsonArray failedContentJobs = new JsonArray();
for (InsightsContentConfig contentConfig : contentConfigList) {
try {
ContentConfigDefinition contentConfigDefinition = contentProcessing.convertJsonToContentConfig(contentConfig);
if (contentConfigDefinition != null) {
contentConfigDefinition.setExecutionId(kpiConfigDTO.getExecutionId());
contentConfigDefinition.setSchedule(kpiConfigDTO.getSchedule());
contentConfigDefinition.setWorkflowId(kpiConfigDTO.getWorkflowId());
contentConfigDefinition.setReportId(kpiConfigDTO.getReportId());
contentConfigDefinition.setAssessmentId(kpiConfigDTO.getAssessmentId());
contentConfigDefinition.setAssessmentReportName(kpiConfigDTO.getAssessmentReportName());
contentProcessor.executeContentData(contentConfigDefinition);
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());
} else {
throw new InsightsJobFailedException("Content execution failed");
}
} catch (InsightsJobFailedException e) {
failedContentJobs.add(contentConfig.getContentId());
}
}
return failedContentJobs;
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class MinMaxCategoryImpl method minInferenceResult.
/**
* Method to get min content result from kpi result
*
* @param inferenceResults
* @return
*/
private InsightsContentDetail minInferenceResult(List<InsightsKPIResultDetails> inferenceResults) {
InsightsContentDetail inferenceContentResult = null;
Map<String, Object> resultValuesMap = new HashMap<>();
String comparisonField = getResultFieldFromContentDefination();
try {
long startTime = System.nanoTime();
InsightsKPIResultDetails minResultObject = Collections.min(inferenceResults, Comparator.comparing(e -> (double) e.getResults().get(comparisonField)));
// double minValue = (double) minResultObject.getResults().get(comparisonField);
String dateOfMinValue = InsightsUtils.insightsTimeXFormat(minResultObject.getRecordDate());
String inferenceText = "";
ReportEngineEnum.KPISentiment sentiment = ReportEngineEnum.KPISentiment.NEUTRAL;
InsightsKPIResultDetails resultFirstData = inferenceResults.get(0);
addTimeValueinResult(resultValuesMap, contentConfigDefinition.getSchedule());
String result = getResultValueForDisplay(minResultObject.getResults().get(comparisonField));
resultValuesMap.put("result", result);
resultValuesMap.put("minDate", dateOfMinValue);
if (result.equalsIgnoreCase("0.0") || result.equalsIgnoreCase("0")) {
inferenceText = getContentText(ReportEngineUtils.NEUTRAL_MESSAGE_KEY, resultValuesMap);
} else {
inferenceText = getContentText(ReportEngineUtils.STANDARD_MESSAGE_KEY, resultValuesMap);
}
if (inferenceText != null) {
inferenceContentResult = setContentDetail(resultFirstData, resultValuesMap, sentiment, "", inferenceText);
} else {
log.debug(" inference text is null in category Min KPIId {} contentId {} result {} ", getContentConfig().getKpiId(), getContentConfig().getContentId(), resultFirstData);
}
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(e);
log.error(" Error while content processing for Min-Max KPIId {} contentId {} ", getContentConfig().getKpiId(), getContentConfig().getContentId());
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() + "Error while content processing for Min-Max" + e.getMessage());
throw new InsightsJobFailedException("Error while content processing for Min-Max KPIId {} contentId {} " + e.getMessage());
}
return inferenceContentResult;
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class ThresholdContentCategoryImpl method countInferenceResult.
/**
* Process KPI result to create content text using count and precentage method
*
* @param inferenceResults
* @return
*/
private InsightsContentDetail countInferenceResult(List<InsightsKPIResultDetails> inferenceResults) {
long startTime = System.nanoTime();
InsightsContentDetail inferenceContentResult = null;
Map<String, Object> resultValuesMap = new HashMap<>();
List<InsightsKPIResultDetails> listBelow = new ArrayList<>();
List<InsightsKPIResultDetails> listAbove = new ArrayList<>();
try {
String result = "";
String inferenceText = "";
InsightsKPIResultDetails resultFirstData = inferenceResults.get(0);
String actaulDirection = "Neutral";
addTimeValueinResult(resultValuesMap, contentConfigDefinition.getSchedule());
for (InsightsKPIResultDetails inferenceResultDetails : inferenceResults) {
String comparisonField = getResultFieldFromContentDefination();
Double currentValue = (Double) inferenceResultDetails.getResults().get(comparisonField);
if (currentValue < getContentConfig().getThreshold()) {
listBelow.add(inferenceResultDetails);
} else {
listAbove.add(inferenceResultDetails);
}
}
resultValuesMap.put("belowThresholdCount", listBelow.size());
resultValuesMap.put("aboveThresholdCount", listAbove.size());
if (getContentConfig().getDirectionOfThreshold() == ReportEngineEnum.DirectionOfThreshold.BELOW) {
result = String.valueOf(listBelow.size());
actaulDirection = listBelow.size() > listAbove.size() ? AssessmentReportAndWorkflowConstants.BELOW : AssessmentReportAndWorkflowConstants.ABOVE;
if (getContentConfig().getAction() == ReportEngineEnum.ExecutionActions.PERCENTAGE) {
result = String.valueOf(listBelow.size() * 100 / inferenceResults.size());
actaulDirection = (listBelow.size() * 100 / inferenceResults.size() > (listAbove.size() * 100) / inferenceResults.size()) ? AssessmentReportAndWorkflowConstants.BELOW : AssessmentReportAndWorkflowConstants.ABOVE;
}
resultValuesMap.put(AssessmentReportAndWorkflowConstants.ACTUALDIRECTION, actaulDirection);
} else if (getContentConfig().getDirectionOfThreshold() == ReportEngineEnum.DirectionOfThreshold.ABOVE) {
result = String.valueOf(listAbove.size());
actaulDirection = listAbove.size() > listBelow.size() ? AssessmentReportAndWorkflowConstants.ABOVE : AssessmentReportAndWorkflowConstants.BELOW;
if (getContentConfig().getAction() == ReportEngineEnum.ExecutionActions.PERCENTAGE) {
result = String.valueOf((listAbove.size() * 100) / inferenceResults.size());
actaulDirection = ((listAbove.size() * 100) / inferenceResults.size() > (listBelow.size() * 100) / inferenceResults.size()) ? AssessmentReportAndWorkflowConstants.ABOVE : AssessmentReportAndWorkflowConstants.BELOW;
}
resultValuesMap.put(AssessmentReportAndWorkflowConstants.ACTUALDIRECTION, actaulDirection);
}
ReportEngineEnum.KPISentiment sentiment = getContentConfig().getDirectionOfThreshold().name().equalsIgnoreCase(actaulDirection) ? ReportEngineEnum.KPISentiment.POSITIVE : ReportEngineEnum.KPISentiment.NEGATIVE;
resultValuesMap.put("result", result);
if (result.equalsIgnoreCase("0.0") || result.equalsIgnoreCase("0")) {
inferenceText = getContentText(ReportEngineUtils.NEUTRAL_MESSAGE_KEY, resultValuesMap);
} else {
inferenceText = getContentText(ReportEngineUtils.STANDARD_MESSAGE_KEY, resultValuesMap);
}
if (inferenceText != null) {
inferenceContentResult = setContentDetail(resultFirstData, resultValuesMap, sentiment, "", inferenceText);
} else {
log.debug("Worlflow Detail ==== inference text is null for count and percentage threshold KPIId {} contentId {} result {} ", getContentConfig().getKpiId(), getContentConfig().getContentId(), resultFirstData);
}
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(e);
log.error(" Errro while content processing for threshold KPIId {} contentId {} ", getContentConfig().getKpiId(), getContentConfig().getContentId());
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() + "Exception while running neo4j operation" + e.getMessage());
throw new InsightsJobFailedException("Exception while running neo4j operation {} " + e.getMessage());
}
return inferenceContentResult;
}
Aggregations