Search in sources :

Example 1 with InsightsKPIResultDetails

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails in project Insights by CognizantOneDevOps.

the class ComparisonContentCategoryImpl method generateContent.

/**
 * Generate comparision content text using KPI result
 */
@Override
public void generateContent() {
    long startTime = System.nanoTime();
    List<InsightsKPIResultDetails> kpiResults = getKPIExecutionResult();
    InsightsContentDetail contentResult = null;
    if (!kpiResults.isEmpty()) {
        contentResult = getContentFromResult(kpiResults);
    } else {
        contentResult = setNeutralContentDetail();
        log.debug("Worlflow Detail ====   No kpi result found for kpi Id {} ContentId {} ", contentConfigDefinition.getKpiId(), contentConfigDefinition.getContentId());
    }
    if (contentResult != null) {
        log.debug("Worlflow Detail ====  contentid {}  kpi {} contentResultText  + {} ", contentConfigDefinition.getCategory(), contentConfigDefinition.getKpiId(), contentResult.getInferenceText());
        saveContentResult(contentResult);
        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());
    }
}
Also used : InsightsKPIResultDetails(com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails) InsightsContentDetail(com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)

Example 2 with InsightsKPIResultDetails

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails in project Insights by CognizantOneDevOps.

the class ReportGraphDataHandler method creatingResultDetailFromGraphResponce.

public void creatingResultDetailFromGraphResponce(List<InsightsKPIResultDetails> kpiDetailList, ContentConfigDefinition contentConfigDefinition, JsonObject graphResp) {
    JsonArray graphJsonResult = graphResp.getAsJsonArray(AssessmentReportAndWorkflowConstants.RESULTS);
    log.debug("Worlflow Detail ====  KPI Id {}  record return by key query ==== {}", contentConfigDefinition.getKpiId(), graphResp.getAsJsonArray("results").size());
    JsonArray data = graphJsonResult.get(0).getAsJsonObject().getAsJsonArray("data");
    for (int dataIndex = 0; dataIndex < data.size(); dataIndex++) {
        JsonArray rowData = data.get(dataIndex).getAsJsonObject().getAsJsonArray("row");
        for (int rowDataIndex = 0; rowDataIndex < rowData.size(); rowDataIndex++) {
            try {
                JsonObject row = rowData.get(rowDataIndex).getAsJsonObject();
                InsightsKPIResultDetails resultMapping = gson.fromJson(row, InsightsKPIResultDetails.class);
                JsonArray columnProperty = row.get(ReportEngineUtils.COLUMN_PROPERTY).getAsJsonArray();
                Map<String, Object> results = new HashMap<>();
                for (int i = 0; i < columnProperty.size(); i++) {
                    String columnName = columnProperty.get(i).getAsString();
                    if (row.get(columnName) != null) {
                        Object result = ReportEngineUtils.getJsonValue(row.get(columnName));
                        results.put(columnName, result);
                    } else {
                        log.error(" null value found for {} ", columnName);
                    }
                }
                resultMapping.setResults(results);
                kpiDetailList.add(resultMapping);
            } catch (Exception e) {
                log.error(" Error while parsing kpi result  ", e);
                throw new InsightsJobFailedException(" Error while parsing kpi result  " + e.getMessage());
            }
        }
    }
}
Also used : JsonArray(com.google.gson.JsonArray) InsightsKPIResultDetails(com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 3 with InsightsKPIResultDetails

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails in project Insights by CognizantOneDevOps.

the class ThresholdRangeCategoryImpl method countAndPercentageInferenceResult.

/**
 * Process KPI result to create content text using count and precentage method
 *
 * @param inferenceResults
 * @return
 */
private InsightsContentDetail countAndPercentageInferenceResult(List<InsightsKPIResultDetails> inferenceResults) {
    InsightsContentDetail inferenceContentResult = null;
    if (contentConfigDefinition.getThresholds() != null) {
        try {
            long startTime = System.nanoTime();
            InsightsKPIResultDetails resultDetailObj = inferenceResults.get(0);
            Map<String, Object> zoneWiseCountWithSentiment = getZoneWiseCountWithSentiment(inferenceResults);
            Map<String, Object> resultValuesMap = new HashMap<>();
            int redZone = (int) zoneWiseCountWithSentiment.get("redZone");
            int amberZone = (int) zoneWiseCountWithSentiment.get("amberZone");
            int greenZone = (int) zoneWiseCountWithSentiment.get("greenZone");
            ReportEngineEnum.KPISentiment sentiment = (ReportEngineEnum.KPISentiment) zoneWiseCountWithSentiment.get("sentiment");
            String zone = (String) zoneWiseCountWithSentiment.get("zone");
            int result = (int) zoneWiseCountWithSentiment.get(AssessmentReportAndWorkflowConstants.RESULT);
            if (getContentConfig().getAction() == ReportEngineEnum.ExecutionActions.PERCENTAGE) {
                int totalSize = inferenceResults.size();
                resultValuesMap.put("red", ((redZone * 100) / totalSize) + "%");
                resultValuesMap.put(AssessmentReportAndWorkflowConstants.AMBER, ((amberZone * 100) / totalSize) + "%");
                resultValuesMap.put(AssessmentReportAndWorkflowConstants.GREEN, ((greenZone * 100) / totalSize) + "%");
                resultValuesMap.put("zone", zone);
                resultValuesMap.put(AssessmentReportAndWorkflowConstants.RESULT, result);
                addTimeValueinResult(resultValuesMap, contentConfigDefinition.getSchedule());
            } else {
                resultValuesMap.put("red", redZone);
                resultValuesMap.put(AssessmentReportAndWorkflowConstants.AMBER, amberZone);
                resultValuesMap.put(AssessmentReportAndWorkflowConstants.GREEN, greenZone);
                resultValuesMap.put("zone", zone);
                resultValuesMap.put(AssessmentReportAndWorkflowConstants.RESULT, result);
                addTimeValueinResult(resultValuesMap, contentConfigDefinition.getSchedule());
            }
            String inferenceText = getContentText(ReportEngineUtils.STANDARD_MESSAGE_KEY, resultValuesMap);
            if (inferenceText != null) {
                inferenceContentResult = setContentDetail(resultDetailObj, resultValuesMap, sentiment, "", inferenceText);
            } else {
                log.debug(" inference text is null for count And Percentage threshold-range KPIId {} contentId {} result {} ", getContentConfig().getKpiId(), getContentConfig().getContentId(), resultDetailObj);
            }
            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 threshold-range countAndPercentageInferenceResult 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() + " Error while content processing for threshold-range" + e.getMessage());
            throw new InsightsJobFailedException(" Error while content processing for threshold-range KPIId {} contentId {}");
        }
    } else {
        log.error(" Errro while content processing for threshold-range 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() + " Error while content processing for threshold-range");
    }
    return inferenceContentResult;
}
Also used : HashMap(java.util.HashMap) 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) JsonObject(com.google.gson.JsonObject) InsightsContentDetail(com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)

