use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.
the class MongoViewDaoTest method createView.
private JsonView createView(String code, String name, Set<String> collections) {
JsonView jsonView = prepareView();
jsonView.setCode(code);
jsonView.setName(name);
jsonView.setQuery(new JsonQuery(collections, null, null));
viewDao.databaseCollection().insertOne(jsonView);
return jsonView;
}
use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.
the class ViewCodec method decode.
@Override
public JsonView decode(final BsonReader reader, final DecoderContext decoderContext) {
Document bson = documentCodec.decode(reader, decoderContext);
String id = bson.getObjectId(ID).toHexString();
String code = bson.getString(CODE);
String name = bson.getString(NAME);
String icon = bson.getString(ICON);
String color = bson.getString(COLOR);
String description = bson.getString(DESCRIPTION);
// TODO try to use better approach
JsonPermissions permissions = PermissionsCodec.convertFromDocument(bson.get(PERMISSIONS, Document.class));
JsonQuery query = QueryCodec.convertFromDocument(bson.get(QUERY, Document.class));
String perspective = bson.getString(PERSPECTIVE);
Object config = bson.get(CONFIG);
JsonView view = new JsonView(code, name, icon, color, description, permissions, query, perspective, config);
view.setId(id);
return view;
}
use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.
the class LinkInstanceFacadeIT method testGetLinkInstances.
@Test
public void testGetLinkInstances() {
String id1 = linkInstanceFacade.createLinkInstance(prepareLinkInstance()).getId();
LinkInstance linkInstance2 = prepareLinkInstance();
linkInstance2.setLinkTypeId(linkTypeId1);
linkInstance2.setDocumentIds(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(2)));
String id2 = linkInstanceFacade.createLinkInstance(linkInstance2).getId();
LinkInstance linkInstance3 = prepareLinkInstance();
linkInstance3.setLinkTypeId(linkTypeId1);
linkInstance3.setDocumentIds(Arrays.asList(documentIdsColl1.get(1), documentIdsColl2.get(1)));
String id3 = linkInstanceFacade.createLinkInstance(linkInstance3).getId();
LinkInstance linkInstance4 = prepareLinkInstance();
linkInstance4.setLinkTypeId(linkTypeId2);
linkInstance4.setDocumentIds(Arrays.asList(documentIdsColl1.get(0), documentIdsColl2.get(0)));
String id4 = linkInstanceFacade.createLinkInstance(linkInstance4).getId();
JsonQuery jsonQuery1 = new JsonQuery(null, null, Collections.singleton(documentIdsColl1.get(0)));
List<LinkInstance> linkInstances = linkInstanceFacade.getLinkInstances(jsonQuery1);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id4));
JsonQuery jsonQuery2 = new JsonQuery(null, null, Collections.singleton(documentIdsColl2.get(1)));
linkInstances = linkInstanceFacade.getLinkInstances(jsonQuery2);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Collections.singletonList(id3));
JsonQuery jsonQuery3 = new JsonQuery(null, new HashSet<>(Arrays.asList(linkTypeId1, linkTypeId2)), null);
linkInstances = linkInstanceFacade.getLinkInstances(jsonQuery3);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id3, id4));
JsonQuery jsonQuery4 = new JsonQuery(null, Collections.singleton(linkTypeId1), null);
linkInstances = linkInstanceFacade.getLinkInstances(jsonQuery4);
assertThat(linkInstances).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id3));
}
use of io.lumeer.api.dto.JsonQuery in project engine by Lumeer.
the class LinkTypeFacadeIT method testGetLinkTypes.
@Test
public void testGetLinkTypes() {
String id1 = linkTypeFacade.createLinkType(prepareLinkType()).getId();
LinkType linkType2 = prepareLinkType();
linkType2.setCollectionIds(Arrays.asList(collectionIds.get(0), collectionIds.get(2)));
String id2 = linkTypeFacade.createLinkType(linkType2).getId();
LinkType linkType3 = prepareLinkType();
linkType3.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(2)));
String id3 = linkTypeFacade.createLinkType(linkType3).getId();
LinkType linkType4 = prepareLinkType();
linkType4.setCollectionIds(Arrays.asList(collectionIds.get(1), collectionIds.get(0)));
String id4 = linkTypeFacade.createLinkType(linkType4).getId();
JsonQuery jsonQuery = new JsonQuery(Collections.singleton(collectionIds.get(0)), null, null);
List<LinkType> linkTypes = linkTypeFacade.getLinkTypes(jsonQuery);
assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id2, id4));
JsonQuery jsonQuery2 = new JsonQuery(null, new HashSet<>(Arrays.asList(id1, id3)), null);
linkTypes = linkTypeFacade.getLinkTypes(jsonQuery2);
assertThat(linkTypes).extracting("id").containsOnlyElementsOf(Arrays.asList(id1, id3));
}
use of io.lumeer.api.dto.JsonQuery 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));
}
Aggregations