Search in sources :

Example 21 with IFilterCriteriaManager

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);
}
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 22 with IFilterCriteriaManager

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());
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OQueryDataProvider(ru.ydn.wicket.wicketorientdb.model.OQueryDataProvider) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) IFilterCriteria(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria) Test(org.junit.Test)

Example 23 with IFilterCriteriaManager

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));
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) IFilterCriteria(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria) Test(org.junit.Test)

Example 24 with IFilterCriteriaManager

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));
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) CollectionModel(org.apache.wicket.model.util.CollectionModel) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) Test(org.junit.Test)

Example 25 with IFilterCriteriaManager

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();
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager)

Aggregations

IFilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager)25 FilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager)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