use of io.lumeer.api.dto.JsonCollection in project engine by Lumeer.
the class LinkInstanceFacadeIT method configureLinkInstances.
@Before
public void configureLinkInstances() {
JsonOrganization organization = new JsonOrganization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new JsonPermissions());
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
User user = new User(USER);
userDao.createUser(user);
JsonProject project = new JsonProject();
project.setPermissions(new JsonPermissions());
project.setCode(PROJECT_CODE);
Project storedProject = projectDao.createProject(project);
workspaceKeeper.setWorkspace(ORGANIZATION_CODE, PROJECT_CODE);
collectionDao.setProject(storedProject);
JsonPermissions collectionPermissions = new JsonPermissions();
collectionPermissions.updateUserPermissions(new JsonPermission(USER, Project.ROLES.stream().map(Role::toString).collect(Collectors.toSet())));
JsonCollection jsonCollection = new JsonCollection("col1", "col1", "icon", "color", collectionPermissions);
jsonCollection.setDocumentsCount(0);
String collection1 = collectionDao.createCollection(jsonCollection).getId();
JsonCollection jsonCollection2 = new JsonCollection("col2", "col2", "icon", "color", collectionPermissions);
jsonCollection.setDocumentsCount(0);
String collection2 = collectionDao.createCollection(jsonCollection2).getId();
LinkType linkType = new LinkType(null, NAME, Arrays.asList(collection1, collection2), ATTRIBUTES);
linkTypeId1 = linkTypeDao.createLinkType(linkType).getId();
LinkType linkType2 = new LinkType(null, NAME2, Arrays.asList(collection1, collection2), ATTRIBUTES);
linkTypeId2 = linkTypeDao.createLinkType(linkType2).getId();
documentIdsColl1.clear();
for (int i = 0; i < 3; i++) {
documentIdsColl1.add(createDocument(collection1).getId());
}
documentIdsColl2.clear();
for (int i = 0; i < 3; i++) {
documentIdsColl2.add(createDocument(collection2).getId());
}
}
use of io.lumeer.api.dto.JsonCollection in project engine by Lumeer.
the class LinkTypeFacadeIT method configureLinkTypes.
@Before
public void configureLinkTypes() {
JsonOrganization organization = new JsonOrganization();
organization.setCode(ORGANIZATION_CODE);
organization.setPermissions(new JsonPermissions());
Organization storedOrganization = organizationDao.createOrganization(organization);
projectDao.setOrganization(storedOrganization);
User user = new User(USER);
userDao.createUser(user);
JsonProject project = new JsonProject();
project.setPermissions(new JsonPermissions());
project.setCode(PROJECT_CODE);
Project storedProject = projectDao.createProject(project);
workspaceKeeper.setWorkspace(ORGANIZATION_CODE, PROJECT_CODE);
collectionDao.setProject(storedProject);
collectionIds.clear();
for (String name : COLLECTION_NAMES) {
JsonPermissions collectionPermissions = new JsonPermissions();
collectionPermissions.updateUserPermissions(new JsonPermission(USER, Project.ROLES.stream().map(Role::toString).collect(Collectors.toSet())));
JsonCollection jsonCollection = new JsonCollection(name, name, COLLECTION_ICON, COLLECTION_COLOR, collectionPermissions);
jsonCollection.setDocumentsCount(0);
collectionIds.add(collectionDao.createCollection(jsonCollection).getId());
}
}
use of io.lumeer.api.dto.JsonCollection in project engine by Lumeer.
the class CollectionServiceIT method testCreateCollection.
@Test
public void testCreateCollection() {
Collection collection = prepareCollection(CODE);
Entity entity = Entity.json(collection);
Response response = client.target(COLLECTIONS_URL).request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
JsonCollection returnedCollection = response.readEntity(JsonCollection.class);
assertThat(returnedCollection).isNotNull();
assertThat(returnedCollection.getId()).isNotNull();
Collection storedCollection = collectionDao.getCollectionByCode(CODE);
assertThat(storedCollection).isNotNull();
assertThat(returnedCollection.getId()).isEqualTo(storedCollection.getId());
SoftAssertions assertions = new SoftAssertions();
assertions.assertThat(storedCollection.getCode()).isEqualTo(CODE);
assertions.assertThat(storedCollection.getName()).isEqualTo(NAME);
assertions.assertThat(storedCollection.getIcon()).isEqualTo(ICON);
assertions.assertThat(storedCollection.getColor()).isEqualTo(COLOR);
assertions.assertThat(storedCollection.getPermissions().getUserPermissions()).containsOnly(USER_PERMISSION);
assertions.assertThat(storedCollection.getPermissions().getGroupPermissions()).isEmpty();
assertions.assertAll();
}
use of io.lumeer.api.dto.JsonCollection in project engine by Lumeer.
the class CollectionServiceIT method testGetAllCollections.
@Test
public void testGetAllCollections() {
createCollection(CODE);
createCollection(CODE2);
Response response = client.target(COLLECTIONS_URL).request(MediaType.APPLICATION_JSON).buildGet().invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<JsonCollection> collections = response.readEntity(new GenericType<List<JsonCollection>>() {
});
assertThat(collections).extracting(Resource::getCode).containsOnly(CODE, CODE2);
Permissions permissions1 = collections.get(0).getPermissions();
assertThat(permissions1).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions1).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions1).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
Permissions permissions2 = collections.get(1).getPermissions();
assertThat(permissions2).extracting(Permissions::getUserPermissions).containsOnly(Collections.singleton(USER_PERMISSION));
assertThat(permissions2).extracting(p -> p.getUserPermissions().iterator().next().getRoles()).containsOnly(USER_ROLES);
assertThat(permissions2).extracting(Permissions::getGroupPermissions).containsOnly(Collections.emptySet());
}
use of io.lumeer.api.dto.JsonCollection in project engine by Lumeer.
the class CollectionService method getCollections.
@GET
public List<JsonCollection> getCollections(@QueryParam("page") Integer page, @QueryParam("pageSize") Integer pageSize) {
Pagination pagination = new Pagination(page, pageSize);
List<Collection> collections = collectionFacade.getCollections(pagination);
return JsonCollection.convert(collections);
}
Aggregations