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());
}
}
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());
}
}
}
}
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;
}
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;
}
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());
}
}
Aggregations