use of org.summerb.approaches.jdbccrud.api.dto.PagerParams in project summerb by skarpushin.
the class GenericCrudServiceTestTemplate method testFindByQueryBooleanFalse.
@Test
public void testFindByQueryBooleanFalse() throws Exception {
createTestData();
PaginatedList<TestDto1> result = getTestDto1Service().query(new PagerParams(0, 100), Query.n().isFalse("active"));
assertEquals(1, result.getTotalResults());
result = getTestDto1Service().query(new PagerParams(0, 100), Query.n().ne("active", true));
assertEquals(1, result.getTotalResults());
}
use of org.summerb.approaches.jdbccrud.api.dto.PagerParams in project summerb by skarpushin.
the class GenericCrudServiceTestTemplate method testFindByQueryNumberNotIn.
@Test
public void testFindByQueryNumberNotIn() throws Exception {
createTestData();
PaginatedList<TestDto1> result = getTestDto1Service().query(new PagerParams(0, 100), Query.n().notIn("minorVersion", 4L, 5L));
assertEquals(1, result.getTotalResults());
}
use of org.summerb.approaches.jdbccrud.api.dto.PagerParams in project summerb by skarpushin.
the class EasyCrudControllerBase method getList.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView getList(HttpServletResponse response) throws Exception {
ModelAndView ret = new ModelAndView(viewNameForList);
if (initialPageSize > 0) {
ret.addObject(ATTR_LIST, service.query(new PagerParams(0, initialPageSize), null));
}
// TODO: Shouldn't we cache such things?
Map<String, Boolean> perms = getPermissionsMapForCurrentUser();
ret.addObject(ATTR_PERMISSIONS, gson.toJson(perms));
return ret;
}
use of org.summerb.approaches.jdbccrud.api.dto.PagerParams in project summerb by skarpushin.
the class StringIdAliasServiceEagerImpl method loadAllAliases.
protected final BiMap<String, Long> loadAllAliases() {
try {
BiMap<String, Long> ret = HashBiMap.create();
long maxOffset = -2;
for (long offset = 0; maxOffset == -2 || offset < maxOffset; offset = offset + EAGER_LOAD_BATCH_SIZE) {
PagerParams pagerParams = new PagerParams(offset, EAGER_LOAD_BATCH_SIZE);
PaginatedList<AliasEntry> loadedAliases = stringIdAliasDao.loadAllAliases(pagerParams);
maxOffset = loadedAliases.getTotalResults() - 1;
for (Entry<String, Long> entry : loadedAliases.getItems()) {
ret.put(entry.getKey(), entry.getValue());
}
}
return ret;
} catch (Throwable t) {
String msg = "Failed to eagerly load alias map";
log.error(msg, t);
throw new PropertyServiceUnexpectedException(msg, t);
}
}
use of org.summerb.approaches.jdbccrud.api.dto.PagerParams in project summerb by skarpushin.
the class DataSetLoaderImplTest method testLoadObjectsByIds_ExpectManyLoadByLongsNfe.
@Test(expected = GenericEntityNotFoundException.class)
public void testLoadObjectsByIds_ExpectManyLoadByLongsNfe() throws Exception {
DataSetLoaderImpl fixture = buildMockedInstance();
EasyCrudService service = Mockito.mock(EasyCrudService.class);
when(fixture.getEasyCrudServiceResolver().resolveByEntityType("dto1")).thenReturn(service);
PaginatedList mockret = new PaginatedList<>(new PagerParams(), Collections.emptyList(), 0);
when(service.query(any(PagerParams.class), any(Query.class))).thenReturn(mockret);
fixture.loadObjectsByIds(ids(1L, 2L), "dto1");
}
Aggregations