Search in sources :

Example 1 with ReportConfigDAL

use of com.cognizant.devops.platformdal.assessmentreport.ReportConfigDAL in project Insights by CognizantOneDevOps.

the class ReportKPISubscriber method extractKPIAndContentRetryList.

private void extractKPIAndContentRetryList(JsonObject incomingTaskMessage, List<InsightsKPIConfig> kpiConfigList, List<Integer> contentList) {
    ReportConfigDAL reportConfigDAL = new ReportConfigDAL();
    InsightsWorkflowExecutionHistory historyConfig = workflowDAL.getWorkflowExecutionHistoryByHistoryId(incomingTaskMessage.get("exectionHistoryId").getAsInt());
    JsonObject statusLog = new Gson().fromJson(historyConfig.getStatusLog(), JsonObject.class);
    log.debug(" Worlflow Detail ====  extractKPIAndContentRetryList statusLog {}", statusLog);
    if (statusLog != null) {
        Type type = new TypeToken<List<Integer>>() {
        }.getType();
        Gson gson = new Gson();
        List<Integer> kpiList = gson.fromJson(statusLog.get("kpiList"), type);
        if (!kpiList.isEmpty()) {
            kpiConfigList.addAll(reportConfigDAL.getActiveKPIConfigurationsBasedOnKPIId(kpiList));
        }
        contentList.addAll(gson.fromJson(statusLog.get(AssessmentReportAndWorkflowConstants.CONTENT_ARRAY), type));
    } else {
        log.error("Worlflow Detail ==== ReportKPISubscriber unable to parse retry message ", statusLog);
    }
}
Also used : Type(java.lang.reflect.Type) ReportConfigDAL(com.cognizant.devops.platformdal.assessmentreport.ReportConfigDAL) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) ArrayList(java.util.ArrayList) List(java.util.List) InsightsWorkflowExecutionHistory(com.cognizant.devops.platformdal.workflow.InsightsWorkflowExecutionHistory)

Example 2 with ReportConfigDAL

use of com.cognizant.devops.platformdal.assessmentreport.ReportConfigDAL in project Insights by CognizantOneDevOps.

the class KPIExecutor method call.

@Override
public JsonObject call() throws Exception {
    JsonObject response = new JsonObject();
    JsonArray failedjobs = new JsonArray();
    int kpiId = ReportEngineEnum.StatusCode.ERROR.getValue();
    long startTime = System.nanoTime();
    try {
        kpiId = executeKPIJob(_kpiConfigDTO);
        log.debug("Type=TaskExecution  executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", _kpiConfigDTO.getExecutionId(), _kpiConfigDTO.getWorkflowId(), _kpiConfigDTO.getReportId(), "-", _kpiConfigDTO.getKpiId(), _kpiConfigDTO.getCategory(), 0, "usecasename: " + _kpiConfigDTO.getUsecaseName() + "schedule: " + _kpiConfigDTO.getSchedule());
    } catch (InsightsJobFailedException e) {
        response.addProperty(STATUS, "Failure");
        failedjobs.add(_kpiConfigDTO.getKpiId());
        response.add("kpiArray", failedjobs);
        log.debug("Type=TaskExecution  executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", _kpiConfigDTO.getExecutionId(), _kpiConfigDTO.getWorkflowId(), _kpiConfigDTO.getReportId(), "-", _kpiConfigDTO.getKpiId(), _kpiConfigDTO.getCategory(), 0, "usecasename: " + _kpiConfigDTO.getUsecaseName() + "schedule: " + _kpiConfigDTO.getSchedule());
    }
    if (kpiId != ReportEngineEnum.StatusCode.ERROR.getValue()) {
        ReportConfigDAL reportConfigAL = new ReportConfigDAL();
        List<InsightsContentConfig> contentConfigList = reportConfigAL.getActiveContentConfigByKPIId(_kpiConfigDTO.getKpiId());
        if (!contentConfigList.isEmpty()) {
            /* Execute content on the same thread */
            failedjobs = ContentExecutor.executeContentJob(contentConfigList, _kpiConfigDTO);
        }
        /* If none of the kpi or content is failed then simply return Status as success */
        if (failedjobs.size() > 0) {
            response.addProperty(STATUS, "Failure");
            response.add("contentArray", failedjobs);
        } else {
            response.addProperty(STATUS, "Success");
        }
        long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
        log.debug("Type=TaskExecution  executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", _kpiConfigDTO.getExecutionId(), _kpiConfigDTO.getWorkflowId(), _kpiConfigDTO.getReportId(), "-", _kpiConfigDTO.getKpiId(), _kpiConfigDTO.getCategory(), processingTime, "usecasename: " + _kpiConfigDTO.getUsecaseName() + " schedule: " + _kpiConfigDTO.getSchedule());
    }
    return response;
}
Also used : JsonArray(com.google.gson.JsonArray) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsContentConfig(com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig) ReportConfigDAL(com.cognizant.devops.platformdal.assessmentreport.ReportConfigDAL) JsonObject(com.google.gson.JsonObject)

Aggregations

ReportConfigDAL (com.cognizant.devops.platformdal.assessmentreport.ReportConfigDAL)2 JsonObject (com.google.gson.JsonObject)2 InsightsContentConfig (com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig)1 InsightsWorkflowExecutionHistory (com.cognizant.devops.platformdal.workflow.InsightsWorkflowExecutionHistory)1 InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)1 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1