use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class LedgerPDFChartHandler method generatePDF.
@Override
public void generatePDF(InsightsAssessmentConfigurationDTO assessmentReportDTO) {
try {
createPDFDirectory(assessmentReportDTO);
prepareAndExportPDFFile(assessmentReportDTO);
} catch (Exception e) {
log.error(e);
throw new InsightsJobFailedException(e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class LedgerPDFChartHandler method createPDFDirectory.
private void createPDFDirectory(InsightsAssessmentConfigurationDTO assessmentReportDTO) {
try {
String folderName = assessmentReportDTO.getAsseementreportname() + "_" + assessmentReportDTO.getExecutionId();
assessmentReportDTO.setPdfReportFolderName(folderName);
String reportExecutionFile = AssessmentReportAndWorkflowConstants.REPORT_PDF_EXECUTION_RESOLVED_PATH + folderName;
assessmentReportDTO.setPdfReportDirPath(reportExecutionFile);
File reportExecutionFolder = new File(reportExecutionFile);
reportExecutionFolder.mkdir();
} catch (Exception e) {
log.error(e);
throw new InsightsJobFailedException("Unable to create pdf execution directory, message == {} " + e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class OpenPDFChartHandler method prepareAndExportPDFFile.
private void prepareAndExportPDFFile(InsightsAssessmentConfigurationDTO assessmentReportDTO) {
try {
long startTime = System.nanoTime();
Set<String> headerList = new LinkedHashSet<>();
List<String> rowValueList = new ArrayList<>();
JsonArray kpiResultArray = assessmentReportDTO.getVisualizationResult();
log.debug("Workflow Detail ==== kpiResultArray {} ", kpiResultArray);
JsonArray kpiVisualizationArray = kpiResultArray.get(0).getAsJsonObject().get("visualizationresult").getAsJsonArray();
log.debug("Workflow Detail ==== kpiVisualizationArray {} ", kpiVisualizationArray);
JsonArray fromkpiResultArray = kpiVisualizationArray.get(0).getAsJsonObject().get("KpiResult").getAsJsonArray();
JsonArray dataArray = fromkpiResultArray.get(0).getAsJsonObject().get("data").getAsJsonArray();
JsonArray columnArray = fromkpiResultArray.get(0).getAsJsonObject().get("columns").getAsJsonArray();
for (JsonElement elements : dataArray) {
JsonArray rowArray = elements.getAsJsonObject().get("row").getAsJsonArray();
String rowValue = StringUtils.join(rowArray, ',');
rowValueList.add(rowValue.replaceAll("\"", ""));
}
headerList.add("SNo");
for (JsonElement elements : columnArray) {
headerList.add(elements.getAsString().replace("\"", ""));
}
exportPDFFile(headerList, rowValueList, assessmentReportDTO);
long processingTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime);
log.debug("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), "-", "-", "-", processingTime, "Preparedpdf data");
} catch (Exception e) {
log.error("Workflow Detail ==== error while processing pdf data ", e);
log.error("Type=TaskExecution executionId={} workflowId={} ConfigId={} WorkflowType={} KpiId={} Category={} ProcessingTime={} message={}", assessmentReportDTO.getExecutionId(), assessmentReportDTO.getWorkflowId(), assessmentReportDTO.getConfigId(), "-", "-", "-", 0, "unable to prepare pdf data" + e.getMessage());
throw new InsightsJobFailedException(" unable to prepare pdf data " + e);
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class OpenPDFChartHandler method exportPDFFile.
private void exportPDFFile(Set<String> headerList, List<String> rowValueList, InsightsAssessmentConfigurationDTO assessmentReportDTO) {
try {
String exportedFilePath = assessmentReportDTO.getPdfReportDirPath() + File.separator + assessmentReportDTO.getAsseementreportname() + "." + ReportEngineUtils.REPORT_TYPE;
assessmentReportDTO.setPdfExportedFilePath(exportedFilePath);
PdfTableUtil pdfTableUtil = new PdfTableUtil();
byte[] pdfResponse = pdfTableUtil.generateCypherReport(headerList, rowValueList, URLEncoder.encode(assessmentReportDTO.getAsseementreportname() + ".pdf", "UTF-8"));
File extractedPdfFile = new File(exportedFilePath);
savePDFFile(extractedPdfFile, pdfResponse);
log.debug("Workflow Detail ==== pdf File Saved {} ", exportedFilePath);
} catch (Exception e) {
log.error("Workflow Detail ==== Error while exporting pdf ", e);
throw new InsightsJobFailedException(e.getMessage());
}
}
use of com.cognizant.devops.platformreports.exception.InsightsJobFailedException in project Insights by CognizantOneDevOps.
the class OpenPDFChartHandler method createPDFDirectory.
private void createPDFDirectory(InsightsAssessmentConfigurationDTO assessmentReportDTO) {
try {
String folderName = assessmentReportDTO.getAsseementreportname() + "_" + assessmentReportDTO.getExecutionId();
assessmentReportDTO.setPdfReportFolderName(folderName);
String reportExecutionFile = AssessmentReportAndWorkflowConstants.REPORT_PDF_EXECUTION_RESOLVED_PATH + folderName;
assessmentReportDTO.setPdfReportDirPath(reportExecutionFile);
File reportExecutionFolder = new File(reportExecutionFile);
reportExecutionFolder.mkdir();
} catch (Exception e) {
log.error(e);
throw new InsightsJobFailedException("Unable to create pdf execution directory, message == {} " + e.getMessage());
}
}
Aggregations