Search in sources :

Example 51 with InsightsJobFailedException

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());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException)

Example 52 with InsightsJobFailedException

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");
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsReportVisualizationContainer(com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer) JsonObject(com.google.gson.JsonObject) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException)

Example 53 with InsightsJobFailedException

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;
}
Also used : JsonArray(com.google.gson.JsonArray) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsContentConfig(com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig) ReportPostgresDataHandler(com.cognizant.devops.platformreports.assessment.dal.ReportPostgresDataHandler) ContentConfigDefinition(com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition)

Example 54 with InsightsJobFailedException

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;
}
Also used : ContentConfigDefinition(com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition) HashMap(java.util.HashMap) WorkflowSchedule(com.cognizant.devops.platformcommons.core.enums.WorkflowTaskEnum.WorkflowSchedule) InsightsUtils(com.cognizant.devops.platformcommons.core.util.InsightsUtils) InsightsContentDetail(com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail) TimeUnit(java.util.concurrent.TimeUnit) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) List(java.util.List) Logger(org.apache.logging.log4j.Logger) InsightsKPIResultDetails(com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails) Map(java.util.Map) Comparator(java.util.Comparator) ReportEngineUtils(com.cognizant.devops.platformreports.assessment.util.ReportEngineUtils) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) ReportEngineEnum(com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum) InsightsKPIResultDetails(com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) HashMap(java.util.HashMap) ReportEngineEnum(com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsContentDetail(com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)

Example 55 with InsightsJobFailedException

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ReportEngineEnum(com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsKPIResultDetails(com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsContentDetail(com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)

Aggregations

InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)63 IOException (java.io.IOException)31 JsonObject (com.google.gson.JsonObject)29 InsightsCustomException (com.cognizant.devops.platformcommons.exception.InsightsCustomException)21 ArrayList (java.util.ArrayList)16 File (java.io.File)14 JsonArray (com.google.gson.JsonArray)12 HashMap (java.util.HashMap)11 InsightsKPIResultDetails (com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails)8 List (java.util.List)8 InsightsContentDetail (com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)7 ReportEngineEnum (com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum)7 ExecutionException (java.util.concurrent.ExecutionException)7 ContentConfigDefinition (com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition)6 InsightsAssessmentConfigurationDTO (com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO)5 FileNotFoundException (java.io.FileNotFoundException)5 NoSuchFileException (java.nio.file.NoSuchFileException)5 Map (java.util.Map)5 InsightsContentConfig (com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig)4 InsightsReportVisualizationContainer (com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer)4