use of io.lumeer.api.model.Project in project engine by Lumeer.
the class ProjectFacade method createProject.
public Project createProject(Project project) {
checkOrganizationWriteRole();
Permission defaultUserPermission = new SimplePermission(authenticatedUser.getCurrentUsername(), Project.ROLES);
project.getPermissions().updateUserPermissions(defaultUserPermission);
Project storedProject = projectDao.createProject(project);
createProjectScopedRepositories(storedProject);
return storedProject;
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class ProjectFacade method removeGroupPermission.
public void removeGroupPermission(final String projectCode, final String group) {
Project project = projectDao.getProjectByCode(projectCode);
permissionsChecker.checkRole(project, Role.MANAGE);
project.getPermissions().removeGroupPermission(group);
projectDao.updateProject(project.getId(), project);
}
use of io.lumeer.api.model.Project in project engine by Lumeer.
the class CollectionFacade method checkProjectWriteRole.
private void checkProjectWriteRole() {
if (!workspaceKeeper.getProject().isPresent()) {
throw new ResourceNotFoundException(ResourceType.PROJECT);
}
Project project = workspaceKeeper.getProject().get();
permissionsChecker.checkRole(project, Role.WRITE);
}
use of io.lumeer.api.model.Project 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.api.model.Project in project engine by Lumeer.
the class MorphiaProjectDaoTest method testDeleteProject.
@Test
public void testDeleteProject() {
MorphiaProject project = prepareProject(CODE1);
datastore.save(projectDao.databaseCollection(), project);
assertThat(project.getId()).isNotNull();
projectDao.deleteProject(project.getId());
Project storedProject = datastore.get(projectDao.databaseCollection(), MorphiaProject.class, new ObjectId(project.getId()));
assertThat(storedProject).isNull();
}
Aggregations