Search in sources :

Example 6 with IFilterCriteria

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

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());
        }
    }
}
Also used : Serializable(java.io.Serializable) List(java.util.List) FilterCriteriaType(ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaType) IFilterCriteria(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria)

Example 8 with IFilterCriteria

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);
}
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 9 with IFilterCriteria

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

Example 10 with IFilterCriteria

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());
}
Also used : IFilterCriteriaManager(ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager) OQueryDataProvider(ru.ydn.wicket.wicketorientdb.model.OQueryDataProvider) 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