use of com.epam.ta.reportportal.database.entity.Project in project commons-dao by reportportal.
the class ProjectRepositoryCustomImpl method findPersonalProjectName.
@Override
public Optional<String> findPersonalProjectName(String user) {
Query query = Query.query(userExists(user)).addCriteria(Criteria.where(PROJECT_TYPE).is(EntryType.PERSONAL)).addCriteria(Criteria.where(PROJECT_ID).regex("^" + user + PERSONAL_PROJECT_POSTFIX));
query.fields().include("name");
return Optional.ofNullable(mongoTemplate.findOne(query, Project.class)).map(Project::getName);
}
use of com.epam.ta.reportportal.database.entity.Project 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()));
}
use of com.epam.ta.reportportal.database.entity.Project in project commons-dao by reportportal.
the class ProjectRepositoryCustomImpl method clearExternalSystems.
@Override
public synchronized void clearExternalSystems(String projectId) {
Project first = mongoTemplate.findOne(projectById(projectId), Project.class);
first.getConfiguration().setExternalSystem(Collections.emptyList());
mongoTemplate.save(first);
}
use of com.epam.ta.reportportal.database.entity.Project in project commons-dao by reportportal.
the class PersonalProjectService method generatePersonalProject.
/**
* Generates personal project for provided user
*
* @param user User project should be created for
* @return Built Project object
*/
public Project generatePersonalProject(User user) {
Project project = new Project();
project.setName(generatePersonalProjectName(user.getLogin()));
project.setCreationDate(Date.from(ZonedDateTime.now().toInstant()));
Project.UserConfig userConfig = new Project.UserConfig();
userConfig.setLogin(user.getId());
userConfig.setProjectRole(ProjectRole.PROJECT_MANAGER);
userConfig.setProposedRole(ProjectRole.PROJECT_MANAGER);
project.setUsers(ImmutableList.<Project.UserConfig>builder().add(userConfig).build());
project.setAddInfo("Personal project of " + (isNullOrEmpty(user.getFullName()) ? user.getLogin() : user.getFullName()));
project.setConfiguration(defaultConfiguration());
/* Default email configuration */
ProjectUtils.setDefaultEmailCofiguration(project);
return project;
}
use of com.epam.ta.reportportal.database.entity.Project in project commons-dao by reportportal.
the class CascadeDeleteUserTrigger method clearProject.
/**
* Remove user references from projects for which user was assigned
*
* @param id
*/
private void clearProject(String id) {
List<Project> projects = projectRepository.findUserProjects(id);
for (Project project : projects) {
project.getUsers().removeIf(it -> id.equals(it.getLogin()));
}
projectRepository.save(projects);
}
Aggregations