Search in sources :

Example 71 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_find method dsl_query_two_root_properties.

@Test
public void dsl_query_two_root_properties() throws Exception {
    final PropertyTree request = new PropertyTree();
    request.addSet("fulltext", new PropertySet());
    request.addSet("ngram", new PropertySet());
    final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request))).build();
    assertThrows(IllegalArgumentException.class, () -> contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()));
}
Also used : ContentQuery(com.enonic.xp.content.ContentQuery) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 72 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_find method dsl_query_range.

@Test
public void dsl_query_range() throws Exception {
    final Content site = createContent(ContentPath.ROOT, "a");
    final Content child3 = createContent(site.getPath(), "d");
    final Content child2 = createContent(site.getPath(), "c");
    final Content child1 = createContent(site.getPath(), "b");
    final PropertyTree request = new PropertyTree();
    final PropertySet like = new PropertySet();
    request.addSet("like", like);
    like.addString("field", "_path");
    like.addString("value", "*a/*");
    PropertyTree order = new PropertyTree();
    order.addString("field", "displayName");
    order.addString("direction", "DESC");
    ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request), DslOrderExpr.from(order))).build();
    assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child3, child2, child1);
    order = new PropertyTree();
    order.addString("field", "displayName");
    queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request), DslOrderExpr.from(order))).build();
    assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child1, child2, child3);
}
Also used : ContentQuery(com.enonic.xp.content.ContentQuery) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 73 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_find method dsl_match_all_query.

@Test
public void dsl_match_all_query() throws Exception {
    final Content site = createContent(ContentPath.ROOT, "a");
    createContent(site.getPath(), "d");
    createContent(site.getPath(), "c");
    createContent(site.getPath(), "b");
    final PropertyTree request = new PropertyTree();
    final PropertySet fulltext = new PropertySet();
    request.addSet("matchAll", fulltext);
    final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request))).build();
    assertEquals(4, contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()).getTotalHits());
}
Also used : ContentQuery(com.enonic.xp.content.ContentQuery) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 74 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_find method dsl_like_query.

@Test
public void dsl_like_query() throws Exception {
    final Content site = createContent(ContentPath.ROOT, "a");
    final Content child3 = createContent(site.getPath(), "d");
    final Content child2 = createContent(site.getPath(), "c");
    final Content child1 = createContent(site.getPath(), "b");
    final PropertyTree request = new PropertyTree();
    final PropertySet fulltext = new PropertySet();
    fulltext.addString("field", "displayName");
    fulltext.addString("value", "*d");
    request.addSet("like", fulltext);
    final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request))).build();
    final FindContentByQueryResult result = contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build());
    assertOrder(result, child3);
}
Also used : ContentQuery(com.enonic.xp.content.ContentQuery) Content(com.enonic.xp.content.Content) FindContentByQueryResult(com.enonic.xp.content.FindContentByQueryResult) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Example 75 with PropertySet

use of com.enonic.xp.data.PropertySet in project xp by enonic.

the class ContentServiceImplTest_find method dsl_query.

@Test
public void dsl_query() throws Exception {
    final Content site = createContent(ContentPath.ROOT, "a");
    final Content child3 = createContent(site.getPath(), "d");
    final Content child2 = createContent(site.getPath(), "c");
    final Content child1 = createContent(site.getPath(), "b");
    final PropertyTree request = new PropertyTree();
    final PropertySet fulltext = new PropertySet();
    fulltext.addStrings("fields", "displayName");
    fulltext.addString("query", "c");
    request.addSet("fulltext", fulltext);
    final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request))).build();
    assertOrder(contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()), child2);
}
Also used : ContentQuery(com.enonic.xp.content.ContentQuery) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Test(org.junit.jupiter.api.Test)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)225 PropertyTree (com.enonic.xp.data.PropertyTree)150 Test (org.junit.jupiter.api.Test)69 Content (com.enonic.xp.content.Content)30 Node (com.enonic.xp.node.Node)20 CreateContentParams (com.enonic.xp.content.CreateContentParams)12 ContentId (com.enonic.xp.content.ContentId)11 Property (com.enonic.xp.data.Property)11 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)10 PrincipalKey (com.enonic.xp.security.PrincipalKey)9 ContentQuery (com.enonic.xp.content.ContentQuery)7 DescriptorKey (com.enonic.xp.page.DescriptorKey)7 ExtraDatas (com.enonic.xp.content.ExtraDatas)6 Form (com.enonic.xp.form.Form)6 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)6 CreateAttachment (com.enonic.xp.attachment.CreateAttachment)5 ContentPropertyNames (com.enonic.xp.content.ContentPropertyNames)5 ExtraData (com.enonic.xp.content.ExtraData)5 PropertyPath (com.enonic.xp.data.PropertyPath)5 Page (com.enonic.xp.page.Page)5