use of com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig in project Insights by CognizantOneDevOps.
the class ReportKPISubscriber method executeContent.
private void executeContent(List<Integer> contentList, List<JsonObject> failedJobs) throws InterruptedException, ExecutionException {
List<Callable<Integer>> contentListToExecute = new ArrayList<>();
ReportPostgresDataHandler contentProcessing = new ReportPostgresDataHandler();
int assessmentId = workflowConfig.getAssessmentConfig().getId();
String assessmentReportName = workflowConfig.getAssessmentConfig().getAsseementreportname();
int reportTemplateId = workflowConfig.getAssessmentConfig().getReportTemplateEntity().getReportId();
for (int contentId : contentList) {
InsightsContentConfig contentConfig = contentProcessing.getContentConfig(contentId);
ContentConfigDefinition contentConfigDefinition = contentProcessing.convertJsonToContentConfig(contentConfig);
log.debug("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());
if (contentConfigDefinition != null) {
contentConfigDefinition.setExecutionId(executionId);
contentConfigDefinition.setSchedule(WorkflowTaskEnum.WorkflowSchedule.valueOf(workflowConfig.getScheduleType()));
contentConfigDefinition.setWorkflowId(workflowConfig.getWorkflowId());
contentConfigDefinition.setReportId(reportTemplateId);
contentConfigDefinition.setAssessmentId(assessmentId);
contentConfigDefinition.setAssessmentReportName(assessmentReportName);
contentListToExecute.add(new ContentExecutor(contentConfigDefinition));
} else {
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() + " Content execution failed");
throw new InsightsJobFailedException("Content execution failed");
}
}
/* segregate entire content execution list into defined chunks */
List<List<Callable<Integer>>> contentChunkList = WorkflowThreadPool.getChunk(contentListToExecute, 3);
/* submit each chunk to threadpool in a loop */
executeContentChunks(contentChunkList, failedJobs);
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig in project Insights by CognizantOneDevOps.
the class AssesmentReportServiceImpl method saveContentDefinition.
/**
* Used to store individual content definition
*
* @param registerContentJson
* @return
* @throws InsightsCustomException
*/
public int saveContentDefinition(JsonObject registerContentJson) throws InsightsCustomException {
int contentId = -1;
Gson gson = new Gson();
try {
InsightsContentConfig contentConfig = new InsightsContentConfig();
int kpiId = registerContentJson.get(AssessmentReportAndWorkflowConstants.KPIID).getAsInt();
contentId = registerContentJson.get(AssessmentReportAndWorkflowConstants.CONTENTID).getAsInt();
boolean isActive = registerContentJson.get(AssessmentReportAndWorkflowConstants.ISACTIVE).getAsBoolean();
String contentName = registerContentJson.get(AssessmentReportAndWorkflowConstants.CONTENT_NAME).getAsString();
String contentString = gson.toJson(registerContentJson);
contentConfig.setContentId(contentId);
InsightsKPIConfig kpiConfig = reportConfigDAL.getKPIConfig(kpiId);
if (kpiConfig == null) {
throw new InsightsCustomException("KPI not exists");
}
InsightsContentConfig contentDBConfig = reportConfigDAL.getContentConfig(contentId);
if (contentDBConfig != null) {
throw new InsightsCustomException("Content Definition already exists");
}
String category = kpiConfig.getCategory();
contentConfig.setKpiConfig(kpiConfig);
contentConfig.setActive(isActive);
contentConfig.setContentJson(contentString);
contentConfig.setContentName(contentName);
contentConfig.setCategory(category);
reportConfigDAL.saveContentConfig(contentConfig);
} catch (Exception e) {
log.error(e);
throw new InsightsCustomException(e.getMessage());
}
return contentId;
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig in project Insights by CognizantOneDevOps.
the class AssesmentReportServiceImpl method updateContentDefinition.
/**
* Used to store update content definition
*
* @param registerContentJson
* @return
* @throws InsightsCustomException
*/
public int updateContentDefinition(JsonObject updateContentJson) throws InsightsCustomException {
int contentId = -1;
Gson gson = new Gson();
try {
InsightsContentConfig contentConfig = new InsightsContentConfig();
int kpiId = updateContentJson.get(AssessmentReportAndWorkflowConstants.KPIID).getAsInt();
contentId = updateContentJson.get(AssessmentReportAndWorkflowConstants.CONTENTID).getAsInt();
boolean isActive = updateContentJson.get(AssessmentReportAndWorkflowConstants.ISACTIVE).getAsBoolean();
String contentName = updateContentJson.get(AssessmentReportAndWorkflowConstants.CONTENT_NAME).getAsString();
String contentString = gson.toJson(updateContentJson);
contentConfig.setContentId(contentId);
InsightsKPIConfig kpiConfig = reportConfigDAL.getKPIConfig(kpiId);
if (kpiConfig == null) {
throw new InsightsCustomException("KPI defination not exists");
}
InsightsContentConfig contentDBConfig = reportConfigDAL.getContentConfig(contentId);
if (contentDBConfig == null) {
throw new InsightsCustomException("Content Definition does not exists");
} else {
String category = kpiConfig.getCategory();
contentDBConfig.setKpiConfig(kpiConfig);
contentDBConfig.setActive(isActive);
contentDBConfig.setContentJson(contentString);
contentDBConfig.setContentName(contentName);
contentDBConfig.setCategory(category);
reportConfigDAL.updateContentConfig(contentDBConfig);
}
} catch (Exception e) {
log.error(e);
throw new InsightsCustomException(e.getMessage());
}
return contentId;
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig in project Insights by CognizantOneDevOps.
the class AssesmentReportServiceImpl method deleteContentDefinition.
/**
* Used to delete individual Content definition
*
* @param registerkpiJson
* @return
* @throws InsightsCustomException
*/
public boolean deleteContentDefinition(JsonObject deleteContentJson) throws InsightsCustomException {
int contentId = -1;
boolean isRecordDeleted = Boolean.FALSE;
try {
contentId = deleteContentJson.get(AssessmentReportAndWorkflowConstants.CONTENTID).getAsInt();
InsightsContentConfig contentExistingConfig = reportConfigDAL.getContentConfig(contentId);
if (contentExistingConfig == null) {
throw new InsightsCustomException("Content definition not exists");
} else {
List<InsightsReportsKPIConfig> reportKPIList = reportConfigDAL.getActiveReportTemplateByKPIId(contentExistingConfig.getKpiConfig().getId());
if (reportKPIList.isEmpty()) {
reportConfigDAL.deleteContentbyContentID(contentId);
isRecordDeleted = Boolean.TRUE;
} else {
throw new InsightsCustomException("Content definition attached to report template");
}
}
} catch (Exception e) {
log.error(e);
throw new InsightsCustomException(e.getMessage());
}
return isRecordDeleted;
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig in project Insights by CognizantOneDevOps.
the class AssesmentReportServiceImpl method getAllActiveContentList.
/**
* API use to return all active Content list
*
* @return
* @throws InsightsCustomException
*/
public List<JsonObject> getAllActiveContentList() throws InsightsCustomException {
List<InsightsContentConfig> kpiconfigList = new ArrayList<>();
List<JsonObject> contentCustomList = new ArrayList<>();
try {
kpiconfigList = reportConfigDAL.getAllActiveContentList();
kpiconfigList.stream().forEach(contentDBData -> {
JsonObject contentData = JsonUtils.parseStringAsJsonObject(contentDBData.getContentJson());
contentData.addProperty("kpiName", contentDBData.getKpiConfig().getKpiName());
contentData.addProperty("contentId", contentDBData.getContentId());
contentData.addProperty("contentName", contentDBData.getContentName());
contentData.addProperty("kpiId", contentDBData.getKpiConfig().getKpiId());
contentData.addProperty("category", contentDBData.getKpiConfig().getCategory());
contentCustomList.add(contentData);
});
return contentCustomList;
} catch (Exception e) {
log.error("Error getting all kpiList...", e);
throw new InsightsCustomException(e.toString());
}
}
Aggregations