Fix search publication mechanism.
This commit is contained in:
@@ -3,7 +3,6 @@ package org.codiki.infrastructure.publication;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.codiki.domain.publication.model.search.PublicationSearchCriterion;
|
import org.codiki.domain.publication.model.search.PublicationSearchCriterion;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -16,11 +15,11 @@ public class PublicationSearchCriteriaJpaAdapter {
|
|||||||
boolean criterionAdaptationOccurred = false;
|
boolean criterionAdaptationOccurred = false;
|
||||||
|
|
||||||
if (criterion.value() instanceof String criterionValue) {
|
if (criterion.value() instanceof String criterionValue) {
|
||||||
String unaccentedCriterionValue = StringUtils.stripAccents(criterionValue);
|
String unaccentedCriterionValue = criterionValue.replaceAll("[àáâãäåçèéêëìíîïñòóôõöùúûüýÿ]", "_");
|
||||||
result.add(new PublicationSearchCriterion(
|
result.add(new PublicationSearchCriterion(
|
||||||
criterion.searchField(),
|
criterion.searchField(),
|
||||||
criterion.searchType(),
|
criterion.searchType(),
|
||||||
unaccentedCriterionValue
|
unaccentedCriterionValue.toLowerCase()
|
||||||
));
|
));
|
||||||
criterionAdaptationOccurred = true;
|
criterionAdaptationOccurred = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ public class PublicationPredicateMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return criteriaBuilder.equal(
|
return criteriaBuilder.equal(
|
||||||
from.get(attributeName),
|
criteriaBuilder.lower(
|
||||||
|
from.get(attributeName)
|
||||||
|
),
|
||||||
value
|
value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -72,7 +74,9 @@ public class PublicationPredicateMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return criteriaBuilder.like(
|
return criteriaBuilder.like(
|
||||||
from.get(attributeName),
|
criteriaBuilder.lower(
|
||||||
|
from.get(attributeName)
|
||||||
|
),
|
||||||
String.format("%%%s%%", value)
|
String.format("%%%s%%", value)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class PublicationSearchCriteriaJpaAdapterTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
List<PublicationSearchCriterion> expectedResult = List.of(
|
List<PublicationSearchCriterion> expectedResult = List.of(
|
||||||
new PublicationSearchCriterion(KEY, CONTAINS, "critere")
|
new PublicationSearchCriterion(KEY, CONTAINS, "crit_re")
|
||||||
);
|
);
|
||||||
assertThat(result).isEqualTo(expectedResult);
|
assertThat(result).isEqualTo(expectedResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
meta {
|
||||||
|
name: Create a new category
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{url}}/api/categories
|
||||||
|
body: json
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"name": "New category with sub-category",
|
||||||
|
"subCategoryIds": [
|
||||||
|
"2d19d037-57a1-44a1-9a20-766b4e3628b6"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
meta {
|
||||||
|
name: Delete an existing category
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
delete {
|
||||||
|
url: {{url}}/api/categories/{{categoryId}}
|
||||||
|
body: none
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
meta {
|
||||||
|
name: Get all categories
|
||||||
|
type: http
|
||||||
|
seq: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{url}}/api/categories
|
||||||
|
body: none
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
meta {
|
||||||
|
name: Update an existing category
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
put {
|
||||||
|
url: {{url}}/api/categories/{{categoryId}}
|
||||||
|
body: json
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"name": "Another name of the category",
|
||||||
|
"subCategoryIds": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
meta {
|
||||||
|
name: Create a new picture
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{url}}/api/pictures
|
||||||
|
body: multipartForm
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:multipart-form {
|
||||||
|
file: @file(/Users/florian_thierry/Pictures/applications_mac.jpeg)
|
||||||
|
}
|
||||||
11
rest-client-collection/Codiki/Pictures/Load a picture.bru
Normal file
11
rest-client-collection/Codiki/Pictures/Load a picture.bru
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
meta {
|
||||||
|
name: Load a picture
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{url}}/api/pictures/{{pictureId}}
|
||||||
|
body: none
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
meta {
|
||||||
|
name: Create a new publication
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{url}}/api/publications
|
||||||
|
body: json
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"title" : "Test",
|
||||||
|
"text" : "Test",
|
||||||
|
"description" : "Test",
|
||||||
|
"illustrationId" : "e2a5618e-ef83-4e83-b8ec-0aa129173f85",
|
||||||
|
"categoryId" : "3f4b4540-a901-92f3-1c15-8ec9172f820e"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
meta {
|
||||||
|
name: Delete an existing publication
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
delete {
|
||||||
|
url: {{url}}/api/publications/{{publicationId}}
|
||||||
|
body: none
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
meta {
|
||||||
|
name: Get a publication by its id
|
||||||
|
type: http
|
||||||
|
seq: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{url}}/api/publications/{{publicationId}}
|
||||||
|
body: none
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
meta {
|
||||||
|
name: Search publications
|
||||||
|
type: http
|
||||||
|
seq: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: {{url}}/api/publications?query=test
|
||||||
|
body: none
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
query {
|
||||||
|
query: test
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
meta {
|
||||||
|
name: Update an existing publication
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
put {
|
||||||
|
url: {{url}}/api/publications/{{publicationId}}
|
||||||
|
body: json
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{bearerToken}}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"title" : "Le titre de la publication.",
|
||||||
|
"text" : "Un autre contenu de la publication.",
|
||||||
|
"description" : "Une autre description de la publication",
|
||||||
|
"image" : "https://google.com/logos/doodles/2024/celebrating-the-flat-white-6753651837110463-s.png",
|
||||||
|
"categoryId" : "fd424c2f-6e58-4812-a179-00e50a0eab05"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
rest-client-collection/Codiki/Users/Login as admin user.bru
Normal file
18
rest-client-collection/Codiki/Users/Login as admin user.bru
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
meta {
|
||||||
|
name: Login as admin user
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{url}}/api/users/login
|
||||||
|
body: json
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"id": "15a13dc7-029d-4eab-a63d-c1e96f90241d",
|
||||||
|
"password": "password"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
meta {
|
||||||
|
name: Login as standard user
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{url}}/api/users/login
|
||||||
|
body: json
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"id": "5ad462b8-8f9e-4a26-bb86-c74fef5d11b6",
|
||||||
|
"password": "password"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
rest-client-collection/Codiki/Users/Sign in.bru
Normal file
11
rest-client-collection/Codiki/Users/Sign in.bru
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
meta {
|
||||||
|
name: Sign in
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: {{url}}/users
|
||||||
|
body: none
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
vars {
|
vars {
|
||||||
url: http://localhost:8080
|
url: http://localhost:8080
|
||||||
publicationId: e23831a6-9cc0-4f3d-9efa-7a1cae191cb1
|
publicationId: e23831a6-9cc0-4f3d-9efa-7a1cae191cb1
|
||||||
bearerToken: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWQ0NjJiOC04ZjllLTRhMjYtYmI4Ni1jNzRmZWY1ZDExYjYiLCJleHAiOjE3MTA0OTc2MTd9.xYfS-9CrJxCKUyvZ1ejMKErEttA1zysXxjlVzHFzXJ3ct9dt13xuiI7PHA-8_xY7HQjuIP1M5P2p0OGVsnxXsw
|
bearerToken: eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWQ0NjJiOC04ZjllLTRhMjYtYmI4Ni1jNzRmZWY1ZDExYjYiLCJleHAiOjE3MTA1MjE5NzN9.KgYeDYNjgM4ndv_An0fAoOdx7qHRJDXuUPnBEcn6es5kn2g-HDjgt1n_s5CD3_F13alBdR18--9dZlWV8qQmHg
|
||||||
categoryId: 172fa901-3f4b-4540-92f3-1c15820e8ec9
|
categoryId: 172fa901-3f4b-4540-92f3-1c15820e8ec9
|
||||||
pictureId: 65b660b7-66bb-4e4a-a62c-fd0ca101f972
|
pictureId: 65b660b7-66bb-4e4a-a62c-fd0ca101f972
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user