Skip to content

Commit

Permalink
Added: Query in body for CREATE_QUERY
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Dec 3, 2023
1 parent ddd0f77 commit a774f4f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Apt-get clean in docker
- Tomcat max-http-header-size
- Request Template
- Query in body for CREATE_QUERY

### Changed
- Move FHIR Packages to dktk-exporter
Expand Down
26 changes: 23 additions & 3 deletions src/main/java/de/samply/exporter/ExporterController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import de.samply.merger.FilesMergerManager;
import de.samply.template.ConverterTemplate;
import de.samply.template.ConverterTemplateManager;
import de.samply.template.RequestTemplate;
import de.samply.template.graph.ConverterGraph;
import de.samply.template.graph.factory.ConverterTemplateGraphFactoryManager;
import de.samply.template.token.TokenContext;
Expand Down Expand Up @@ -97,17 +98,36 @@ public ResponseEntity<String> info() {
}

@PostMapping(value = ExporterConst.CREATE_QUERY, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> createQuery(@RequestParam(name = ExporterConst.QUERY) String query,
public ResponseEntity<String> createQuery(@RequestParam(name = ExporterConst.QUERY, required = false) String query, // It can also be in requestTemplate
@RequestParam(name = ExporterConst.QUERY_FORMAT) Format queryFormat,
@RequestParam(name = ExporterConst.QUERY_LABEL) String queryLabel,
@RequestParam(name = ExporterConst.QUERY_DESCRIPTION) String queryDescription,
@RequestParam(name = ExporterConst.QUERY_CONTACT_ID) String queryContactId,
@RequestParam(name = ExporterConst.QUERY_DEFAULT_TEMPLATE_ID, required = false) String defaultTemplateId,
@RequestParam(name = ExporterConst.QUERY_CONTEXT, required = false) String queryContext,
@RequestParam(name = ExporterConst.QUERY_DEFAULT_OUTPUT_FORMAT, required = false) Format defaultOutputFormat,
@RequestParam(name = ExporterConst.QUERY_EXPIRATION_DATE, required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate queryExpirationDate) {
@RequestParam(name = ExporterConst.QUERY_EXPIRATION_DATE, required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate queryExpirationDate,
@RequestHeader(name = "Content-Type", required = false) String contentType,
@RequestBody(required = false) String requestTemplate) {
Query tempQuery = new Query();
tempQuery.setQuery(query);
String sQuery = null;
if (query != null){
sQuery = query;
} else if (requestTemplate != null){
if (contentType == null){
return ResponseEntity.badRequest().body("Content-Type not set");
}
try {
RequestTemplate requestTemplate1 = exporterCore.fetchRequestTemplate(requestTemplate, contentType);
sQuery = requestTemplate1.getQuery();
} catch (IOException e) {
return createInternalServerError(e);
}
}
if (sQuery == null){
return ResponseEntity.badRequest().body("Query not set");
}
tempQuery.setQuery(sQuery);
tempQuery.setFormat(queryFormat);
tempQuery.setLabel(queryLabel);
tempQuery.setDescription(queryDescription);
Expand Down

0 comments on commit a774f4f

Please sign in to comment.