Search in sources :

Example 16 with QueryStem

use of io.lumeer.api.model.QueryStem in project engine by Lumeer.

the class SearchFacadeIT method testSearchDocumentsByCollectionIds.

@Test
public void testSearchDocumentsByCollectionIds() {
    String id1 = createDocument(collectionIds.get(0), "doc1").getId();
    String id2 = createDocument(collectionIds.get(0), "doc2").getId();
    createDocument(collectionIds.get(1), "doc3");
    createDocument(collectionIds.get(1), "doc4");
    String id5 = createDocument(collectionIds.get(2), "doc5").getId();
    String id6 = createDocument(collectionIds.get(2), "doc6").getId();
    QueryStem stem1 = new QueryStem(collectionIds.get(0));
    QueryStem stem2 = new QueryStem(collectionIds.get(2));
    Query query = new Query(Arrays.asList(stem1, stem2));
    List<Document> documents = searchFacade.searchDocuments(query, true);
    assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id5, id6);
}
Also used : Query(io.lumeer.api.model.Query) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) QueryStem(io.lumeer.api.model.QueryStem) Test(org.junit.Test)

Example 17 with QueryStem

use of io.lumeer.api.model.QueryStem in project engine by Lumeer.

the class SearchFacadeIT method testSearchDocumentsWithLinks.

@Test
public void testSearchDocumentsWithLinks() {
    String id1 = createDocument(collectionIds.get(0), "lumeer lol").getId();
    String id2 = createDocument(collectionIds.get(0), "lol").getId();
    String id3 = createDocument(collectionIds.get(0), "lmr").getId();
    String id4 = createDocument(collectionIds.get(0), "lalamr").getId();
    String id5 = createDocument(collectionIds.get(0), "something fulltext").getId();
    String id6 = createDocument(collectionIds.get(1), "lmr").getId();
    String id7 = createDocument(collectionIds.get(1), "other lol").getId();
    String id8 = createDocument(collectionIds.get(1), "o lmr").getId();
    String id9 = createDocument(collectionIds.get(1), "lumeer").getId();
    String id10 = createDocument(collectionIds.get(2), "mr").getId();
    String id11 = createDocument(collectionIds.get(2), "mr lumr").getId();
    String id12 = createDocument(collectionIds.get(2), "lol").getId();
    String linkType01Id = linkTypeDao.createLinkType(new LinkType("lmr", Arrays.asList(collectionIds.get(0), collectionIds.get(1)), Collections.emptyList(), null, null, null)).getId();
    String linkType12Id = linkTypeDao.createLinkType(new LinkType("lmrr", Arrays.asList(collectionIds.get(1), collectionIds.get(2)), Collections.emptyList(), null, null, null)).getId();
    createLinkInstance(linkType01Id, Arrays.asList(id1, id6));
    createLinkInstance(linkType01Id, Arrays.asList(id1, id7));
    createLinkInstance(linkType01Id, Arrays.asList(id2, id8));
    createLinkInstance(linkType01Id, Arrays.asList(id3, id8));
    createLinkInstance(linkType01Id, Arrays.asList(id4, id6));
    createLinkInstance(linkType12Id, Arrays.asList(id6, id10));
    createLinkInstance(linkType12Id, Arrays.asList(id6, id11));
    createLinkInstance(linkType12Id, Arrays.asList(id7, id12));
    QueryStem stem = new QueryStem(null, collectionIds.get(0), Arrays.asList(linkType01Id, linkType12Id), Collections.emptySet(), Collections.emptyList(), Collections.emptyList());
    Query query = new Query(Collections.singletonList(stem), Collections.emptySet(), null, null);
    List<Document> documents = searchFacade.searchDocuments(query, true);
    assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id3, id4, id5, id6, id7, id8, id9, id10, id11, id12);
    stem = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkType01Id), Collections.emptySet(), Collections.emptyList(), Collections.emptyList());
    query = new Query(Collections.singletonList(stem), Collections.singleton("lol"), null, null);
    documents = searchFacade.searchDocuments(query, true);
    assertThat(documents).extracting(Document::getId).containsOnly(id1, id2, id6, id7, id8);
    stem = new QueryStem(null, collectionIds.get(1), Collections.singletonList(linkType12Id), Collections.emptySet(), Collections.emptyList(), Collections.emptyList());
    query = new Query(Collections.singletonList(stem), Collections.singleton("lumr"), null, null);
    documents = searchFacade.searchDocuments(query, true);
    assertThat(documents).extracting(Document::getId).containsOnly(id11, id6);
}
Also used : Query(io.lumeer.api.model.Query) LinkType(io.lumeer.api.model.LinkType) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) QueryStem(io.lumeer.api.model.QueryStem) Test(org.junit.Test)

Example 18 with QueryStem

use of io.lumeer.api.model.QueryStem in project engine by Lumeer.

the class SearchFacadeIT method testCyclicChildDocuments.

