Search in sources :

Example 1 with ProjectRole

use of com.epam.ta.reportportal.database.entity.ProjectRole in project commons-dao by reportportal.

the class ProjectRepositoryCustomImpl method findProjectRoles.

@Override
public Map<String, ProjectRole> findProjectRoles(String login) {
    final Query q = Query.query(userExists(login));
    q.fields().include("users");
    return mongoTemplate.find(q, Project.class).stream().collect(Collectors.toMap(Project::getName, p -> p.getUsers().stream().filter(it -> login.equals(it.getLogin())).findFirst().get().getProjectRole()));
}
Also used : UserConfig(com.epam.ta.reportportal.database.entity.Project.UserConfig) Predicate(java.util.function.Predicate) BasicDBObject(com.mongodb.BasicDBObject) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) Criteria(org.springframework.data.mongodb.core.query.Criteria) Query(org.springframework.data.mongodb.core.query.Query) PERSONAL_PROJECT_POSTFIX(com.epam.ta.reportportal.database.personal.PersonalProjectService.PERSONAL_PROJECT_POSTFIX) List(java.util.List) ProjectRole(com.epam.ta.reportportal.database.entity.ProjectRole) EntryType(com.epam.ta.reportportal.database.entity.project.EntryType) Map(java.util.Map) Update(org.springframework.data.mongodb.core.query.Update) Optional(java.util.Optional) Project(com.epam.ta.reportportal.database.entity.Project) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) Collections(java.util.Collections) Query(org.springframework.data.mongodb.core.query.Query)

Aggregations

Project (com.epam.ta.reportportal.database.entity.Project)1 UserConfig (com.epam.ta.reportportal.database.entity.Project.UserConfig)1 ProjectRole (com.epam.ta.reportportal.database.entity.ProjectRole)1 EntryType (com.epam.ta.reportportal.database.entity.project.EntryType)1 PERSONAL_PROJECT_POSTFIX (com.epam.ta.reportportal.database.personal.PersonalProjectService.PERSONAL_PROJECT_POSTFIX)1 BasicDBObject (com.mongodb.BasicDBObject)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 MongoTemplate (org.springframework.data.mongodb.core.MongoTemplate)1 Criteria (org.springframework.data.mongodb.core.query.Criteria)1 Query (org.springframework.data.mongodb.core.query.Query)1 Update (org.springframework.data.mongodb.core.query.Update)1