use of io.lumeer.storage.api.query.DatabaseQuery in project engine by Lumeer.
the class ProjectFacade method getProjects.
public List<Project> getProjects() {
User user = authenticatedUser.getCurrentUser();
Set<String> groups = authenticatedUser.getCurrentUserGroups();
DatabaseQuery query = DatabaseQuery.createBuilder(user.getEmail()).groups(groups).build();
return projectDao.getProjects(query).stream().map(this::keepOnlyActualUserRoles).collect(Collectors.toList());
}
use of io.lumeer.storage.api.query.DatabaseQuery in project engine by Lumeer.
the class MorphiaProjectDaoTest method testGetProjectsGroupRole.
@Test
public void testGetProjectsGroupRole() {
MorphiaProject project = prepareProject(CODE1);
datastore.save(projectDao.databaseCollection(), project);
MorphiaProject project2 = prepareProject(CODE2);
datastore.save(projectDao.databaseCollection(), project2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP)).build();
List<Project> projects = projectDao.getProjects(query);
assertThat(projects).extracting(Project::getCode).containsOnly(CODE1, CODE2);
}
use of io.lumeer.storage.api.query.DatabaseQuery in project engine by Lumeer.
the class MorphiaProjectDaoTest method testGetProjects.
@Test
public void testGetProjects() {
MorphiaProject project = prepareProject(CODE1);
datastore.save(projectDao.databaseCollection(), project);
MorphiaProject project2 = prepareProject(CODE2);
datastore.save(projectDao.databaseCollection(), project2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER).build();
List<MorphiaProject> projects = (List<MorphiaProject>) (List<?>) projectDao.getProjects(query);
assertThat(projects).extracting(Project::getCode).containsOnly(CODE1, CODE2);
}
use of io.lumeer.storage.api.query.DatabaseQuery in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testGetOrganizationsNoReadRole.
@Test
public void testGetOrganizationsNoReadRole() {
Organization organization = prepareOrganization(CODE1);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
organization.getPermissions().updateUserPermissions(userPermission);
datastore.save(organization);
Organization organization2 = prepareOrganization(CODE2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
organization2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(organization2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<Organization> organizations = organizationDao.getOrganizations(query);
assertThat(organizations).isEmpty();
}
use of io.lumeer.storage.api.query.DatabaseQuery in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testGetOrganizations.
@Test
public void testGetOrganizations() {
Organization organization = prepareOrganization(CODE1);
datastore.save(organization);
Organization organization2 = prepareOrganization(CODE2);
datastore.save(organization2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER).build();
List<Organization> organizations = organizationDao.getOrganizations(query);
assertThat(organizations).extracting(Organization::getCode).containsOnly(CODE1, CODE2);
}
Aggregations