Search in sources :

Example 1 with OQueryDataProvider

use of ru.ydn.wicket.wicketorientdb.model.OQueryDataProvider in project wicket-orientdb by OrienteerBAP.

the class TestModels method testOQueryProvider.

@Test
public void testOQueryProvider() {
    OQueryDataProvider<OUser> provider = new OQueryDataProvider<OUser>("select from OUser where name <> :other", OUser.class);
    provider.setSort("name", SortOrder.ASCENDING);
    provider.setParameter("other", Model.of("blalba"));
    Iterator<OUser> it = provider.iterator(0, -1);
    List<ODocument> allUsers = wicket.getTester().getMetadata().getSecurity().getAllUsers();
    assertTrue(provider.size() == allUsers.size());
    while (it.hasNext()) {
        OUser oUser = it.next();
        assertTrue(allUsers.contains(provider.model(oUser).getObject().getDocument()));
    }
    provider.detach();
    assertTrue(provider.size() == allUsers.size());
}
Also used : OQueryDataProvider(ru.ydn.wicket.wicketorientdb.model.OQueryDataProvider) OUser(com.orientechnologies.orient.core.metadata.security.OUser) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) Test(org.junit.Test)

Example 2 with OQueryDataProvider

use of ru.ydn.wicket.wicketorientdb.model.OQueryDataProvider 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

Test (org.junit.Test)2 OQueryDataProvider (ru.ydn.wicket.wicketorientdb.model.OQueryDataProvider)2 OUser (com.orientechnologies.orient.core.metadata.security.OUser)1 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 FilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.FilterCriteriaManager)1 IFilterCriteria (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteria)1 IFilterCriteriaManager (ru.ydn.wicket.wicketorientdb.utils.query.filter.IFilterCriteriaManager)1