@Test
public void testCyclicChildDocuments() {
    final Document a0 = createDocument(collectionIds.get(0), "a0");
    final Document a1 = createDocument(collectionIds.get(0), "a1", a0.getId());
    final Document a2 = createDocument(collectionIds.get(0), "a2", a1.getId());
    a0.setMetaData(new DataDocument(Document.META_PARENT_ID, a2.getId()));
    documentDao.updateDocument(a0.getId(), a0);
    Query query = new Query(new QueryStem(null, collectionIds.get(0), Collections.emptyList(), Collections.singleton(a0.getId()), Collections.emptyList(), Collections.emptyList()));
    List<Document> documents = searchFacade.searchDocuments(query, true);
    assertThat(documents).hasSize(3);
    var parents = documents.stream().map(d -> d.getMetaData().getString(Document.META_PARENT_ID)).collect(Collectors.toList());
    var ids = documents.stream().map(Document::getId).collect(Collectors.toList());
    assertThat(ids).hasSize(3);
    assertThat(parents).hasSize(3);
    assertThat(parents).containsAll(ids);
}
Also used : Arrays(java.util.Arrays) ProjectDao(io.lumeer.storage.api.dao.ProjectDao) Arquillian(org.jboss.arquillian.junit.Arquillian) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ZonedDateTime(java.time.ZonedDateTime) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.auth.AuthenticatedUser) LinkTypeDao(io.lumeer.storage.api.dao.LinkTypeDao) WorkspaceKeeper(io.lumeer.core.WorkspaceKeeper) CollectionDao(io.lumeer.storage.api.dao.CollectionDao) QueryStem(io.lumeer.api.model.QueryStem) Map(java.util.Map) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) Permission(io.lumeer.api.model.Permission) RoleType(io.lumeer.api.model.RoleType) DataDocument(io.lumeer.engine.api.data.DataDocument) ConditionValueType(io.lumeer.api.model.ConditionValueType) Document(io.lumeer.api.model.Document) Set(java.util.Set) PermissionsChecker(io.lumeer.core.auth.PermissionsChecker) Constraint(io.lumeer.api.model.Constraint) Collectors(java.util.stream.Collectors) LinkInstance(io.lumeer.api.model.LinkInstance) LinkType(io.lumeer.api.model.LinkType) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) List(java.util.List) Attribute(io.lumeer.api.model.Attribute) ConstraintType(io.lumeer.api.model.ConstraintType) CollectionAttributeFilter(io.lumeer.api.model.CollectionAttributeFilter) UserDao(io.lumeer.storage.api.dao.UserDao) SoftAssertions(org.assertj.core.api.SoftAssertions) RunWith(org.junit.runner.RunWith) CollectionPurpose(io.lumeer.api.model.CollectionPurpose) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) OrganizationDao(io.lumeer.storage.api.dao.OrganizationDao) Language(io.lumeer.api.model.Language) Role(io.lumeer.api.model.Role) DataDao(io.lumeer.storage.api.dao.DataDao) Query(io.lumeer.api.model.Query) Organization(io.lumeer.api.model.Organization) Before(org.junit.Before) ConditionType(io.lumeer.api.model.ConditionType) DocumentDao(io.lumeer.storage.api.dao.DocumentDao) Permissions(io.lumeer.api.model.Permissions) Test(org.junit.Test) CollectionPurposeType(io.lumeer.api.model.CollectionPurposeType) Project(io.lumeer.api.model.Project) LinkInstanceDao(io.lumeer.storage.api.dao.LinkInstanceDao) IntegrationTestBase(io.lumeer.engine.IntegrationTestBase) LinkDataDao(io.lumeer.storage.api.dao.LinkDataDao) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) DataDocument(io.lumeer.engine.api.data.DataDocument) Query(io.lumeer.api.model.Query) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) QueryStem(io.lumeer.api.model.QueryStem) Test(org.junit.Test)

Example 19 with QueryStem

use of io.lumeer.api.model.QueryStem in project engine by Lumeer.

the class SearchFacadeIT method testSearchLinkInstances.

