Search in sources :

Example 16 with FilterCriteriaManager

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager in project wicket-orientdb by OrienteerBAP.

the class TestFilters method testEmbeddedMapKey.

@Test
public void testEmbeddedMapKey() {
    String key = MAP_KEYS.get(0);
    IModel<OProperty> property = wicket.getProperty(EMBEDDED_MAP_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    manager.addFilterCriteria(manager.createMapContainsKeyCriteria(Model.of(key), Model.<Boolean>of(true)));
    queryModel.addFilterCriteriaManager(EMBEDDED_MAP_FIELD, manager);
    assertTrue("size must be 1 but it is - " + queryModel.getObject().size(), queryModel.getObject().size() == 1);
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) Test(org.junit.Test)

Example 17 with FilterCriteriaManager

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager in project wicket-orientdb by OrienteerBAP.

the class TestFilters method testRangeFilterCriteria.

@Test
public void testRangeFilterCriteria() {
    List<Integer> models = Lists.newArrayList();
    models.add(NUM_VALUE_1);
    models.add(NUM_VALUE_3);
    IModel<List<Integer>> listModel = new ListModel<>(models);
    IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
    manager.addFilterCriteria(manager.createRangeFilterCriteria(listModel, Model.of(true)));
    String field = wicket.getProperty(NUMBER_FIELD).getObject().getName();
    queryModel.addFilterCriteriaManager(field, manager);
    queryModel.setSort(NUMBER_FIELD, SortOrder.ASCENDING);
    assertTrue("size must be 3, but it is - " + queryModel.size(), queryModel.size() == 3);
    assertTrue(queryModel.getObject().get(0).field(NUMBER_FIELD).equals(NUM_VALUE_1));
    assertTrue(queryModel.getObject().get(1).field(NUMBER_FIELD).equals(NUM_VALUE_2));
    assertTrue(queryModel.getObject().get(2).field(NUMBER_FIELD).equals(NUM_VALUE_3));
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) ListModel(org.apache.wicket.model.util.ListModel) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) Test(org.junit.Test)

Example 18 with FilterCriteriaManager

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager in project wicket-orientdb by OrienteerBAP.

the class TestFilters method testLinkMapValue.

@Test
public void testLinkMapValue() {
    String key = MAP_KEYS.get(0);
    IModel<OProperty> property = wicket.getProperty(LINK_MAP_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    manager.addFilterCriteria(manager.createMapContainsKeyCriteria(Model.of(key), Model.<Boolean>of(true)));
    queryModel.addFilterCriteriaManager(LINK_MAP_FIELD, manager);
    ODocument document = queryModel.getObject().get(0);
    Map<String, ODocument> map = document.field(LINK_MAP_FIELD);
    manager.clearFilterCriterias();
    queryModel.detach();
    manager.addFilterCriteria(manager.createMapContainsValueCriteria(Model.of(map.get(STR_VALUE_1)), Model.<Boolean>of(true)));
    assertTrue("size must be 1, but it is - " + queryModel.size(), queryModel.size() == 1);
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 19 with FilterCriteriaManager

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager in project wicket-orientdb by OrienteerBAP.

the class TestFilters method testEmbeddedMapValue.

@Test
public void testEmbeddedMapValue() {
    IModel<OProperty> property = wicket.getProperty(EMBEDDED_MAP_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    manager.addFilterCriteria(manager.createMapContainsValueCriteria(Model.of(STR_VALUE_1), Model.<Boolean>of(true)));
    queryModel.addFilterCriteriaManager(EMBEDDED_MAP_FIELD, manager);
    assertTrue("size must be 1 but it is - " + queryModel.getObject().size(), queryModel.getObject().size() == 1);
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) Test(org.junit.Test)

Example 20 with FilterCriteriaManager

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager in project wicket-orientdb by OrienteerBAP.

the class TestFilters method testDateTimeCollection.

@Test
public void testDateTimeCollection() throws ParseException {
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    List<Date> list = Lists.newArrayList();
    list.add(format.parse(DATETIME_VALUE_1));
    list.add(format.parse(DATETIME_VALUE_2));
    IModel<OProperty> property = wicket.getProperty(DATETIME_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    manager.addFilterCriteria(manager.createCollectionFilterCriteria(new CollectionModel<>(list), Model.of(true)));
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    assertTrue(queryModel.getObject().size() == 2);
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) CollectionModel(org.apache.wicket.model.util.CollectionModel) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Aggregations

FilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager)24 IFilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager)24 Test (org.junit.Test)23 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)10 IFilterCriteria (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria)10 CollectionModel (org.apache.wicket.model.util.CollectionModel)5 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)4 DateFormat (java.text.DateFormat)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ListModel (org.apache.wicket.model.util.ListModel)3 ODocumentModel (ru.ydn.wicket.wicketorientdb.model.ODocumentModel)2 ODocumentLinksQueryDataProvider (ru.ydn.wicket.wicketorientdb.model.ODocumentLinksQueryDataProvider)1 OQueryDataProvider (ru.ydn.wicket.wicketorientdb.model.OQueryDataProvider)1