Search in sources :

Example 16 with PagerParams

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());
}
Also used : PagerParams(org.summerb.approaches.jdbccrud.api.dto.PagerParams) Test(org.junit.Test)

Example 17 with PagerParams

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());
}
Also used : PagerParams(org.summerb.approaches.jdbccrud.api.dto.PagerParams) Test(org.junit.Test)

Example 18 with PagerParams

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;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) PagerParams(org.summerb.approaches.jdbccrud.api.dto.PagerParams) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with PagerParams

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);
    }
}
Also used : PagerParams(org.summerb.approaches.jdbccrud.api.dto.PagerParams) PropertyServiceUnexpectedException(org.summerb.microservices.properties.api.exceptions.PropertyServiceUnexpectedException) AliasEntry(org.summerb.microservices.properties.impl.dao.AliasEntry)

Example 20 with PagerParams

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");
}
Also used : DataSetLoaderImpl(org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl) EasyCrudService(org.summerb.approaches.jdbccrud.api.EasyCrudService) Query(org.summerb.approaches.jdbccrud.api.query.Query) PagerParams(org.summerb.approaches.jdbccrud.api.dto.PagerParams) PaginatedList(org.summerb.approaches.jdbccrud.api.dto.PaginatedList) Test(org.junit.Test)

Aggregations

PagerParams (org.summerb.approaches.jdbccrud.api.dto.PagerParams)31 Test (org.junit.Test)27 PaginatedList (org.summerb.approaches.jdbccrud.api.dto.PaginatedList)6 EasyCrudService (org.summerb.approaches.jdbccrud.api.EasyCrudService)3 Query (org.summerb.approaches.jdbccrud.api.query.Query)3 DataSetLoaderImpl (org.summerb.approaches.jdbccrud.impl.relations.DataSetLoaderImpl)3 User (org.summerb.microservices.users.api.dto.User)3 TestDto1 (integr.org.summerb.jdbccrud.TestDto1)2 HasId (org.summerb.approaches.jdbccrud.api.dto.HasId)2 AliasEntry (org.summerb.microservices.properties.impl.dao.AliasEntry)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Entry (java.util.Map.Entry)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 Attachment (org.summerb.microservices.articles.api.dto.Attachment)1 PropertyServiceUnexpectedException (org.summerb.microservices.properties.api.exceptions.PropertyServiceUnexpectedException)1 StringIdAliasDao (org.summerb.microservices.properties.impl.dao.StringIdAliasDao)1 AuthToken (org.summerb.microservices.users.api.dto.AuthToken)1