Example 4 with InsightsKPIResultDetails

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails in project Insights by CognizantOneDevOps.

the class ThresholdRangeCategoryImpl method getZoneWiseCountWithSentiment.

/**
 * Process KPI result and divide it based on Zone or Range
 *
 * @param inferenceResults
 * @return
 */
private Map<String, Object> getZoneWiseCountWithSentiment(List<InsightsKPIResultDetails> inferenceResults) {
    int redZone = 0;
    int amberZone = 0;
    int greenZone = 0;
    String zone = AssessmentReportAndWorkflowConstants.GREEN;
    ReportEngineEnum.KPISentiment sentiment = ReportEngineEnum.KPISentiment.NEUTRAL;
    HashMap<String, Integer> zonesMap = new HashMap<>();
    String comparisonField = getResultFieldFromContentDefination();
    JsonObject thresholdObjs = JsonUtils.parseStringAsJsonObject(String.valueOf(contentConfigDefinition.getThresholds()));
    double amberThreshold = thresholdObjs.get(AssessmentReportAndWorkflowConstants.AMBER).getAsDouble();
    double greenThreshold = thresholdObjs.get(AssessmentReportAndWorkflowConstants.GREEN).getAsDouble();
    if (contentConfigDefinition.getDirectionOfThreshold() == ReportEngineEnum.DirectionOfThreshold.BELOW) {
        for (InsightsKPIResultDetails resultObj : inferenceResults) {
            double val = (double) resultObj.getResults().get(comparisonField);
            if (val <= greenThreshold) {
                greenZone++;
            } else if (val <= amberThreshold) {
                amberZone++;
            } else {
                redZone++;
            }
        }
        zonesMap.put(AssessmentReportAndWorkflowConstants.GREEN, greenZone);
        zonesMap.put(AssessmentReportAndWorkflowConstants.AMBER, amberZone);
        zonesMap.put("red", redZone);
        zone = Collections.min(zonesMap.keySet());
        sentiment = getThresholdRangeSentiment(redZone, amberZone, greenZone, contentConfigDefinition.getDirectionOfThreshold());
    } else {
        for (InsightsKPIResultDetails resultObj : inferenceResults) {
            double val = (double) resultObj.getResults().get(comparisonField);
            if (val >= greenThreshold) {
                greenZone++;
            } else if (val >= amberThreshold) {
                amberZone++;
            } else {
                redZone++;
            }
        }
        zonesMap.put(AssessmentReportAndWorkflowConstants.GREEN, greenZone);
        zonesMap.put(AssessmentReportAndWorkflowConstants.AMBER, amberZone);
        zonesMap.put("red", redZone);
        zone = Collections.max(zonesMap.keySet());
        sentiment = getThresholdRangeSentiment(redZone, amberZone, greenZone, contentConfigDefinition.getDirectionOfThreshold());
    }
    Map<String, Object> zoneWiseCount = new HashMap<>();
    zoneWiseCount.put("greenZone", zonesMap.get(AssessmentReportAndWorkflowConstants.GREEN));
    zoneWiseCount.put("amberZone", zonesMap.get(AssessmentReportAndWorkflowConstants.AMBER));
    zoneWiseCount.put("redZone", zonesMap.get("red"));
    zoneWiseCount.put("sentiment", sentiment);
    zoneWiseCount.put("zone", zone);
    zoneWiseCount.put(AssessmentReportAndWorkflowConstants.RESULT, getZoneResultValue(zone));
    return zoneWiseCount;
}
Also used : InsightsKPIResultDetails(com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails) HashMap(java.util.HashMap) ReportEngineEnum(com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum) JsonObject(com.google.gson.JsonObject) JsonObject(com.google.gson.JsonObject)

