use of io.lumeer.storage.api.query.DatabaseQuery in project engine by Lumeer.
the class OrganizationFacade method getOrganizations.
public List<Organization> getOrganizations() {
String userEmail = authenticatedUser.getUserEmail();
DatabaseQuery query = DatabaseQuery.createBuilder(userEmail).build();
return organizationDao.getOrganizations(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 testGetProjectsNoReadRole.
@Test
public void testGetProjectsNoReadRole() {
MorphiaProject project = prepareProject(CODE1);
Permission userPermission = new MorphiaPermission(USER2, Collections.singleton(Role.CLONE.toString()));
project.getPermissions().updateUserPermissions(userPermission);
datastore.save(projectDao.databaseCollection(), project);
MorphiaProject project2 = prepareProject(CODE2);
Permission groupPermission = new MorphiaPermission(GROUP2, Collections.singleton(Role.SHARE.toString()));
project2.getPermissions().updateGroupPermissions(groupPermission);
datastore.save(projectDao.databaseCollection(), project2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP2)).build();
List<Project> projects = projectDao.getProjects(query);
assertThat(projects).isEmpty();
}
use of io.lumeer.storage.api.query.DatabaseQuery in project engine by Lumeer.
the class MorphiaOrganizationDaoTest method testGetOrganizationsGroupRole.
@Test
public void testGetOrganizationsGroupRole() {
Organization organization = prepareOrganization(CODE1);
datastore.save(organization);
Organization organization2 = prepareOrganization(CODE2);
datastore.save(organization2);
DatabaseQuery query = DatabaseQuery.createBuilder(USER2).groups(Collections.singleton(GROUP)).build();
List<Organization> organizations = organizationDao.getOrganizations(query);
assertThat(organizations).extracting(Organization::getCode).containsOnly(CODE1, CODE2);
}
Aggregations