Search in sources :

Example 6 with Project

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;
}
Also used : Project(io.lumeer.api.model.Project) Permission(io.lumeer.api.model.Permission) SimplePermission(io.lumeer.core.model.SimplePermission) SimplePermission(io.lumeer.core.model.SimplePermission)

Example 7 with Project

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);
}
Also used : Project(io.lumeer.api.model.Project)

Example 8 with 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);
}
Also used : Project(io.lumeer.api.model.Project) ResourceNotFoundException(io.lumeer.storage.api.exception.ResourceNotFoundException)

Example 9 with Project

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);
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Project(io.lumeer.api.model.Project) DatabaseQuery(io.lumeer.storage.api.query.DatabaseQuery) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Test(org.junit.Test)

Example 10 with Project

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();
}
Also used : MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Project(io.lumeer.api.model.Project) ObjectId(org.bson.types.ObjectId) MorphiaProject(io.lumeer.storage.mongodb.model.MorphiaProject) Test(org.junit.Test)

Aggregations

Project (io.lumeer.api.model.Project)46 JsonProject (io.lumeer.api.dto.JsonProject)28 Test (org.junit.Test)17 Organization (io.lumeer.api.model.Organization)16 Before (org.junit.Before)16 JsonPermission (io.lumeer.api.dto.JsonPermission)14 User (io.lumeer.api.model.User)14 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)14 JsonOrganization (io.lumeer.api.dto.JsonOrganization)13 JsonPermissions (io.lumeer.api.dto.JsonPermissions)12 Response (javax.ws.rs.core.Response)9 JsonCollection (io.lumeer.api.dto.JsonCollection)8 MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)7 SoftAssertions (org.assertj.core.api.SoftAssertions)7 SimplePermission (io.lumeer.core.model.SimplePermission)4 Permission (io.lumeer.api.model.Permission)3 MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)3 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)3 Entity (javax.ws.rs.client.Entity)3 LinkType (io.lumeer.api.model.LinkType)2