Skip to content
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

Fix: visu web dsfr #284

Merged
merged 2 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<groupId>fr.insee</groupId>
<artifactId>Pogues-BO</artifactId>
<packaging>jar</packaging>
<version>4.6.4-SNAPSHOT</version>
<version>4.6.5-SNAPSHOT</version>
<name>Pogues-Back-Office</name>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public ResponseEntity<StreamingResponseBody> visualizeSpecFromBody(@RequestBody
StreamingResponseBody stream = output -> {
try {
output.write(
pipeline.from(new ByteArrayInputStream(request.getBytes(StandardCharsets.UTF_8)))
pipeline.from(string2InputStream(request))
.map(jsonToJsonDeref::transform, params, questionnaireName)
.map(jsonToXML::transform, params, questionnaireName)
.map(poguesXMLToDDI::transform, params, questionnaireName)
Expand Down Expand Up @@ -108,7 +108,7 @@ public ResponseEntity<StreamingResponseBody> visualizeDDIFromBody(@RequestBody S
StreamingResponseBody stream = output -> {
try {
output.write(
pipeline.from(new ByteArrayInputStream(request.getBytes(StandardCharsets.UTF_8)))
pipeline.from(string2InputStream(request))
.map(jsonToJsonDeref::transform, params, questionnaireName)
.map(jsonToXML::transform, params, questionnaireName)
.map(poguesXMLToDDI::transform, params, questionnaireName).transform().toByteArray());
Expand Down Expand Up @@ -136,7 +136,7 @@ public ResponseEntity<StreamingResponseBody> visualizePDFFromBody(@RequestBody S

StreamingResponseBody stream = output -> {
try {
output.write(pipeline.from(new ByteArrayInputStream(request.getBytes(StandardCharsets.UTF_8)))
output.write(pipeline.from(string2InputStream(request))
.map(jsonToJsonDeref::transform, params, questionnaireName)
.map(jsonToXML::transform, params, questionnaireName)
.map(poguesXMLToDDI::transform, params, questionnaireName)
Expand Down Expand Up @@ -181,7 +181,7 @@ public ResponseEntity<StreamingResponseBody> ddi2pdfWithParamTest(@RequestBody S

StreamingResponseBody stream = output -> {
try {
output.write(pipeline.from(new ByteArrayInputStream(questDDI.getBytes(StandardCharsets.UTF_8)))
output.write(pipeline.from(string2InputStream(questDDI))
.map(ddiToFo::transform, params, questionnaireName)
.map(foToPdf::transform, params, questionnaireName)
.transform().toByteArray());
Expand All @@ -205,7 +205,7 @@ public ResponseEntity<StreamingResponseBody> fo2Pdf(@RequestBody String questFO)
StreamingResponseBody stream = output -> {

try {
output.write(pipeline.from(new ByteArrayInputStream(questFO.getBytes(StandardCharsets.UTF_8)))
output.write(pipeline.from(string2InputStream(questFO))
.map(foToPdf::transform, params, questionnaireName)
.transform().toByteArray());
} catch (Exception e) {
Expand All @@ -225,7 +225,7 @@ public ResponseEntity<StreamingResponseBody> fo2Pdf(@RequestBody String questFO)
})
public ResponseEntity<StreamingResponseBody> json2XML(@RequestBody String questJson) throws Exception {
String questionnaire = "xforms";
return transform(new ByteArrayInputStream(questJson.getBytes(StandardCharsets.UTF_8)), jsonToXML,
return transform(string2InputStream(questJson), jsonToXML,
questionnaire, MediaType.APPLICATION_XML);
}

Expand All @@ -248,7 +248,9 @@ public ResponseEntity<StreamingResponseBody> xml2Json(@RequestBody String questX
@ApiResponse(responseCode = "500", description = "Error") })
@ResponseBody
public ResponseEntity<String> jsonRef2JsonDeref(@RequestBody String questJson) throws Exception {
ByteArrayOutputStream result = jsonToJsonDeref.transform(string2InputStream(questJson), Map.of("needDeref", true), null);
Map<String, Object> params = new HashMap<>();
params.put("needDeref", true);
ByteArrayOutputStream result = jsonToJsonDeref.transform(string2InputStream(questJson), params, null);
return ResponseEntity.status(HttpStatus.OK).contentType(MediaType.APPLICATION_JSON).body(result.toString(StandardCharsets.UTF_8));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ResponseEntity<String> visualizeCatiQueenFromBody(@RequestBody String req
params.put("needDeref", ref);
params.put("nomenclatureIds", SuggesterVisuTreatment.getNomenclatureIdsFromQuestionnaire(request));
URI uri;
ByteArrayOutputStream outputStream = pipeline.from(new ByteArrayInputStream(request.getBytes(StandardCharsets.UTF_8)))
ByteArrayOutputStream outputStream = pipeline.from(string2InputStream(request))
.map(jsonToJsonDeref::transform, params, questionnaireName.toLowerCase())
.map(jsonToXML::transform, params, questionnaireName.toLowerCase())
.map(poguesXMLToDDI::transform, params, questionnaireName.toLowerCase())
Expand Down Expand Up @@ -147,7 +147,7 @@ public ResponseEntity<String> visualizeStromaeV2FromBody(@RequestBody String req
params.put("nomenclatureIds", SuggesterVisuTreatment.getNomenclatureIdsFromQuestionnaire(request));

URI uri;
ByteArrayOutputStream outputStream = pipeline.from(new ByteArrayInputStream(request.getBytes(StandardCharsets.UTF_8)))
ByteArrayOutputStream outputStream = pipeline.from(string2InputStream(request))
.map(jsonToJsonDeref::transform, params, questionnaireName.toLowerCase())
.map(jsonToXML::transform, params, questionnaireName.toLowerCase())
.map(poguesXMLToDDI::transform, params, questionnaireName.toLowerCase())
Expand All @@ -171,7 +171,7 @@ public ResponseEntity<String> visualizeStromaeV3FromBody(@RequestBody String req
params.put("nomenclatureIds", SuggesterVisuTreatment.getNomenclatureIdsFromQuestionnaire(request));
params.put("dsfr", true);
URI uri;
ByteArrayOutputStream outputStream = pipeline.from(new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8)))
ByteArrayOutputStream outputStream = pipeline.from(string2InputStream(request))
.map(jsonToJsonDeref::transform, params, questionnaireName.toLowerCase())
.map(jsonToXML::transform, params, questionnaireName.toLowerCase())
.map(poguesXMLToDDI::transform, params, questionnaireName.toLowerCase())
Expand All @@ -192,7 +192,7 @@ public ResponseEntity<String> visualizeFromDDIBody(@RequestBody String request,
params.put("dataCollection", dataCollection.toLowerCase());
params.put("questionnaire", questionnaire.toLowerCase());
URI uri;
ByteArrayOutputStream outputStream = pipeline.from(new ByteArrayInputStream(request.getBytes(StandardCharsets.UTF_8)))
ByteArrayOutputStream outputStream = pipeline.from(string2InputStream(request))
.map(ddiToXForm::transform, params, questionnaire.toLowerCase())
.transform();
uri = xformToUri.transform(output2Input(outputStream), params, questionnaire.toLowerCase());
Expand Down