Search in sources :

Example 76 with PropertySet

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

the class ContentServiceImplTest_find method dsl_query_sort.

@Test
public void dsl_query_sort() 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 77 with PropertySet

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

the class ContentServiceImplTest_find method dsl_query_geo_point.

@Test
public void dsl_query_geo_point() throws Exception {
    PropertyTree data = createPropertyTreeForAllInputTypes();
    final Content content = this.contentService.create(CreateContentParams.create().type(ContentTypeName.folder()).contentData(data).name("myContent").parent(ContentPath.ROOT).displayName("my display-name").build());
    final Content child2 = createContent(ContentPath.ROOT, "c");
    final PropertyTree request = new PropertyTree();
    final PropertySet fulltext = request.addSet("term");
    fulltext.addString("field", "data.geoPoint");
    fulltext.addString("value", "59.91273,10.74609");
    final ContentQuery queryDsl = ContentQuery.create().queryExpr(QueryExpr.from(DslExpr.from(request))).build();
    assertEquals(1, contentService.find(FindContentByQueryParams.create().contentQuery(queryDsl).build()).getHits());
}
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 78 with PropertySet

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

the class TestDataFixtures method newPropertyTree.

public static PropertyTree newPropertyTree() {
    final PropertyTree tree = new PropertyTree();
    tree.setBoolean("boolean", true);
    tree.addBooleans("boolean", true, false);
    tree.setLong("long", 1L);
    tree.addLongs("longs", 1L, 2L, 3L);
    tree.setDouble("double", 2.2);
    tree.addDoubles("doubles", 1.1, 2.2, 3.3);
    tree.setString("string", "a");
    tree.addStrings("strings", "a", "b", "c");
    tree.setString("stringEmpty", "");
    tree.setString("stringNull", null);
    tree.setString("set.property", "value");
    tree.addXml("xml", "<xml><my-xml hello='world'/></xml>");
    tree.addBinaryReference("binaryReference", BinaryReference.from("abc"));
    tree.addLink("link", Link.from(ContentPath.from("/my/content").toString()));
    tree.addGeoPoint("geoPoint", new GeoPoint(1.1, -1.1));
    tree.addGeoPoints("geoPoints", new GeoPoint(1.1, -1.1), new GeoPoint(2.2, -2.2));
    tree.addInstant("instant", Instant.MAX);
    tree.addLocalDate("localDate", LocalDate.of(2014, 1, 31));
    tree.addLocalDateTime("localDateTime", LocalDateTime.of(2014, 1, 31, 10, 30, 5));
    final PropertySet set1 = tree.addSet("c");
    set1.setBoolean("d", true);
    set1.addStrings("e", "3", "4", "5");
    set1.setLong("f", 2L);
    return tree;
}
Also used : GeoPoint(com.enonic.xp.util.GeoPoint) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 79 with PropertySet

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

the class Project method from.

public static Project from(final Repository repository) {
    if (repository == null) {
        return null;
    }
    final PropertyTree repositoryData = repository.getData();
    // TODO: remove default project data for XP8
    if (repositoryData == null) {
        return ContentConstants.CONTENT_REPO_ID.equals(repository.getId()) ? ProjectConstants.DEFAULT_PROJECT : null;
    }
    final PropertySet projectData = repositoryData.getSet(ProjectConstants.PROJECT_DATA_SET_NAME);
    if (projectData == null) {
        return ContentConstants.CONTENT_REPO_ID.equals(repository.getId()) ? ProjectConstants.DEFAULT_PROJECT : null;
    }
    final Project.Builder project = Project.create().name(ProjectName.from(repository.getId())).description(projectData.getString(ProjectConstants.PROJECT_DESCRIPTION_PROPERTY)).displayName(projectData.getString(ProjectConstants.PROJECT_DISPLAY_NAME_PROPERTY));
    buildParents(project, projectData);
    buildIcon(project, projectData);
    return project.build();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet)

Example 80 with PropertySet

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

the class DslOrderExprTest method equalsContract.

@Test
public void equalsContract() {
    final PropertySet expression1 = new PropertySet();
    expression1.addString("field", "myField");
    final PropertySet expression2 = new PropertySet();
    expression2.addString("field", "anotherField");
    EqualsVerifier.forClass(DslOrderExpr.class).withPrefabValues(PropertySet.class, expression1, expression2).usingGetClass().verify();
}
Also used : 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