use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportTemplateConfigFiles in project Insights by CognizantOneDevOps.
the class CommonDALUtils method changeAnnotationValue.
/**
* This method use for changing annotation value/base data type of some table so that It is compilable with other database
* @throws NoSuchFieldException
* @throws SecurityException
* @throws ClassNotFoundException
*/
public static void changeAnnotationValue() throws NoSuchFieldException, SecurityException, ClassNotFoundException {
Map<Object, String> classMap = new HashMap<>();
classMap.put(new InsightsConfigFiles(), "fileData");
classMap.put(new InsightsReportTemplateConfigFiles(), "fileData");
classMap.put(new InsightsReportVisualizationContainer(), "attachmentData");
classMap.put(new AutoMLConfig(), "file");
classMap.put(new AutoMLConfig(), "mojoDeployedZip");
for (Map.Entry<Object, String> entry : classMap.entrySet()) {
Field field = entry.getKey().getClass().getDeclaredField(entry.getValue());
Annotation annotations = field.getAnnotations()[0];
Object handler = Proxy.getInvocationHandler(annotations);
log.debug("Field : {}", field.getName());
field.setAccessible(true);
Field f;
try {
f = handler.getClass().getDeclaredField("memberValues");
} catch (NoSuchFieldException | SecurityException e) {
throw new IllegalStateException(e);
}
f.setAccessible(true);
Map<String, Object> memberValues;
try {
memberValues = (Map<String, Object>) f.get(handler);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
Object oldValue = memberValues.get("columnDefinition");
memberValues.put("columnDefinition", "BLOB");
}
Map<Object, String> classBooleanMap = new HashMap<>();
classBooleanMap.put(new AgentConfig(), "vault");
classBooleanMap.put(new AgentConfig(), "iswebhook");
classBooleanMap.put(new CorrelationConfiguration(), "enableCorrelation");
classBooleanMap.put(new CorrelationConfiguration(), "isSelfRelation");
classBooleanMap.put(new InsightsAssessmentReportTemplate(), "isActive");
classBooleanMap.put(new InsightsContentConfig(), "isActive");
classBooleanMap.put(new InsightsKPIConfig(), "isActive");
classBooleanMap.put(new AutoMLConfig(), "isActive");
classBooleanMap.put(new WebHookConfig(), "subscribeStatus");
classBooleanMap.put(new WebHookConfig(), "isUpdateRequired");
classBooleanMap.put(new WebHookConfig(), "isEventProcessing");
classBooleanMap.put(new InsightsWorkflowConfiguration(), "isActive");
classBooleanMap.put(new InsightsWorkflowConfiguration(), "runImmediate");
classBooleanMap.put(new InsightsWorkflowConfiguration(), "reoccurence");
for (Map.Entry<Object, String> entry : classBooleanMap.entrySet()) {
Field field = entry.getKey().getClass().getDeclaredField(entry.getValue());
Annotation annotations = field.getAnnotations()[0];
Object handler = Proxy.getInvocationHandler(annotations);
log.debug("Field :{} ", field.getName());
field.setAccessible(true);
Field f;
try {
f = handler.getClass().getDeclaredField("memberValues");
} catch (NoSuchFieldException | SecurityException e) {
throw new IllegalStateException(e);
}
f.setAccessible(true);
Map<String, Object> memberValues;
try {
memberValues = (Map<String, Object>) f.get(handler);
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new IllegalStateException(e);
}
Object oldValue = memberValues.get("columnDefinition");
memberValues.put("columnDefinition", "INT");
}
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportTemplateConfigFiles in project Insights by CognizantOneDevOps.
the class FusionChartHandler method setReportExecutionFolder.
public void setReportExecutionFolder(InsightsAssessmentConfigurationDTO assessmentReportDTO) throws IOException {
List<InsightsReportTemplateConfigFiles> records = reportConfigDAL.getReportTemplateConfigFileByReportId(assessmentReportDTO.getReportId());
for (InsightsReportTemplateConfigFiles record : records) {
String filePath = assessmentReportDTO.getPdfReportDirPath() + File.separator + record.getFileName();
File file = new File(filePath);
if (!file.exists()) {
FileUtils.writeByteArrayToFile(file, record.getFileData());
}
}
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportTemplateConfigFiles in project Insights by CognizantOneDevOps.
the class AssesmentReportServiceImpl method uploadReportTemplateFile.
/**
* Method to upload Report Template file
*
* @param reportId
* @param reportEntity
* @param fileType
* @param file
* @throws IOException
*/
private void uploadReportTemplateFile(int reportId, InsightsAssessmentReportTemplate reportEntity, String fileType, String filename, byte[] file) {
InsightsReportTemplateConfigFiles templateFile = reportConfigDAL.getReportTemplateConfigFileByFileNameAndReportId(filename, reportEntity.getReportId());
if (templateFile == null) {
InsightsReportTemplateConfigFiles record = new InsightsReportTemplateConfigFiles();
record.setFileName(filename);
record.setFileData(file);
record.setFileType(fileType);
record.setReportId(reportId);
reportConfigDAL.saveReportTemplateConfigFiles(record);
} else {
templateFile.setFileData(file);
reportConfigDAL.updateReportTemplateConfigFiles(templateFile);
}
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportTemplateConfigFiles in project Insights by CognizantOneDevOps.
the class AssesmentReportServiceImpl method saveDashbaordInGrafana.
private String saveDashbaordInGrafana(String userName, String reportName, InsightsAssessmentReportTemplate reportTemplate) throws InsightsCustomException {
String responseorg = null;
try {
List<InsightsReportTemplateConfigFiles> records = reportConfigDAL.getReportTemplateConfigFileByReportId(reportTemplate.getReportId());
JsonObject requestOrg = new JsonObject();
for (InsightsReportTemplateConfigFiles insightsReportTemplateConfigFiles : records) {
if (insightsReportTemplateConfigFiles.getFileName().equalsIgnoreCase(AssessmentReportAndWorkflowConstants.DASHBOARDTEMPLATEJSON)) {
String dashboardJson = new String(insightsReportTemplateConfigFiles.getFileData());
requestOrg = JsonUtils.parseStringAsJsonObject(dashboardJson);
}
}
requestOrg.get(AssessmentReportAndWorkflowConstants.DASHBOARD).getAsJsonObject().addProperty(AssessmentReportAndWorkflowConstants.TITLE, reportName);
JsonArray panelArray = requestOrg.get("dashboard").getAsJsonObject().get("panels").getAsJsonArray();
for (JsonElement jsonElement : panelArray) {
String vQuery = jsonElement.getAsJsonObject().getAsJsonArray(AssessmentReportAndWorkflowConstants.TARGETS).get(0).getAsJsonObject().get(AssessmentReportAndWorkflowConstants.QUERYTEXT).getAsString();
vQuery = vQuery.replace("{assessmentReportName}", "'" + reportName + "'");
jsonElement.getAsJsonObject().getAsJsonArray(AssessmentReportAndWorkflowConstants.TARGETS).get(0).getAsJsonObject().addProperty(AssessmentReportAndWorkflowConstants.QUERYTEXT, vQuery);
}
log.debug(" requestOrg {} ", requestOrg);
responseorg = grafanaUtilities.createOrgAndSaveDashboardInGrafana(requestOrg, userName);
log.debug(" responseorg {} ", responseorg);
} catch (Exception e) {
log.error("Error while saving dashboard in Grafana.", e);
throw new InsightsCustomException(e.getMessage());
}
return responseorg;
}
use of com.cognizant.devops.platformdal.assessmentreport.InsightsReportTemplateConfigFiles in project Insights by CognizantOneDevOps.
the class AssessmentReportsTestData method uploadReportTemplateDesignFiles.
public String uploadReportTemplateDesignFiles(int reportId) throws InsightsCustomException {
String returnMessage = "";
try {
InsightsAssessmentReportTemplate reportEntity = (InsightsAssessmentReportTemplate) reportConfigDAL.getReportTemplateByReportId(reportId);
if (reportEntity == null) {
throw new InsightsCustomException(" Report template not exists in database " + reportId);
} else {
for (String eachFile : templateDesignFilesArray) {
String fileType = FilenameUtils.getExtension(eachFile).toUpperCase();
File file = new File(classLoader.getResource("Report_SONAR_JENKINS_PROD/" + eachFile).getFile());
InsightsReportTemplateConfigFiles templateFile = reportConfigDAL.getReportTemplateConfigFileByFileNameAndReportId(file.getName(), reportId);
if (templateFile == null) {
InsightsReportTemplateConfigFiles record = new InsightsReportTemplateConfigFiles();
record.setFileName(file.getName());
record.setFileData(FileUtils.readFileToByteArray(file));
record.setFileType(fileType);
record.setReportId(reportId);
reportConfigDAL.saveReportTemplateConfigFiles(record);
} else {
templateFile.setFileData(FileUtils.readFileToByteArray(file));
reportConfigDAL.updateReportTemplateConfigFiles(templateFile);
}
}
returnMessage = "File uploaded";
}
} catch (Exception ex) {
log.error("Error in Report Template files upload {} ", ex.getMessage());
throw new InsightsCustomException(ex.getMessage());
}
return returnMessage;
}
Aggregations