/** * Recursively crawls this {@link ProjectModelTraversal} and adds all of the {@link ProjectModel}s to a {@link Set}. The exact projects returns * will be affected by the {@link TraversalStrategy} in use by the current traversal. * * This is the same as {@link ProjectModelTraversal#getAllProjects(boolean)} except that it returns a Set of vertices instead of frames. */ public Set<Vertex> getAllProjectsAsVertices(boolean recursive) { Set<Vertex> vertices = new LinkedHashSet<>(); for (ProjectModel projectModel : getAllProjects(recursive)) vertices.add(projectModel.getElement()); return vertices; }
/** * Recursively crawls this {@link ProjectModelTraversal} and adds all of the {@link ProjectModel}s to a {@link Set}. The exact projects returns * will be affected by the {@link TraversalStrategy} in use by the current traversal. * * This is the same as {@link ProjectModelTraversal#getAllProjects(boolean)} except that it returns a Set of vertices instead of frames. */ public Set<Vertex> getAllProjectsAsVertices(boolean recursive) { Set<Vertex> vertices = new LinkedHashSet<>(); for (ProjectModel projectModel : getAllProjects(recursive)) vertices.add(projectModel.getElement()); return vertices; }
private List<Vertex> getProjectAndChildren(ProjectModel projectModel) { ArrayList<Vertex> result = new ArrayList<>(); result.add(projectModel.getElement()); for (ProjectModel child : projectModel.getChildProjects()) { result.addAll(getProjectAndChildren(child)); } return result; }
private List<Vertex> getProjectAndChildren(ProjectModel projectModel) { ArrayList<Vertex> result = new ArrayList<>(); result.add(projectModel.getElement()); for (ProjectModel child : projectModel.getChildProjects()) { result.addAll(getProjectAndChildren(child)); } return result; }
/** * Returns all hints for the given {@link ProjectModel}. If recursive is set, then this will recurse into * child projects as well. */ public Iterable<InlineHintModel> getHintsForProject(ProjectModel projectModel, boolean recursive) { final List<Vertex> initialVertices; if (recursive) { initialVertices = getProjectAndChildren(projectModel); } else { initialVertices = Collections.singletonList(projectModel.getElement()); } return getInlineHintModels(initialVertices); }
/** * Returns all hints for the given {@link ProjectModel}. If recursive is set, then this will recurse into * child projects as well. */ public Iterable<InlineHintModel> getHintsForProject(ProjectModel projectModel, boolean recursive) { final List<Vertex> initialVertices; if (recursive) { initialVertices = getProjectAndChildren(projectModel); } else { initialVertices = Collections.singletonList(projectModel.getElement()); } return getInlineHintModels(initialVertices); }
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (ProjectModel)"); } StringModel stringModelArg = (StringModel) arguments.get(0); if (stringModelArg == null) { throw new IllegalArgumentException("FreeMarker Method " + NAME + " called with null project model"); } ProjectModel projectModel = (ProjectModel) stringModelArg.getWrappedObject(); ApplicationReportIndexModel index = service.getApplicationReportIndexForProjectModel(projectModel); if (index == null) { LOG.warning("Could not find an application index for project model: " + projectModel.getName() + " (Vertex ID: " + projectModel.getElement().id() + ")"); } ExecutionStatistics.get().end(NAME); return index; } }
@Override public Object exec(@SuppressWarnings("rawtypes") List arguments) throws TemplateModelException { ExecutionStatistics.get().begin(NAME); if (arguments.size() != 1) { throw new TemplateModelException("Error, method expects one argument (ProjectModel)"); } StringModel stringModelArg = (StringModel) arguments.get(0); if (stringModelArg == null) { throw new IllegalArgumentException("FreeMarker Method " + NAME + " called with null project model"); } ProjectModel projectModel = (ProjectModel) stringModelArg.getWrappedObject(); ApplicationReportIndexModel index = service.getApplicationReportIndexForProjectModel(projectModel); if (index == null) { LOG.warning("Could not find an application index for project model: " + projectModel.getName() + " (Vertex ID: " + projectModel.getElement().id() + ")"); } ExecutionStatistics.get().end(NAME); return index; } }
appTechReport.setSectorsHolderTag(sectorsTag); appTechReport.setRowsHolderTag(rowsTag); appProjectToReportMap.put(appModel.getElement().id().toString(), appTechReport);
/** * Returns the {@link ApplicationReportIndexModel} associated with the provided ProjectModel */ public ApplicationReportIndexModel getApplicationReportIndexForProjectModel(ProjectModel projectModel) { GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(projectModel.getElement()); pipeline.in(ApplicationReportIndexModel.APPLICATION_REPORT_INDEX_TO_PROJECT_MODEL); ApplicationReportIndexModel applicationReportIndex = null; if (pipeline.hasNext()) { applicationReportIndex = frame(pipeline.next()); } return applicationReportIndex; } }
/** * Returns the {@link ApplicationReportIndexModel} associated with the provided ProjectModel */ public ApplicationReportIndexModel getApplicationReportIndexForProjectModel(ProjectModel projectModel) { GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(projectModel.getElement()); pipeline.in(ApplicationReportIndexModel.APPLICATION_REPORT_INDEX_TO_PROJECT_MODEL); ApplicationReportIndexModel applicationReportIndex = null; if (pipeline.hasNext()) { applicationReportIndex = frame(pipeline.next()); } return applicationReportIndex; } }
/** * Return an {@link Iterable} containing all {@link TechnologyTagModel}s that are directly associated with the provided {@link ProjectModel}. */ public Iterable<TechnologyTagModel> findTechnologyTagsForProject(ProjectModelTraversal traversal) { Set<TechnologyTagModel> results = new TreeSet<>(new DefaultTechnologyTagComparator()); GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(traversal.getCanonicalProject().getElement()); pipeline.out(ProjectModel.PROJECT_MODEL_TO_FILE); pipeline.in(TechnologyTagModel.TECH_TAG_TO_FILE_MODEL).has(WindupVertexFrame.TYPE_PROP, Text.textContains(TechnologyTagModel.TYPE)); Iterable<TechnologyTagModel> modelIterable = new FramedVertexIterable<>(getGraphContext().getFramed(), pipeline.toList(), TechnologyTagModel.class); results.addAll(Iterators.asSet(modelIterable)); for (ProjectModelTraversal childTraversal : traversal.getChildren()) { results.addAll(Iterators.asSet(findTechnologyTagsForProject(childTraversal))); } return results; } }
/** * Return an {@link Iterable} containing all {@link TechnologyTagModel}s that are directly associated with the provided {@link ProjectModel}. */ public Iterable<TechnologyTagModel> findTechnologyTagsForProject(ProjectModelTraversal traversal) { Set<TechnologyTagModel> results = new TreeSet<>(new DefaultTechnologyTagComparator()); GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(traversal.getCanonicalProject().getElement()); pipeline.out(ProjectModel.PROJECT_MODEL_TO_FILE); pipeline.in(TechnologyTagModel.TECH_TAG_TO_FILE_MODEL).has(WindupVertexFrame.TYPE_PROP, Text.textContains(TechnologyTagModel.TYPE)); Iterable<TechnologyTagModel> modelIterable = new FramedVertexIterable<>(getGraphContext().getFramed(), pipeline.toList(), TechnologyTagModel.class); results.addAll(Iterators.asSet(modelIterable)); for (ProjectModelTraversal childTraversal : traversal.getChildren()) { results.addAll(Iterators.asSet(findTechnologyTagsForProject(childTraversal))); } return results; } }
/** * Gets an {@link Iterable} of {@link }s for the given {@link ProjectModel}. */ public Iterable<HibernateEntityModel> findAllByApplication(ProjectModel application) { GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(application.getElement()); pipeline.in(HibernateEntityModel.APPLICATIONS); pipeline.has(WindupVertexFrame.TYPE_PROP, Text.textContains(HibernateEntityModel.TYPE)); return new FramedVertexIterable<>(getGraphContext().getFramed(), pipeline.toList(), HibernateEntityModel.class); } }
/** * Gets an {@link Iterable} of {@link }s for the given {@link ProjectModel}. */ public Iterable<HibernateEntityModel> findAllByApplication(ProjectModel application) { GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(application.getElement()); pipeline.in(HibernateEntityModel.APPLICATIONS); pipeline.has(WindupVertexFrame.TYPE_PROP, Text.textContains(HibernateEntityModel.TYPE)); return new FramedVertexIterable<>(getGraphContext().getFramed(), pipeline.toList(), HibernateEntityModel.class); } }
/** * After the packages are registered and Java scanning done, * we can link the ProjectModel and API packages together. * ProjectModel --uses--> ArchiveCoordinateModel */ public void markProjectsUsingPackagesFromAPI(MavenCoord apiCoords) { final Service<ArchiveCoordinateModel> coordsService = graphContext.service(ArchiveCoordinateModel.class); Iterable<String> packages = this.getPackagesInArtifact(apiCoords); for (String pkg : packages) { Iterable<ProjectModel> projects = this.getProjectsContainingClassesReferencingPackage(pkg); for (ProjectModel project : projects) { ArchiveCoordinateModel apiArchiveRepresentant = new ArchiveCoordinateService(graphContext, ArchiveCoordinateModel.class) .getSingleOrCreate(apiCoords.getGroupId(), apiCoords.getArtifactId(), null); // We specifically want null. project.getElement().addEdge(EDGE_USES, apiArchiveRepresentant.getElement()); } } }
/** * Gets an {@link Iterable} of {@link SpringBeanModel}s for the given {@link ProjectModel}. * * @return an iterable of SpringBeanModel entries for the given application */ public Iterable<SpringBeanModel> findAllByApplication(ProjectModel application) { GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(application.getElement()); pipeline.in(SpringBeanModel.APPLICATIONS); pipeline.has(WindupVertexFrame.TYPE_PROP, P.eq(SpringBeanModel.TYPE)); return new FramedVertexIterable<>(getGraphContext().getFramed(), pipeline.toList(), SpringBeanModel.class); } }
/** * Gets an {@link Iterable} of {@link SpringBeanModel}s for the given {@link ProjectModel}. * * @return an iterable of SpringBeanModel entries for the given application */ public Iterable<SpringBeanModel> findAllByApplication(ProjectModel application) { GraphTraversal<Vertex, Vertex> pipeline = new GraphTraversalSource(getGraphContext().getGraph()).V(application.getElement()); pipeline.in(SpringBeanModel.APPLICATIONS); pipeline.has(WindupVertexFrame.TYPE_PROP, P.eq(SpringBeanModel.TYPE)); return new FramedVertexIterable<>(getGraphContext().getFramed(), pipeline.toList(), SpringBeanModel.class); } }
GraphTraversal<Vertex, Vertex> pipe = new GraphTraversalSource(getGraphContext().getGraph()).V(rootProjectModel.getElement()); pipe.in(ApplicationReportModel.REPORT_TO_PROJECT_MODEL); pipe.has(ApplicationReportModel.MAIN_APPLICATION_REPORT, true);
/** * After the packages are registered and Java scanning done, * we can link the ProjectModel and API packages together. * ProjectModel --uses--> ArchiveCoordinateModel */ public void markProjectsUsingPackagesFromAPI(MavenCoord apiCoords) { final Service<ArchiveCoordinateModel> coordsService = graphContext.service(ArchiveCoordinateModel.class); Iterable<String> packages = this.getPackagesInArtifact(apiCoords); for (String pkg : packages) { Iterable<ProjectModel> projects = this.getProjectsContainingClassesReferencingPackage(pkg); for (ProjectModel project : projects) { ArchiveCoordinateModel apiArchiveRepresentant = new ArchiveCoordinateService(graphContext, ArchiveCoordinateModel.class) .getSingleOrCreate(apiCoords.getGroupId(), apiCoords.getArtifactId(), null); // We specifically want null. project.getElement().addEdge(EDGE_USES, apiArchiveRepresentant.getElement()); } } }