use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testLinkFilter.
@Test
public void testLinkFilter() {
IModel<OProperty> property = wicket.getProperty(NUMBER_FIELD);
IFilterCriteriaManager manager = new FilterCriteriaManager(property);
IFilterCriteria equalsFilterCriteria = manager.createEqualsFilterCriteria(Model.of(NUM_VALUE_1), Model.of(true));
manager.addFilterCriteria(equalsFilterCriteria);
queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
ODocument document = queryModel.getObject().get(0).field(LINK_FIELD);
queryModel.clearFilterCriteriaManagers();
queryModel.detach();
property = wicket.getProperty(LINK_FIELD);
manager = new FilterCriteriaManager(property);
equalsFilterCriteria = manager.createEqualsFilterCriteria(new ODocumentModel(document), Model.of(true));
manager.addFilterCriteria(equalsFilterCriteria);
queryModel.addFilterCriteriaManager(property.getObject().getName(), manager);
assertTrue(queryModel.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 testFilterCriteriaManager.
@Test
public void testFilterCriteriaManager() {
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(STRING_FIELD));
assertFalse(manager.isFilterApply());
manager.addFilterCriteria(manager.createEqualsFilterCriteria(Model.of(NUM_VALUE_1), Model.of(true)));
assertTrue(manager.isFilterApply());
manager.clearFilterCriterias();
assertFalse(manager.isFilterApply());
IModel<Integer> model = Model.of(NUM_VALUE_1);
manager.addFilterCriteria(manager.createEqualsFilterCriteria(model, Model.of(true)));
assertTrue(manager.isFilterApply());
model.setObject(null);
assertFalse(manager.isFilterApply());
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testEmbeddedContainsKeyFilter.
@Test
public void testEmbeddedContainsKeyFilter() {
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(EMBEDDED_FIELD));
IFilterCriteria criteria = manager.createEmbeddedContainsKeyCriteria(Model.of(STRING_FIELD), Model.of(true));
manager.addFilterCriteria(criteria);
queryModel.addFilterCriteriaManager(EMBEDDED_FIELD, manager);
assertTrue("size must be more than 0, but it is - " + queryModel.size(), queryModel.size() > 0);
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testEmbeddedListFilter.
@Test
public void testEmbeddedListFilter() {
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(EMBEDDED_LIST_FIELD));
List<String> list = new ArrayList<>();
list.add(STR_VALUE_2);
IModel<Collection<String>> model = new CollectionModel<String>(list);
IFilterCriteria criteria = manager.createEmbeddedCollectionCriteria(Model.of(STRING_FIELD), model, Model.of(true));
manager.addFilterCriteria(criteria);
queryModel.addFilterCriteriaManager(EMBEDDED_LIST_FIELD, manager);
assertTrue("size must be more than 0, but it is - " + queryModel.size(), queryModel.size() > 0);
}
use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager in project wicket-orientdb by OrienteerBAP.
the class TestFilters method testLinkCollectionFilter.
@Test
public void testLinkCollectionFilter() {
IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(NUMBER_FIELD));
List<Integer> models = Lists.newArrayList();
models.add(NUM_VALUE_1);
models.add(NUM_VALUE_2);
IModel<Collection<Integer>> collectionModel = new CollectionModel<>(models);
IFilterCriteria collectionFilterCriteria = manager.createCollectionFilterCriteria(collectionModel, Model.of(true));
manager.addFilterCriteria(collectionFilterCriteria);
String numField = wicket.getProperty(NUMBER_FIELD).getObject().getName();
queryModel.addFilterCriteriaManager(numField, manager);
manager = new FilterCriteriaManager(wicket.getProperty(LINK_FIELD));
ODocument doc1 = queryModel.getObject().get(0).field(LINK_FIELD);
ODocument doc2 = queryModel.getObject().get(1).field(LINK_FIELD);
IFilterCriteria criteria = manager.createLinkCollectionFilterCriteria(new CollectionModel<>(Arrays.asList(doc1, doc2)), true, Model.of(true));
queryModel.detach();
manager.addFilterCriteria(criteria);
queryModel.clearFilterCriteriaManagers();
queryModel.addFilterCriteriaManager(wicket.getProperty(LINK_FIELD).getObject().getName(), manager);
assertTrue(queryModel.getObject().size() == 2);
}
Aggregations