use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testEmbeddedListContainsValueFilter.
@Test
public void testEmbeddedListContainsValueFilter() {
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(EMBEDDED_LIST_STRING_FIELD));
IFilterCriteria criteria = manager.createEmbeddedCollectionContainsValueCriteria(Model.of(STR_VALUE_1), Model.of(true));
manager.addFilterCriteria(criteria);
queryModel.addFilterCriteriaManager(EMBEDDED_LIST_STRING_FIELD, manager);
assertTrue("size must 1, but it is - " + queryModel.size(), queryModel.size() == 1);
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria in project wicket-orientdb by OrienteerBAP.
the class OQueryModel method addQueryParametersFromManager.
/**
* Add query parameters from {@link IFilterCriteriaManager}
* @param manager {@link IFilterCriteriaManager} for filtering
*/
private void addQueryParametersFromManager(IFilterCriteriaManager manager) {
Map<FilterCriteriaType, IFilterCriteria> criterias = manager.getFilterCriterias();
for (FilterCriteriaType type : criterias.keySet()) {
IFilterCriteria criteria = criterias.get(type);
if (criteria == null)
continue;
if (criteria.getModel().getObject() != null) {
if (type.equals(FilterCriteriaType.RANGE)) {
List<?> list = (List<?>) criteria.getModel().getObject();
Object first = list.get(0);
Object second = list.get(1);
if (first != null && second != null) {
setParameter(criteria.getName() + 0, Model.of((Serializable) first));
setParameter(criteria.getName() + 1, Model.of((Serializable) second));
} else
setParameter(criteria.getName(), Model.of(first != null ? (Serializable) first : (Serializable) second));
} else
setParameter(criteria.getName(), criteria.getModel());
}
}
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria 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);
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria 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);
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria 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());
}
Aggregations