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);
}
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());
}
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;
}
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();
}
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();
}
Aggregations