@Test
public void testSearchLinkInstances() {
    LinkType linkType = new LinkType("nm", Arrays.asList(collectionIds.get(0), collectionIds.get(1)), Collections.emptyList(), null, null, null);
    String linkTypeId1 = linkTypeDao.createLinkType(linkType).getId();
    LinkType linkType2 = new LinkType("nm2", Arrays.asList(collectionIds.get(0), collectionIds.get(1)), Collections.emptyList(), null, null, null);
    String linkTypeId2 = linkTypeDao.createLinkType(linkType2).getId();
    String id10 = createDocument(collectionIds.get(0), "lumeer").getId();
    String id11 = createDocument(collectionIds.get(0), "lumeer").getId();
    String id12 = createDocument(collectionIds.get(0), "lumeer").getId();
    String id20 = createDocument(collectionIds.get(1), "lumeer").getId();
    String id21 = createDocument(collectionIds.get(1), "lumeer").getId();
    String id22 = createDocument(collectionIds.get(1), "lumeer").getId();
    String id1 = createLinkInstance(linkTypeId1, Arrays.asList(id10, id20)).getId();
    String id2 = createLinkInstance(linkTypeId1, Arrays.asList(id10, id22)).getId();
    String id3 = createLinkInstance(linkTypeId1, Arrays.asList(id11, id21)).getId();
    String id4 = createLinkInstance(linkTypeId2, Arrays.asList(id10, id20)).getId();
    QueryStem stem1 = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkTypeId1), Collections.singleton(id10), null, null);
    Query query1 = new Query(stem1);
    List<LinkInstance> linkInstances = searchFacade.searchLinkInstances(query1, true);
    assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id1, id2);
    QueryStem stem2 = new QueryStem(null, collectionIds.get(1), Collections.singletonList(linkTypeId1), Collections.singleton(id21), null, null);
    Query query = new Query(stem2);
    linkInstances = searchFacade.searchLinkInstances(query, true);
    assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id3);
    QueryStem stem3 = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkTypeId2), null, null, null);
    Query query3 = new Query(stem3);
    linkInstances = searchFacade.searchLinkInstances(query3, true);
    assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id4);
    QueryStem stem4 = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkTypeId1), null, null, null);
    Query query4 = new Query(stem4);
    linkInstances = searchFacade.searchLinkInstances(query4, true);
    assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id1, id2, id3);
    QueryStem stem5 = new QueryStem(null, collectionIds.get(0), Collections.singletonList(linkTypeId2), Collections.singleton(id20), null, null);
    Query query5 = new Query(stem5);
    linkInstances = searchFacade.searchLinkInstances(query5, true);
    assertThat(linkInstances).extracting(LinkInstance::getId).containsOnly(id4);
}
Also used : Query(io.lumeer.api.model.Query) LinkInstance(io.lumeer.api.model.LinkInstance) LinkType(io.lumeer.api.model.LinkType) QueryStem(io.lumeer.api.model.QueryStem) Test(org.junit.Test)

Example 20 with QueryStem

use of io.lumeer.api.model.QueryStem in project engine by Lumeer.

the class SearchFacadeIT method testSearchDocumentsByIds.

@Test
public void testSearchDocumentsByIds() {
    String id1 = createDocument(collectionIds.get(0), "doc1").getId();
    createDocument(collectionIds.get(0), "doc2");
    String id3 = createDocument(collectionIds.get(1), "doc3").getId();
    String id4 = createDocument(collectionIds.get(1), "doc4").getId();
    createDocument(collectionIds.get(2), "doc5");
    String id6 = createDocument(collectionIds.get(2), "doc6").getId();
    QueryStem stem1 = new QueryStem(null, collectionIds.get(0), Collections.emptyList(), Collections.singleton(id1), Collections.emptyList(), Collections.emptyList());
    QueryStem stem2 = new QueryStem(null, collectionIds.get(1), Collections.emptyList(), new HashSet<>(Arrays.asList(id3, id4)), Collections.emptyList(), Collections.emptyList());
    QueryStem stem3 = new QueryStem(null, collectionIds.get(2), Collections.emptyList(), Collections.singleton(id6), Collections.emptyList(), Collections.emptyList());
    Query query = new Query(Arrays.asList(stem1, stem2, stem3));
    List<Document> documents = searchFacade.searchDocuments(query, true);
    assertThat(documents).extracting(Document::getId).containsOnly(id1, id3, id4, id6);
}
Also used : Query(io.lumeer.api.model.Query) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) QueryStem(io.lumeer.api.model.QueryStem) Test(org.junit.Test)

Aggregations

Query (io.lumeer.api.model.Query)22 QueryStem (io.lumeer.api.model.QueryStem)22 Test (org.junit.Test)14 Collection (io.lumeer.api.model.Collection)8 Document (io.lumeer.api.model.Document)8 Role (io.lumeer.api.model.Role)8 DataDocument (io.lumeer.engine.api.data.DataDocument)8 Permission (io.lumeer.api.model.Permission)7 Permissions (io.lumeer.api.model.Permissions)7 Project (io.lumeer.api.model.Project)6 View (io.lumeer.api.model.View)6 ArrayList (java.util.ArrayList)6 CollectionAttributeFilter (io.lumeer.api.model.CollectionAttributeFilter)5 LinkInstance (io.lumeer.api.model.LinkInstance)5 LinkType (io.lumeer.api.model.LinkType)5 Organization (io.lumeer.api.model.Organization)5 User (io.lumeer.api.model.User)5 AuthenticatedUser (io.lumeer.core.auth.AuthenticatedUser)5 Before (org.junit.Before)5 LumeerAssertions.assertPermissions (io.lumeer.test.util.LumeerAssertions.assertPermissions)4