public Path getRelativeTransformedXSLTPath(FileModel payload) { Path outputPath = Paths.get(""); if (payload != null) { String ancestorFolder = payload.getProjectModel().getRootProjectModel().getName(); outputPath = outputPath.resolve(PathUtil.cleanFileName(ancestorFolder)); if (!ancestorFolder.equals(payload.getProjectModel().getName())) { outputPath = outputPath.resolve(PathUtil.cleanFileName(payload.getProjectModel().getName())); } } outputPath = outputPath.resolve(TRANSFORMEDXML_DIR_NAME); return outputPath; }
private void writeCsvRecordForProject(Map<String, CSVWriter> projectToFile, String outputFolderPath, ProjectModel projectModel, String[] line) { if (!projectToFile.containsKey(projectModel.getName())) { String filename = PathUtil.cleanFileName(projectModel.getRootFileModel().getFileName()) + ".csv"; CSVWriter writer = initCSVWriter(outputFolderPath + filename); projectToFile.put(projectModel.getName(), writer); LOG.info("Setting csv filename to: " + filename + " for id: " + projectModel.getId()); projectModel.setCsvFilename(filename); } projectToFile.get(projectModel.getName()).writeNext(line); }
protected String getProjectName(ProjectModel projectModel) { FileModel fileModel = projectModel.getRootFileModel(); if (fileModel != null) { return fileModel.getFileName(); } return projectModel.getName(); }
@Override public String toString() { FileModel rootFileModel = null; if (current != null) { try { rootFileModel = current.getRootFileModel(); } catch (NoSuchElementException e) { // Workaround for Ferma behavior rootFileModel = null; } } String checksum = rootFileModel == null ? null : StringUtils.substring(rootFileModel.getMD5Hash(), 0, 8); String name = rootFileModel == null ? current.getName() : rootFileModel.getFileName(); String projectInfo = current == null ? null : checksum + " " + name + " (" + current.getProjectType() + ')'; String strategyInfo = traversalStrategy == null ? null : traversalStrategy.getClass().getSimpleName(); return "Trav@" + this.hashCode() + "{cur: " + projectInfo + ", strategy: " + strategyInfo + ", prev: " + previous + '}'; }
@Override public String toString() { FileModel rootFileModel = null; if (current != null) { try { rootFileModel = current.getRootFileModel(); } catch (NoSuchElementException e) { // Workaround for Ferma behavior rootFileModel = null; } } String checksum = rootFileModel == null ? null : StringUtils.substring(rootFileModel.getMD5Hash(), 0, 8); String name = rootFileModel == null ? current.getName() : rootFileModel.getFileName(); String projectInfo = current == null ? null : checksum + " " + name + " (" + current.getProjectType() + ')'; String strategyInfo = traversalStrategy == null ? null : traversalStrategy.getClass().getSimpleName(); return "Trav@" + this.hashCode() + "{cur: " + projectInfo + ", strategy: " + strategyInfo + ", prev: " + previous + '}'; }
private void createReport(GraphContext context, ProjectModel application) { ReportService reportService = new ReportService(context); DependenciesReportModel reportModel = createReportModel(context); addAll(context, reportModel, new ProjectModelTraversal(application), new HashMap<String, DependencyReportDependencyGroupModel>()); reportModel.setProjectModel(application); reportService.setUniqueFilename(reportModel, "dependency_report_" + application.getName(), "html"); }
private void createReport(GraphContext context, ProjectModel application) { ReportService reportService = new ReportService(context); DependenciesReportModel reportModel = createReportModel(context); addAll(context, reportModel, new ProjectModelTraversal(application), new HashMap<String, DependencyReportDependencyGroupModel>()); reportModel.setProjectModel(application); reportService.setUniqueFilename(reportModel, "dependency_report_" + application.getName(), "html"); }
private TechReportModel createTechReportBoxes(GraphContext graphContext, ProjectModel appModel) { TechReportModel report = createTechReportBase(graphContext); report.setProjectModel(appModel); report.setDisplayInGlobalApplicationIndex(false); report.setDisplayInApplicationReportIndex(true); report.setReportName(REPORT_NAME_BOXES); report.setTemplatePath(TEMPLATE_PATH_BOXES); report.setDescription(REPORT_DESCRIPTION_BOXES); report.setReportIconClass("fa fa-rocket"); // Set the filename for the report new ReportService(graphContext).setUniqueFilename(report, "techReport-" + appModel.getName(), "html"); return new GraphService<>(graphContext, TechReportModel.class).addTypeToModel(report); }
private TechReportModel createTechReportBoxes(GraphContext graphContext, ProjectModel appModel) { TechReportModel report = createTechReportBase(graphContext); report.setProjectModel(appModel); report.setDisplayInGlobalApplicationIndex(false); report.setDisplayInApplicationReportIndex(true); report.setReportName(REPORT_NAME_BOXES); report.setTemplatePath(TEMPLATE_PATH_BOXES); report.setDescription(REPORT_DESCRIPTION_BOXES); report.setReportIconClass("fa fa-rocket"); // Set the filename for the report new ReportService(graphContext).setUniqueFilename(report, "techReport-" + appModel.getName(), "html"); return new GraphService<>(graphContext, TechReportModel.class).addTypeToModel(report); }
private void createReportModel(GraphContext context, ProjectModel application) { ProjectModelTraversal traversal = new ProjectModelTraversal(application); List<ProjectModel> projects = getProjectsWithUnparsableFiles(traversal); if (projects.isEmpty()) return; GraphService<UnparsablesAppReportModel> service = new GraphService<>(context, UnparsablesAppReportModel.class); UnparsablesAppReportModel reportModel = service.create(); reportModel.setReportPriority(120); reportModel.setDisplayInApplicationReportIndex(true); reportModel.setReportName(REPORT_NAME); reportModel.setDescription(DESCRIPTION); reportModel.setReportIconClass("glyphicon glyphicon-warning-sign"); reportModel.setMainApplicationReport(false); reportModel.setProjectModel(application); reportModel.setTemplatePath(TEMPLATE_UNPARSABLE); reportModel.setTemplateType(TemplateType.FREEMARKER); reportModel.setAllSubProjects(projects); // Set the filename for the report ReportService reportService = new ReportService(context); reportService.setUniqueFilename(reportModel, REPORT_NAME + "_" + application.getName(), "html"); } }
private void createReportIndex(GraphContext context, ProjectModel projectModel) { ApplicationReportService service = new ApplicationReportService(context); ApplicationReportModel applicationReportModel = service.create(); applicationReportModel.setReportPriority(100); applicationReportModel.setDisplayInApplicationReportIndex(true); applicationReportModel.setReportName(REPORT_INDEX); applicationReportModel.setReportIconClass("glyphicon glyphicon-dashboard"); applicationReportModel.setMainApplicationReport(true); applicationReportModel.setTemplatePath(TEMPLATE); applicationReportModel.setTemplateType(TemplateType.FREEMARKER); applicationReportModel.setProjectModel(projectModel); applicationReportModel.setDescription( "Dashboard report aggregating findings from the analysis."); // Set the filename for the report ReportService reportService = new ReportService(context); reportService.setUniqueFilename(applicationReportModel, "report_index_" + projectModel.getName(), "html"); }
private void createReportIndex(GraphContext context, ProjectModel projectModel) { ApplicationReportService service = new ApplicationReportService(context); ApplicationReportModel applicationReportModel = service.create(); applicationReportModel.setReportPriority(100); applicationReportModel.setDisplayInApplicationReportIndex(true); applicationReportModel.setReportName(REPORT_INDEX); applicationReportModel.setReportIconClass("glyphicon glyphicon-dashboard"); applicationReportModel.setMainApplicationReport(true); applicationReportModel.setTemplatePath(TEMPLATE); applicationReportModel.setTemplateType(TemplateType.FREEMARKER); applicationReportModel.setProjectModel(projectModel); applicationReportModel.setDescription( "Dashboard report aggregating findings from the analysis."); // Set the filename for the report ReportService reportService = new ReportService(context); reportService.setUniqueFilename(applicationReportModel, "report_index_" + projectModel.getName(), "html"); }
private ApplicationReportModel createApplicationReport(GraphContext context, ProjectModel application) { ApplicationReportService applicationReportService = new ApplicationReportService(context); ApplicationReportModel applicationReportModel = applicationReportService.create(); applicationReportModel.setReportPriority(200); applicationReportModel.setDisplayInApplicationReportIndex(true); applicationReportModel.setReportName("Compatible Files"); applicationReportModel.setDescription(REPORT_DESCRIPTION); applicationReportModel.setReportIconClass("glyphicon glyphicon-check"); applicationReportModel.setMainApplicationReport(false); applicationReportModel.setProjectModel(application); applicationReportModel.setTemplatePath(TEMPLATE_APPLICATION_REPORT); applicationReportModel.setTemplateType(TemplateType.FREEMARKER); // Set the filename for the report ReportService reportService = new ReportService(context); reportService.setUniqueFilename(applicationReportModel, "compatiblefiles_" + application.getName(), "html"); return applicationReportModel; } }
private ApplicationReportModel createApplicationReport(GraphContext context, ProjectModel projectModel) { ApplicationReportService applicationReportService = new ApplicationReportService(context); ApplicationReportModel applicationReportModel = applicationReportService.create(); applicationReportModel.setReportPriority(200); applicationReportModel.setDisplayInApplicationReportIndex(true); applicationReportModel.setReportName("Unclassified Files"); applicationReportModel.setReportIconClass("glyphicon glyphicon-question-sign"); applicationReportModel.setMainApplicationReport(false); applicationReportModel.setProjectModel(projectModel); applicationReportModel.setTemplatePath(TEMPLATE_APPLICATION_REPORT); applicationReportModel.setTemplateType(TemplateType.FREEMARKER); applicationReportModel.setDisplayInApplicationList(false); // Set the filename for the report ReportService reportService = new ReportService(context); reportService.setUniqueFilename(applicationReportModel, "nonclassifiedfiles_" + projectModel.getName(), "html"); return applicationReportModel; } }
private ApplicationReportModel createApplicationReport(GraphContext context, ProjectModel application) { ApplicationReportService applicationReportService = new ApplicationReportService(context); ApplicationReportModel applicationReportModel = applicationReportService.create(); applicationReportModel.setReportPriority(200); applicationReportModel.setDisplayInApplicationReportIndex(true); applicationReportModel.setReportName("Compatible Files"); applicationReportModel.setDescription(REPORT_DESCRIPTION); applicationReportModel.setReportIconClass("glyphicon glyphicon-check"); applicationReportModel.setMainApplicationReport(false); applicationReportModel.setProjectModel(application); applicationReportModel.setTemplatePath(TEMPLATE_APPLICATION_REPORT); applicationReportModel.setTemplateType(TemplateType.FREEMARKER); // Set the filename for the report ReportService reportService = new ReportService(context); reportService.setUniqueFilename(applicationReportModel, "compatiblefiles_" + application.getName(), "html"); return applicationReportModel; } }
private void setupProject(GraphRewrite event, DuplicateArchiveModel duplicateArchive) { Service<DuplicateProjectModel> duplicateProjectService = event.getGraphContext().service(DuplicateProjectModel.class); ArchiveModel canonicalArchive = duplicateArchive.getCanonicalArchive(); ProjectModel canonicalProject = canonicalArchive.getProjectModel(); DuplicateProjectModel duplicateProject = duplicateProjectService.create(); duplicateProject.setCanonicalProject(canonicalProject); duplicateProject.setName(canonicalProject.getName()); if (duplicateArchive.getParentArchive() != null) duplicateProject.setParentProject(duplicateArchive.getParentArchive().getProjectModel()); duplicateProject.setRootFileModel(duplicateArchive); if (canonicalProject.getParentProject() == null) { ProjectService projectService = new ProjectService(event.getGraphContext()); ProjectModel sharedLibsProject = projectService.getOrCreateSharedLibsProject(); canonicalProject.setParentProject(sharedLibsProject); } duplicateProject.addFileModel(duplicateArchive); } }
private void setupProject(GraphRewrite event, DuplicateArchiveModel duplicateArchive) { Service<DuplicateProjectModel> duplicateProjectService = event.getGraphContext().service(DuplicateProjectModel.class); ArchiveModel canonicalArchive = duplicateArchive.getCanonicalArchive(); ProjectModel canonicalProject = canonicalArchive.getProjectModel(); DuplicateProjectModel duplicateProject = duplicateProjectService.create(); duplicateProject.setCanonicalProject(canonicalProject); duplicateProject.setName(canonicalProject.getName()); if (duplicateArchive.getParentArchive() != null) duplicateProject.setParentProject(duplicateArchive.getParentArchive().getProjectModel()); duplicateProject.setRootFileModel(duplicateArchive); if (canonicalProject.getParentProject() == null) { ProjectService projectService = new ProjectService(event.getGraphContext()); ProjectModel sharedLibsProject = projectService.getOrCreateSharedLibsProject(); canonicalProject.setParentProject(sharedLibsProject); } duplicateProject.addFileModel(duplicateArchive); } }
private void serializeProjectMetadata(ProjectTraversalReducedDTO traversalDTO, PersistedProjectModelTraversalModel traversal) { ProjectModel current = traversal.getCurrentProject(); ProjectModel canonical = traversal.getCanonicalProject(); traversalDTO.setId(traversal.getId()); traversalDTO.setCurrentID(current.getId()); traversalDTO.setCanonicalID(canonical.getId()); FileModel rootFileModel = canonical.getRootFileModel(); if (rootFileModel != null) { traversalDTO.setSha1(rootFileModel.getSHA1Hash()); } traversalDTO.setName(canonical.getName()); traversalDTO.setCanonicalFilename(rootFileModel.getFileName()); traversalDTO.setPath(traversal.getPath()); traversalDTO.setOrganization(canonical.getOrganization()); traversalDTO.setUrl(canonical.getURL()); if (canonical instanceof MavenProjectModel) { traversalDTO.setGav(((MavenProjectModel) canonical).getMavenIdentifier()); } }