Search in sources :

Example 21 with InsightsJobFailedException

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());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException)

Example 22 with InsightsJobFailedException

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());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) File(java.io.File) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException)

Example 23 with InsightsJobFailedException

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);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) JsonArray(com.google.gson.JsonArray) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException)

Example 24 with InsightsJobFailedException

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());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) PdfTableUtil(com.cognizant.devops.platformauditing.util.PdfTableUtil) File(java.io.File) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException)

Example 25 with InsightsJobFailedException

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());
    }
}
Also used : InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException) File(java.io.File) InsightsJobFailedException(com.cognizant.devops.platformreports.exception.InsightsJobFailedException)

Aggregations

InsightsJobFailedException (com.cognizant.devops.platformreports.exception.InsightsJobFailedException)63 IOException (java.io.IOException)31 JsonObject (com.google.gson.JsonObject)29 InsightsCustomException (com.cognizant.devops.platformcommons.exception.InsightsCustomException)21 ArrayList (java.util.ArrayList)16 File (java.io.File)14 JsonArray (com.google.gson.JsonArray)12 HashMap (java.util.HashMap)11 InsightsKPIResultDetails (com.cognizant.devops.platformreports.assessment.datamodel.InsightsKPIResultDetails)8 List (java.util.List)8 InsightsContentDetail (com.cognizant.devops.platformreports.assessment.datamodel.InsightsContentDetail)7 ReportEngineEnum (com.cognizant.devops.platformreports.assessment.util.ReportEngineEnum)7 ExecutionException (java.util.concurrent.ExecutionException)7 ContentConfigDefinition (com.cognizant.devops.platformreports.assessment.datamodel.ContentConfigDefinition)6 InsightsAssessmentConfigurationDTO (com.cognizant.devops.platformreports.assessment.datamodel.InsightsAssessmentConfigurationDTO)5 FileNotFoundException (java.io.FileNotFoundException)5 NoSuchFileException (java.nio.file.NoSuchFileException)5 Map (java.util.Map)5 InsightsContentConfig (com.cognizant.devops.platformdal.assessmentreport.InsightsContentConfig)4 InsightsReportVisualizationContainer (com.cognizant.devops.platformdal.assessmentreport.InsightsReportVisualizationContainer)4