diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 05e8dc8..a6d6ab0 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -2,9 +2,9 @@ name: Build
on:
push:
- branches: [ main ]
+ branches: [ main, [0-9]+.[0-9]+.* ]
pull_request:
- branches: [ main ]
+ branches: [ main, [0-9]+.[0-9]+.* ]
jobs:
build:
diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml
index 749949e..10d0a93 100644
--- a/.github/workflows/renovate.yml
+++ b/.github/workflows/renovate.yml
@@ -1,8 +1,8 @@
name: Renovate
-on:
- schedule:
- - cron: '*/5 8-19 * * 1-5'
+#on:
+# schedule:
+# - cron: '*/5 8-19 * * 1-5'
jobs:
renovate:
diff --git a/pom.xml b/pom.xml
index ef2c934..db31d0b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
fr.ouestfrance.querydsl
querydsl-postgrest-bom
- 1.2.3-SNAPSHOT
+ 1.2.4-SNAPSHOT
pom
querydsl-postgrest-bom
Implementation of unified queryDSL for postgRest API
diff --git a/querydsl-postgrest-resttemplate-adapter/pom.xml b/querydsl-postgrest-resttemplate-adapter/pom.xml
index d0b2f37..3f841cb 100644
--- a/querydsl-postgrest-resttemplate-adapter/pom.xml
+++ b/querydsl-postgrest-resttemplate-adapter/pom.xml
@@ -5,7 +5,7 @@
fr.ouestfrance.querydsl
querydsl-postgrest-bom
../pom.xml
- 1.2.3-SNAPSHOT
+ 1.2.4-SNAPSHOT
querydsl-postgrest-resttemplate-adapter
@@ -20,7 +20,7 @@
org.springframework
spring-web
- 6.1.2
+ 6.1.3
org.apache.commons
diff --git a/querydsl-postgrest-resttemplate-adapter/src/main/java/fr/ouestfrance/querydsl/postgrest/PostgrestRestTemplate.java b/querydsl-postgrest-resttemplate-adapter/src/main/java/fr/ouestfrance/querydsl/postgrest/PostgrestRestTemplate.java
index f8a405b..58e58c0 100644
--- a/querydsl-postgrest-resttemplate-adapter/src/main/java/fr/ouestfrance/querydsl/postgrest/PostgrestRestTemplate.java
+++ b/querydsl-postgrest-resttemplate-adapter/src/main/java/fr/ouestfrance/querydsl/postgrest/PostgrestRestTemplate.java
@@ -4,6 +4,7 @@
import fr.ouestfrance.querydsl.postgrest.model.Page;
import fr.ouestfrance.querydsl.postgrest.model.PageImpl;
import fr.ouestfrance.querydsl.postgrest.model.Range;
+import fr.ouestfrance.querydsl.postgrest.model.RangeResponse;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.reflect.TypeUtils;
@@ -21,6 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.stream.Stream;
/**
* Rest interface for querying postgrest
@@ -37,15 +39,15 @@ public class PostgrestRestTemplate implements PostgrestClient {
* Postgrest restTemplate adapter
*
* @param restTemplate restTemplate
- * @return PostgrestResttemplate implementation
+ * @return PostgrestRestTemplate implementation
*/
public static PostgrestRestTemplate of(RestTemplate restTemplate) {
return new PostgrestRestTemplate(restTemplate);
}
@Override
- public Page search(String resource, Map> params,
- Map> headers, Class clazz) {
+ public RangeResponse search(String resource, Map> params,
+ Map> headers, Class clazz) {
ResponseEntity> response = restTemplate.exchange(restTemplate.getUriTemplateHandler()
.expand(UriComponentsBuilder.fromPath(resource)
.queryParams(toMultiMap(params)).build().toString(), new HashMap<>()), HttpMethod.GET,
@@ -54,14 +56,14 @@ public Page search(String resource, Map> params,
return Optional.of(response)
.map(HttpEntity::getBody)
.map(x -> {
- PageImpl page = new PageImpl<>(x, null, x.size(), 1);
- List contentRangeHeaders = response.getHeaders().get("Content-Range");
- if (contentRangeHeaders != null) {
- Range range = Range.of(contentRangeHeaders.stream().findFirst().toString());
- page.withRange(range);
- }
- return (Page) page;
- }).orElse(Page.empty());
+ Range range = Optional.ofNullable(response.getHeaders().get("Content-Range"))
+ .map(List::stream)
+ .map(Stream::findFirst)
+ .filter(Optional::isPresent)
+ .map(Optional::get)
+ .map(Range::of).orElse(null);
+ return new RangeResponse<>(x, range);
+ }).orElse(new RangeResponse<>(List.of(), null));
}
@Override
@@ -74,8 +76,8 @@ public List post(String resource, List