mirror of
https://github.com/DependencyTrack/dependency-track.git
synced 2025-10-19 16:03:19 +00:00
reuse existing projects endpoint instead of creating a new one
Signed-off-by: Ralf King <rkg@mm-software.com>
This commit is contained in:
parent
db4f1ba137
commit
e379766844
4 changed files with 26 additions and 71 deletions
|
@ -88,7 +88,7 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
* @return a List of Projects
|
||||
*/
|
||||
@Override
|
||||
public PaginatedResult getProjects(final boolean includeMetrics, final boolean excludeInactive, final boolean onlyRoot) {
|
||||
public PaginatedResult getProjects(final boolean includeMetrics, final boolean excludeInactive, final boolean onlyRoot, final Team notAssignedToTeam) {
|
||||
final PaginatedResult result;
|
||||
final Query<Project> query = pm.newQuery(Project.class);
|
||||
if (orderBy == null) {
|
||||
|
@ -103,6 +103,10 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
query.getFetchPlan().addGroup(Project.FetchGroup.ALL.name());
|
||||
}
|
||||
|
||||
if(notAssignedToTeam != null) {
|
||||
filterBuilder.notWithTeam(notAssignedToTeam);
|
||||
}
|
||||
|
||||
if (filter != null) {
|
||||
final String filterString = ".*" + filter.toLowerCase() + ".*";
|
||||
final Tag tag = getTagByName(filter.trim());
|
||||
|
@ -136,7 +140,7 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
*/
|
||||
@Override
|
||||
public PaginatedResult getProjects(final boolean includeMetrics) {
|
||||
return getProjects(includeMetrics, false, false);
|
||||
return getProjects(includeMetrics, false, false, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,7 +183,7 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
* @return a List of Project objects
|
||||
*/
|
||||
@Override
|
||||
public PaginatedResult getProjects(final String name, final boolean excludeInactive, final boolean onlyRoot) {
|
||||
public PaginatedResult getProjects(final String name, final boolean excludeInactive, final boolean onlyRoot, final Team notAssignedToTeam) {
|
||||
final Query<Project> query = pm.newQuery(Project.class);
|
||||
if (orderBy == null) {
|
||||
query.setOrdering("version desc");
|
||||
|
@ -194,32 +198,8 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
|
|||
query.getFetchPlan().addGroup(Project.FetchGroup.ALL.name());
|
||||
}
|
||||
|
||||
final String queryFilter = filterBuilder.buildFilter();
|
||||
final Map<String, Object> params = filterBuilder.getParams();
|
||||
|
||||
preprocessACLs(query, queryFilter, params, false);
|
||||
return execute(query, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of projects by their name that are not assigned to a team.
|
||||
* @param name the name of the Projects
|
||||
* @return a List of Project objects
|
||||
*/
|
||||
@Override
|
||||
public PaginatedResult getProjectsNotAssignedToTeam(final String name, final boolean excludeInactive, final Team team) {
|
||||
final Query<Project> query = pm.newQuery(Project.class);
|
||||
if (orderBy == null) {
|
||||
query.setOrdering("version desc");
|
||||
}
|
||||
|
||||
final var filterBuilder = new ProjectQueryFilterBuilder()
|
||||
.excludeInactive(excludeInactive);
|
||||
if(name != null && !name.isBlank()) {
|
||||
filterBuilder.withName(name);
|
||||
}
|
||||
if(team != null) {
|
||||
filterBuilder.notWithTeam(team);
|
||||
if(notAssignedToTeam != null) {
|
||||
filterBuilder.notWithTeam(notAssignedToTeam);
|
||||
}
|
||||
|
||||
final String queryFilter = filterBuilder.buildFilter();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue