Search in sources :

Example 1 with InsightsContentDetail

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

the class BaseContentCategoryImpl method setContentDetail.

/**
 * Method is convert content model to entity model, further this entity model
 * store in database
 *
 * @param inferenceResult
 * @param resultValuesMap
 * @param sentiment
 * @param actualTrend
 * @param inferenceText
 * @return
 */
public InsightsContentDetail setContentDetail(InsightsKPIResultDetails inferenceResult, Map<String, Object> resultValuesMap, ReportEngineEnum.KPISentiment sentiment, String actualTrend, String inferenceText) {
    InsightsContentDetail detail = new InsightsContentDetail();
    detail.setCategory(contentConfigDefinition.getCategory());
    detail.setActualTrend(actualTrend);
    detail.setExpectedTrend(contentConfigDefinition.getExpectedTrend());
    detail.setContentId(contentConfigDefinition.getContentId());
    detail.setInferenceText(inferenceText);
    detail.setKpiId(inferenceResult.getKpiId());
    detail.setKpiName(inferenceResult.getKpiName());
    detail.setNoOfResult(contentConfigDefinition.getNoOfResult());
    // ranking
    detail.setRanking(null);
    detail.setResultField(contentConfigDefinition.getResultField());
    detail.setResultTime(inferenceResult.getResultTime());
    detail.setResultTimeX(inferenceResult.getResultTimeX());
    detail.setResultValuesMap(resultValuesMap);
    detail.setSchedule(inferenceResult.getSchedule());
    detail.setSentiment(sentiment);
    detail.setThreshold(contentConfigDefinition.getThreshold());
    detail.setToolName(inferenceResult.getToolname());
    // trendline
    detail.setTrendline(null);
    detail.setGroup(inferenceResult.getGroupName());
    detail.setExecutionId(contentConfigDefinition.getExecutionId());
    detail.setReportId(contentConfigDefinition.getReportId());
    detail.setAssessmentId(contentConfigDefinition.getAssessmentId());
    detail.setAssessmentReportName(contentConfigDefinition.getAssessmentReportName());
    return detail;
}
Also used : InsightsContentDetail(com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)

Example 2 with InsightsContentDetail

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail 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 3 with InsightsContentDetail

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail 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 InsightsContentDetail

use of com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail 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)

Example 5 with InsightsContentDetail

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

the class TrendCategoryImpl method averageTrendResult.

/**
 * Process KPI result to create content text using average method
 *
 * @param inferenceResults
 * @return
 */
private InsightsContentDetail averageTrendResult(List<InsightsKPIResultDetails> inferenceResults) {
    Map<String, Object> resultValuesMap = new HashMap<>();
    InsightsContentDetail inferenceContentResult = null;
    try {
        long startTime = System.nanoTime();
        String comparisonField = getResultFieldFromContentDefination();
        InsightsKPIResultDetails resultDetailObj = inferenceResults.get(0);
        ReportEngineEnum.KPISentiment sentiment = ReportEngineEnum.KPISentiment.NEUTRAL;
        double resultValue = inferenceResults.stream().mapToDouble((result -> (Double) result.getResults().get(comparisonField))).average().getAsDouble();
        resultValuesMap.put("result", resultValue);
        addTimeValueinResult(resultValuesMap, contentConfigDefinition.getSchedule());
        inferenceContentResult = prepareContentMessageAndResult(inferenceContentResult, resultValuesMap, resultValue, sentiment, 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(" Errro while content processing for average trend 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 : ContentConfigDefinition(com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition) HashMap(java.util.HashMap) WorkflowSchedule(com.cognizant.devops.platformcommons.core.enums.WorkflowTaskEnum.WorkflowSchedule) 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) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) ReportEngineUtils(com.cognizant.devops.platformreports.assessment.util.ReportEngineUtils) LogManager(org.apache.logging.log4j.LogManager) ReportEngineEnum(com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum) HashMap(java.util.HashMap) ReportEngineEnum(com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException) InsightsKPIResultDetails(com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsContentDetail(com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)

Aggregations

InsightsContentDetail (com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)15 InsightsKPIResultDetails (com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails)13 InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)9 ReportEngineEnum (com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum)8 HashMap (java.util.HashMap)8 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 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 JsonObject (com.google.gson.JsonObject)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Comparator (java.util.Comparator)2 AssessmentReportAndWorkflowConstants (com.cognizant.devops.platformcommons.constants.AssessmentReportAndWorkflowConstants)1