Search in sources :

Example 11 with InsightsContentConfig

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

the class WorkflowTestData method saveContentDefinition.

public int saveContentDefinition(String contentDefinition) throws InsightsCustomException {
    int contentId = -1;
    try {
        InsightsContentConfig contentConfig = new InsightsContentConfig();
        JsonObject contentJson = JsonUtils.parseStringAsJsonObject(contentDefinition);
        Gson gson = new Gson();
        int kpiId = contentJson.get("kpiId").getAsInt();
        contentId = contentJson.get("contentId").getAsInt();
        InsightsContentConfig existingContentConfig = reportConfigDAL.getContentConfig(contentId);
        if (existingContentConfig == null) {
            boolean contentisActive = contentJson.get("isActive").getAsBoolean();
            String contentName = contentJson.get("contentName").getAsString();
            String contentString = gson.toJson(contentJson);
            contentConfig.setContentId(contentId);
            InsightsKPIConfig kpiConfig = reportConfigDAL.getKPIConfig(kpiId);
            String contentCategory = kpiConfig.getCategory();
            contentConfig.setKpiConfig(kpiConfig);
            contentConfig.setActive(contentisActive);
            contentConfig.setContentJson(contentString);
            contentConfig.setContentName(contentName);
            contentConfig.setCategory(contentCategory);
            reportConfigDAL.saveContentConfig(contentConfig);
        }
    } catch (Exception e) {
        log.error(e);
    }
    return contentId;
}
Also used : InsightsContentConfig(com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig) InsightsKPIConfig(com.cognizant.devops.platformdal.assessmentreport.InsightsKPIConfig) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) AddressException(javax.mail.internet.AddressException) InsightsCustomException(com.cognizant.devops.platformcommons.exception.InsightsCustomException)

Example 12 with InsightsContentConfig

use of com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig 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 13 with InsightsContentConfig

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

the class AssessmentReportsTest method testRetryContentExecute.

@Test(priority = 8)
public void testRetryContentExecute() throws InterruptedException {
    try {
        InsightsContentConfig existingContentConfig = reportConfigDAL.getContentConfig(20013131);
        existingContentConfig.setCategory("COMPARISON");
        reportConfigDAL.updateContentConfig(existingContentConfig);
        WorkflowRetryExecutor executorRetry = new WorkflowRetryExecutor();
        executorRetry.retryWorkflowWithFailedTask();
        Thread.sleep(20000);
    } catch (AssertionError e) {
        Assert.fail(e.getMessage());
    }
}
Also used : InsightsContentConfig(com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig) WorkflowRetryExecutor(com.cognizant.devops.platformworkflow.workflowtask.core.WorkflowRetryExecutor) Test(org.testng.annotations.Test)

Aggregations

InsightsContentConfig (com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig)13 InsightsCustomException (com.cognizant.devops.platformcommons.exception.InsightsCustomException)7 InsightsKPIConfig (com.cognizant.devops.platformdal.assessmentreport.InsightsKPIConfig)6 IOException (java.io.IOException)6 FileNotFoundException (java.io.FileNotFoundException)5 NoResultException (javax.persistence.NoResultException)5 Gson (com.google.gson.Gson)4 JsonObject (com.google.gson.JsonObject)4 InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)3 JsonArray (com.google.gson.JsonArray)3 ReportPostgresDataHandler (com.cognizant.devops.platformreports.assessment.dal.ReportPostgresDataHandler)2 ContentConfigDefinition (com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition)2 ArrayList (java.util.ArrayList)2 Test (org.testng.annotations.Test)2 AgentConfig (com.cognizant.devops.platformdal.agentConfig.AgentConfig)1 InsightsAssessmentReportTemplate (com.cognizant.devops.platformdal.assessmentreport.InsightsAssessmentReportTemplate)1 InsightsReportTemplateConfigFiles (com.cognizant.devops.platformdal.assessmentreport.InsightsReportTemplateConfigFiles)1 InsightsReportVisualizationContainer (com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer)1 InsightsReportsKPIConfig (com.cognizant.devops.platformdal.assessmentreport.InsightsReportsKPIConfig)1 ReportConfigDAL (com.cognizant.devops.platformdal.assessmentreport.ReportConfigDAL)1