Search in sources :

Example 11 with FilterCriteriaManager

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

the class TestFilters method testContainsTextFilterCriteria.

@Test
public void testContainsTextFilterCriteria() {
    IModel<OProperty> property = wicket.getProperty(STRING_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    IModel<String> model = Model.of("summer");
    manager.addFilterCriteria(manager.createContainsStringFilterCriteria(model, Model.of(true)));
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    assertTrue(queryModel.size() == 1);
    assertTrue(queryModel.getObject().get(0).field(STRING_FIELD).equals(STR_VALUE_2));
}
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 12 with FilterCriteriaManager

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

the class TestFilters method testEqualsToDateTimeFilterCriteria.

@Test
public void testEqualsToDateTimeFilterCriteria() throws ParseException {
    IModel<OProperty> property = wicket.getProperty(DATETIME_FIELD);
    IFilterCriteriaManager manager = new FilterCriteriaManager(property);
    IModel<String> model = Model.of(DATETIME_VALUE_1);
    manager.addFilterCriteria(manager.createEqualsFilterCriteria(model, Model.of(true)));
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    assertTrue(queryModel.size() == 1);
    queryModel.clearFilterCriteriaManagers();
    queryModel.detach();
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    IModel<Date> dateModel = Model.of(dateFormat.parse(DATETIME_VALUE_1));
    manager.addFilterCriteria(manager.createEqualsFilterCriteria(dateModel, Model.of(true)));
    queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
    assertTrue(queryModel.size() == 1);
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) 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)

Example 13 with FilterCriteriaManager

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

the class TestFilters method testEmbeddedContainsValueFilter.

@Test
public void testEmbeddedContainsValueFilter() {
    IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(EMBEDDED_FIELD));
    IFilterCriteria criteria = manager.createEmbeddedContainsValueCriteria(Model.of(STR_VALUE_2), Model.of(true));
    manager.addFilterCriteria(criteria);
    queryModel.addFilterCriteriaManager(EMBEDDED_FIELD, manager);
    assertTrue("size must be 1, but it is - " + queryModel.size(), queryModel.size() == 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 14 with FilterCriteriaManager

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

the class TestFilters method testRangeFilterCriteriaFirstNull.

@Test
public void testRangeFilterCriteriaFirstNull() {
    List<Integer> models = Lists.newArrayList();
    models.add(null);
    models.add(NUM_VALUE_2);
    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 15 with FilterCriteriaManager

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

the class TestFilters method testODocumentLinkQueryProvider.

@Test
public void testODocumentLinkQueryProvider() {
    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);
    ODocument doc = queryModel.getObject().get(0);
    IModel<OProperty> property = wicket.getProperty(LINK_LIST_FIELD);
    ODocumentLinksQueryDataProvider provider = new ODocumentLinksQueryDataProvider(new ODocumentModel(doc), property);
    OQueryModel<ODocument> state = provider.getFilterState();
    state.addFilterCriteriaManager(numField, manager);
    state.detach();
    assertTrue("size must be 1, but it is " + provider.size(), provider.size() == 1);
    assertTrue(state.getObject().get(0) != null);
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OProperty(com.orientechnologies.orient.core.metadata.schema.OProperty) ODocumentLinksQueryDataProvider(ru.ydn.wicket.wicketorientdb.model.ODocumentLinksQueryDataProvider) IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) FilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager) ODocumentModel(ru.ydn.wicket.wicketorientdb.model.ODocumentModel) IFilterCriteria(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) 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