-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat : add withCodes queryparameter for GET /listeCode/{id} #123
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4f7f9d5
feat : add withCodes queryparameter for GET /listeCode/{id}
HugoBouttes 629f294
fix : add another method mapping request withCodes parameter
HugoBouttes 6afd82d
fix : factorization of code
HugoBouttes ad29cd7
feat : add Banner.txt for Magma
HugoBouttes 5f70f74
fix : change name
HugoBouttes f04db0a
feat : add test for getCodesListWithoutCodes
HugoBouttes 47ec55c
fix : keep the same requestmapping
HugoBouttes 936471f
fix : forget the @RequestParams withCodes for GET /listeCode/{id}
HugoBouttes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package fr.insee.rmes.services.codelists; | ||
|
||
import fr.insee.rmes.persistence.RdfService; | ||
import fr.insee.rmes.services.utils.CommonMethods; | ||
import fr.insee.rmes.utils.Constants; | ||
import fr.insee.rmes.utils.config.Config; | ||
import fr.insee.rmes.utils.exceptions.RmesException; | ||
|
@@ -44,8 +45,7 @@ public String getCodesList(String notation) throws RmesException { | |
JSONObject codesList = repoGestion.getResponseAsObject(buildRequest(Constants.CODELISTS_QUERIES_PATH,"getCodesList.ftlh", params)); | ||
|
||
codesList.put("label", this.formatLabel(codesList)); | ||
codesList.remove("prefLabelLg1"); | ||
codesList.remove("prefLabelLg2"); | ||
CommonMethods.removePrefLabels(codesList); | ||
|
||
if(codesList.has(STATUT_VALIDATION)){ | ||
String validationState = codesList.getString(STATUT_VALIDATION); | ||
|
@@ -258,12 +258,28 @@ public Integer getMaxpage(String notation) throws RmesException { | |
} | ||
return total; | ||
} | ||
|
||
public String getCodesListWithoutCodes(String notation) throws RmesException{ | ||
|
||
Map<String, Object> params = initParamsNotation(notation); | ||
|
||
JSONObject codesList = repoGestion.getResponseAsObject(buildRequest(Constants.CODELISTS_QUERIES_PATH,"getCodesList.ftlh", params)); | ||
|
||
codesList.put("label", this.formatLabel(codesList)); | ||
CommonMethods.removePrefLabels(codesList); | ||
|
||
if(codesList.has(STATUT_VALIDATION)){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Séquence de code dupliquée :
Mieux vaut factoriser dans une méthode |
||
String validationState = codesList.getString(STATUT_VALIDATION); | ||
codesList.put(STATUT_VALIDATION, this.getValidationState(validationState)); | ||
} | ||
codesList.remove(Constants.URI); | ||
return codesList.toString(); | ||
} | ||
public String getCodesListPagination(String notation, int pageNumber)throws RmesException{ | ||
Map<String, Object> params = initParamsNotation(notation); | ||
JSONObject result = repoGestion.getResponseAsObject(buildRequest(Constants.CODELISTS_QUERIES_PATH,"getCodesList.ftlh",params)); | ||
result.put("label", this.formatLabel(result)); | ||
result.remove("prefLabelLg1"); | ||
result.remove("prefLabelLg2"); | ||
CommonMethods.removePrefLabels(result); | ||
if(result.has(STATUT_VALIDATION)){ | ||
String validationState = result.getString(STATUT_VALIDATION); | ||
result.put(STATUT_VALIDATION, this.getValidationState(validationState)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/fr/insee/rmes/services/utils/CommonMethods.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package fr.insee.rmes.services.utils; | ||
|
||
import org.json.JSONObject; | ||
|
||
public class CommonMethods { | ||
|
||
|
||
public static void removePrefLabels(JSONObject jsonObject){ | ||
if (jsonObject.has("prefLabelLg1") && jsonObject.has("prefLabelLg2")){ | ||
jsonObject.remove("prefLabelLg1"); | ||
jsonObject.remove("prefLabelLg2"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
__ __ | ||
| \/ | | ||
| \ / | __ _ __ _ _ __ ___ __ _ | ||
| |\/| |/ _` |/ _` | '_ ` _ \ / _` | | ||
| | | | (_| | (_| | | | | | | (_| | | ||
|_| |_|\__,_|\__, |_| |_| |_|\__,_| | ||
__/ | | ||
|___/ |
60 changes: 60 additions & 0 deletions
60
src/test/java/fr/insee/rmes/services/codelists/CodeListImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package fr.insee.rmes.services.codelists; | ||
|
||
import fr.insee.rmes.persistence.RdfService; | ||
import fr.insee.rmes.services.utils.CommonMethods; | ||
import fr.insee.rmes.utils.Constants; | ||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Map; | ||
|
||
import static fr.insee.rmes.utils.Constants.STATUT_VALIDATION; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class CodeListImplTest { | ||
|
||
public static final String CODELIST_TEST_WITH_STATUT_VALIDATION = "{\"dateMiseAJour\":\"2023-01-01T00:00:00\",\"dateCreation\":\"2023-01-01T00:00:00\",\"statutValidation\":\"Provisoire, jamais publiée\",\"id\":\"CL_TEST\"}"; | ||
public static final String CODELIST_TEST_WITHOUT_STATUT_VALIDATION = "{\"dateMiseAJour\":\"2023-01-01T00:00:00\",\"dateCreation\":\"2023-01-01T00:00:00\",\"id\":\"CL_TEST\"}"; | ||
|
||
|
||
public static final String LABEL = "[{\"langue\":\"fr\",\"contenu\":\"test\"},{\"langue\":\"en\",\"contenu\":\"test\"}]"; | ||
public static final String CODELIST_EXPECTED_WITH_STATUT_VALIDATION = "{\"dateMiseAJour\":\"2023-01-01T00:00:00\",\"dateCreation\":\"2023-01-01T00:00:00\",\"statutValidation\":\"Provisoire, jamais publiée\",\"id\":\"CL_TEST\",\"label\":[{\"langue\":\"fr\",\"contenu\":\"test\"},{\"langue\":\"en\",\"contenu\":\"test\"}]}"; | ||
public static final String CODELIST_EXPECTED_WITHOUT_STATUT_VALIDATION = "{\"dateMiseAJour\":\"2023-01-01T00:00:00\",\"dateCreation\":\"2023-01-01T00:00:00\",\"id\":\"CL_TEST\",\"label\":[{\"langue\":\"fr\",\"contenu\":\"test\"},{\"langue\":\"en\",\"contenu\":\"test\"}]}"; | ||
|
||
public static final String STATUT_VALIDATION_PUBLIEE = "Publiée"; | ||
|
||
@Test | ||
void getCodesListWithoutCodes_With_Statut_Validation() throws JSONException { | ||
|
||
JSONObject codesList = new JSONObject(CODELIST_TEST_WITH_STATUT_VALIDATION); | ||
JSONArray label = new JSONArray(LABEL); | ||
codesList.put("label",label); | ||
|
||
if(codesList.has(STATUT_VALIDATION)){ | ||
String validationState = codesList.getString(STATUT_VALIDATION); | ||
codesList.put(STATUT_VALIDATION, validationState); | ||
} | ||
codesList.remove(Constants.URI); | ||
assertTrue(codesList.toString().equals(CODELIST_EXPECTED_WITH_STATUT_VALIDATION)); | ||
|
||
} | ||
|
||
@Test | ||
void getCodesListWithoutCodes_Without_Statut_Validation() throws JSONException { | ||
|
||
JSONObject codesList = new JSONObject(CODELIST_TEST_WITHOUT_STATUT_VALIDATION); | ||
JSONArray label = new JSONArray(LABEL); | ||
codesList.put("label",label); | ||
|
||
if(codesList.has(STATUT_VALIDATION)){ | ||
String validationState = codesList.getString(STATUT_VALIDATION); | ||
codesList.put(STATUT_VALIDATION, STATUT_VALIDATION_PUBLIEE); | ||
} | ||
codesList.remove(Constants.URI); | ||
assertTrue(codesList.toString().equals(CODELIST_EXPECTED_WITHOUT_STATUT_VALIDATION)); | ||
|
||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nouvelle méthode non couverte par un test