Example 5 with InsightsKPIResultDetails

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails in project Insights by CognizantOneDevOps.

the class TrendCategoryImpl method generateContent.

/**
 * Generate Trend content text using KPI result
 */
@Override
public void generateContent() {
    long startTime = System.nanoTime();
    List<InsightsKPIResultDetails> inferenceResults = getKPIExecutionResult();
    InsightsContentDetail contentResult = null;
    if (!inferenceResults.isEmpty()) {
        contentResult = getContentFromResult(inferenceResults);
    } else {
        contentResult = setNeutralContentDetail();
        log.debug("Worlflow Detail ====   No kpi result found for kpi Id {} ContentId {} ", contentConfigDefinition.getKpiId(), contentConfigDefinition.getContentId());
    }
    if (contentResult != null) {
        log.debug("Worlflow Detail ====  contentid {}  kpi {} contentResultText  + {} ", contentConfigDefinition.getCategory(), contentConfigDefinition.getKpiId(), contentResult.getInferenceText());
        saveContentResult(contentResult);
        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());
    }
}
Also used : InsightsKPIResultDetails(com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails) InsightsContentDetail(com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)

Aggregations

InsightsKPIResultDetails (com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails)16 InsightsContentDetail (com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)13 InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)10 HashMap (java.util.HashMap)10 ReportEngineEnum (com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum)9 WorkflowSchedule (com.cognizant.devops.platformcommons.core.enums.WorkflowTaskEnum.WorkflowSchedule)4 ContentConfigDefinition (com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition)4 ReportEngineUtils (com.cognizant.devops.platformreports.assessment.util.ReportEngineUtils)4 JsonObject (com.google.gson.JsonObject)4 List (java.util.List)4 Map (java.util.Map)4 TimeUnit (java.util.concurrent.TimeUnit)4 LogManager (org.apache.logging.log4j.LogManager)4 Logger (org.apache.logging.log4j.Logger)4 InsightsCustomException (com.cognizant.devops.platformcommons.exception.InsightsCustomException)3 InsightsUtils (com.cognizant.devops.platformcommons.core.util.InsightsUtils)2 JsonArray (com.google.gson.JsonArray)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2