Portfolio Access Control : Add a team group to project should only list projects that are not already added.

Signed-off-by: Ralf King <rkg@mm-software.com>
This commit is contained in:
Ralf King 2023-12-03 21:30:53 +01:00
parent 2f16cae2c3
commit 763492f42f
4 changed files with 71 additions and 0 deletions

View file

@ -201,6 +201,34 @@ final class ProjectQueryManager extends QueryManager implements IQueryManager {
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);
}
final String queryFilter = filterBuilder.buildFilter();
final Map<String, Object> params = filterBuilder.getParams();
preprocessACLs(query, queryFilter, params, false);
return execute(query, params);
}
/**
* Returns a project by its uuid.
* @param uuid the uuid of the Project (required)