Search in sources :

Example 1 with IFilterCriteria

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria 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 IFilterCriteria

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria 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 3 with IFilterCriteria

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria 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 4 with IFilterCriteria

use of ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria 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)

Example 5 with IFilterCriteria

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

the class TestFilters method testEmbeddedSetFilter.

@Test
public void testEmbeddedSetFilter() {
    IFilterCriteriaManager manager = new FilterCriteriaManager(wicket.getProperty(EMBEDDED_SET_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_SET_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)

Aggregations

IFilterCriteria (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria)11 Test (org.junit.Test)10 FilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager)10 IFilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager)10 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)3 CollectionModel (org.apache.wicket.model.util.CollectionModel)3 OProperty (com.orientechnologies.orient.core.metadata.schema.OProperty)2 ODocumentModel (ru.ydn.wicket.wicketorientdb.model.ODocumentModel)2 Serializable (java.io.Serializable)1 List (java.util.List)1 ODocumentLinksQueryDataProvider (ru.ydn.wicket.wicketorientdb.model.ODocumentLinksQueryDataProvider)1 OQueryDataProvider (ru.ydn.wicket.wicketorientdb.model.OQueryDataProvider)1 FilterCriteriaType (ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaType)1