use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testRangeFilterCriteriaSecondNull.
@Test
public void testRangeFilterCriteriaSecondNull() {
List<Integer> models = Lists.newArrayList();
models.add(NUM_VALUE_3);
models.add(null);
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 2, but it is - " + queryModel.size(), queryModel.size() == 2);
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testProvider.
@Test
@SuppressWarnings("unchecked")
public void testProvider() {
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
IFilterCriteria equalsFilterCriteria = manager.createEqualsFilterCriteria(Model.of(NUM_VALUE_1), Model.of(true));
manager.addFilterCriteria(equalsFilterCriteria);
String numField = wicket.getProperty(NUMBER_FIELD).getObject().getName();
queryModel.addFilterCriteriaManager(numField, manager);
OQueryDataProvider provider = new OQueryDataProvider(queryModel);
assertTrue(queryModel.size() == queryModel.getObject().size());
assertTrue(provider.size() == queryModel.getObject().size());
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testEqualsFilterCriteria.
@Test
@SuppressWarnings("unchecked")
public void testEqualsFilterCriteria() {
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
IFilterCriteria equalsFilterCriteria = manager.createEqualsFilterCriteria(Model.of(NUM_VALUE_1), Model.of(true));
manager.addFilterCriteria(equalsFilterCriteria);
String numField = wicket.getProperty(NUMBER_FIELD).getObject().getName();
queryModel.addFilterCriteriaManager(numField, manager);
assertTrue(queryModel.getObject().size() == 1);
assertTrue(queryModel.getObject().get(0).field(NUMBER_FIELD).equals(NUM_VALUE_1));
queryModel.detach();
manager = new FilterCriteriaManager(wicket.getProperty(STRING_FIELD));
equalsFilterCriteria = manager.createEqualsFilterCriteria(Model.of(STR_VALUE_1), Model.of(true));
manager.addFilterCriteria(equalsFilterCriteria);
String strField = wicket.getProperty(STRING_FIELD).getObject().getName();
queryModel.addFilterCriteriaManager(strField, manager);
assertTrue(queryModel.getObject().size() == 1);
assertTrue(queryModel.getObject().get(0).field(STRING_FIELD).equals(STR_VALUE_1));
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testCollectionFilterCriteria.
@Test
@SuppressWarnings("unchecked")
public void testCollectionFilterCriteria() {
List<Integer> models = Lists.newArrayList();
models.add(NUM_VALUE_1);
models.add(NUM_VALUE_2);
IModel<Collection<Integer>> collectionModel = new CollectionModel<>(models);
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
manager.addFilterCriteria(manager.createCollectionFilterCriteria(collectionModel, Model.of(true)));
String field = wicket.getProperty(NUMBER_FIELD).getObject().getName();
queryModel.addFilterCriteriaManager(field, manager);
queryModel.setSort(NUMBER_FIELD, SortOrder.ASCENDING);
assertTrue(queryModel.getObject().size() == 2);
assertTrue(queryModel.getObject().get(0).field(NUMBER_FIELD).equals(NUM_VALUE_1));
assertTrue(queryModel.getObject().get(1).field(NUMBER_FIELD).equals(NUM_VALUE_2));
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class StringQueryManager method applyFilters.
private String applyFilters() {
StringBuilder sb = new StringBuilder();
int counter = 0;
for (String key : managers.keySet()) {
IFilterCriteriaManager manager = managers.get(key);
if (manager != null) {
if (manager.isFilterApply()) {
if (counter > 0)
sb.append(" AND ");
sb.append(manager.apply());
counter++;
}
}
}
return sb.toString();
}
Aggregations