Search in sources :

Example 1 with IFilterCriteriaManager

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));
}
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) 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)

Example 2 with IFilterCriteriaManager

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());
}
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) Test(org.junit.Test)

Example 3 with IFilterCriteriaManager

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

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

Example 5 with IFilterCriteriaManager

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);
}
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) IFilterCriteria(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

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