use of io.lumeer.api.model.LinkType in project engine by Lumeer.
the class LinkTypeServiceIT method testGetLinkTypesByIds.
@Test
public void testGetLinkTypesByIds() {
String id1 = linkTypeDao.createLinkType(prepareLinkType()).getId();
LinkType linkType2 = prepareLinkType();
linkType2.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(2)));
linkTypeDao.createLinkType(linkType2);
LinkType linkType3 = prepareLinkType();
linkType3.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(0)));
String id3 = linkTypeDao.createLinkType(linkType3).getId();
LinkType linkType4 = prepareLinkType();
linkType4.setCollectionIds(Arrays.asList(collectionIds.get(0), collectionIds.get(2)));
linkTypeDao.createLinkType(linkType4);
JsonQuery jsonQuery = new JsonQuery(null, new HashSet<>(Arrays.asList(id1, id3)), null);
Entity entity = Entity.json(jsonQuery);
Response response = client.target(LINK_TYPES_URL).path("search").request(MediaType.APPLICATION_JSON).buildPost(entity).invoke();
assertThat(response).isNotNull();
assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
List<LinkType> linkTypes = response.readEntity(new GenericType<List<LinkType>>() {
});
assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id3));
}
use of io.lumeer.api.model.LinkType in project engine by Lumeer.
the class LinkTypeFacade method deleteLinkType.
public void deleteLinkType(String id) {
LinkType linkType = linkTypeDao.getLinkType(id);
checkLinkTypePermission(linkType.getCollectionIds());
linkTypeDao.deleteLinkType(id);
}
use of io.lumeer.api.model.LinkType in project engine by Lumeer.
the class CollectionFacade method deleteCollection.
public void deleteCollection(String collectionId) {
Collection collection = collectionDao.getCollectionById(collectionId);
permissionsChecker.checkRole(collection, Role.MANAGE);
collectionDao.deleteCollection(collectionId);
documentDao.deleteDocuments(collectionId);
dataDao.deleteDataRepository(collectionId);
SearchQuery queryLinkTypes = createQueryForLinkTypes(collectionId);
List<LinkType> linkTypes = linkTypeDao.getLinkTypes(queryLinkTypes);
if (!linkTypes.isEmpty()) {
linkTypeDao.deleteLinkTypes(queryLinkTypes);
linkInstanceDao.deleteLinkInstances(createQueryForLinkInstances(linkTypes));
}
}
use of io.lumeer.api.model.LinkType in project engine by Lumeer.
the class MongoLinkTypeDaoTest method testDeleteLinkTypesByIds.
@Test
public void testDeleteLinkTypesByIds() throws InterruptedException {
String id1 = linkTypeDao.createLinkType(prepareLinkType()).getId();
LinkType linkType2 = prepareLinkType();
linkType2.setName(NAME2);
String id2 = linkTypeDao.createLinkType(linkType2).getId();
LinkType linkType3 = prepareLinkType();
linkType3.setName(NAME3);
String id3 = linkTypeDao.createLinkType(linkType3).getId();
LinkType linkType4 = prepareLinkType();
linkType4.setName(NAME4);
String id4 = linkTypeDao.createLinkType(linkType4).getId();
assertThat(linkTypeDao.databaseCollection().find().into(new ArrayList<>()).size()).isEqualTo(4);
SearchQuery query = SearchQuery.createBuilder(USER).linkTypeIds(new HashSet<>(Arrays.asList(id1, id4))).build();
linkTypeDao.deleteLinkTypes(query);
List<LinkType> linkTypes = linkTypeDao.databaseCollection().find().into(new ArrayList<>());
assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id2, id3));
}
use of io.lumeer.api.model.LinkType in project engine by Lumeer.
the class MongoLinkTypeDaoTest method testCreateLinkType.
@Test
public void testCreateLinkType() {
LinkType linkType = prepareLinkType();
String id = linkTypeDao.createLinkType(linkType).getId();
assertThat(id).isNotNull().isNotEmpty();
assertThat(ObjectId.isValid(id)).isTrue();
LinkType storedLinkType = linkTypeDao.getLinkType(id);
assertThat(storedLinkType).isNotNull();
assertThat(storedLinkType.getName()).isEqualTo(NAME);
assertThat(storedLinkType.getAttributes()).isEqualTo(ATTRIBUTES);
assertThat(storedLinkType.getCollectionIds()).containsOnlyElementsOf(Arrays.asList(COLLECTION_ID1, COLLECTION_ID2));
}
Aggregations