Search in sources :

Example 1 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization in project engine by Lumeer.

the class MorphiaOrganizationDaoTest method prepareOrganization.

private MorphiaOrganization prepareOrganization(String code) {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(code);
    organization.setName(NAME);
    organization.setColor(COLOR);
    organization.setIcon(ICON);
    organization.setPermissions(new MorphiaPermissions(PERMISSIONS));
    return organization;
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)

Example 2 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization in project engine by Lumeer.

the class MorphiaOrganizationDaoTest method testUpdateOrganizationPermissions.

@Test
public void testUpdateOrganizationPermissions() {
    MorphiaOrganization organization = prepareOrganization(CODE1);
    String id = datastore.save(organization).getId().toString();
    assertThat(id).isNotNull().isNotEmpty();
    organization.getPermissions().removeUserPermission(USER);
    organization.getPermissions().updateGroupPermissions(GROUP_PERMISSION);
    organizationDao.updateOrganization(id, organization);
    MorphiaOrganization storedOrganization = datastore.get(MorphiaOrganization.class, new ObjectId(id));
    assertThat(storedOrganization).isNotNull();
    assertThat(storedOrganization.getPermissions().getUserPermissions()).isEmpty();
    assertThat(storedOrganization.getPermissions().getGroupPermissions()).containsExactly(GROUP_PERMISSION);
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) ObjectId(org.bson.types.ObjectId) Test(org.junit.Test)

Example 3 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization in project engine by Lumeer.

the class MorphiaOrganizationDao method createOrganization.

@Override
public Organization createOrganization(final Organization organization) {
    MorphiaOrganization morphiaOrganization = new MorphiaOrganization(organization);
    datastore.insert(morphiaOrganization);
    return morphiaOrganization;
}
Also used : MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization)

Example 4 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization in project engine by Lumeer.

the class ProjectFacadeIT method configureProject.

@Before
public void configureProject() {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new MorphiaPermissions());
    organization.getPermissions().updateUserPermissions(new MorphiaPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    User user = new User(USER);
    userDao.createUser(user);
    workspaceKeeper.setOrganization(ORGANIZATION_CODE);
}
Also used : Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Example 5 with MorphiaOrganization

use of io.lumeer.storage.mongodb.model.MorphiaOrganization in project engine by Lumeer.

the class ProjectServiceIT method configureProject.

@Before
public void configureProject() {
    MorphiaOrganization organization = new MorphiaOrganization();
    organization.setCode(ORGANIZATION_CODE);
    organization.setPermissions(new MorphiaPermissions());
    organization.getPermissions().updateUserPermissions(new MorphiaPermission(USER, Role.toStringRoles(new HashSet<>(Arrays.asList(Role.WRITE, Role.READ, Role.MANAGE)))));
    Organization storedOrganization = organizationDao.createOrganization(organization);
    projectDao.setOrganization(storedOrganization);
    User user = new User(USER);
    userDao.createUser(user);
}
Also used : Organization(io.lumeer.api.model.Organization) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.AuthenticatedUser) MorphiaPermission(io.lumeer.storage.mongodb.model.embedded.MorphiaPermission) MorphiaOrganization(io.lumeer.storage.mongodb.model.MorphiaOrganization) MorphiaPermissions(io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions) Before(org.junit.Before)

Aggregations

MorphiaOrganization (io.lumeer.storage.mongodb.model.MorphiaOrganization)12 MorphiaPermissions (io.lumeer.storage.mongodb.model.embedded.MorphiaPermissions)6 Organization (io.lumeer.api.model.Organization)5 User (io.lumeer.api.model.User)5 AuthenticatedUser (io.lumeer.core.AuthenticatedUser)5 Before (org.junit.Before)5 MorphiaPermission (io.lumeer.storage.mongodb.model.embedded.MorphiaPermission)3 Test (org.junit.Test)3 Project (io.lumeer.api.model.Project)2 MorphiaProject (io.lumeer.storage.mongodb.model.MorphiaProject)2 ObjectId (org.bson.types.ObjectId)2 JsonOrganization (io.lumeer.api.dto.JsonOrganization)1 ArrayList (java.util.ArrayList)1 FindOptions (org.mongodb.morphia.query.FindOptions)1