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