Skip to content

Commit

Permalink
Fixed: only query in body
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Dec 3, 2023
1 parent 17a0aea commit ddd0f77
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/main/java/de/samply/core/ExporterCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private Query checkParametersAndFetchQuery(ExporterParameters exporterParameters
query = queryOptional.get();
}
} else {
if (exporterParameters.query() != null || template.getQuery() != null){
if (exporterParameters.query() != null || template.getQuery() != null) {
query = createNewQuery(exporterParameters, template);
} else {
errors.addError("Query not defined");
Expand All @@ -88,9 +88,9 @@ private Query checkParametersAndFetchQuery(ExporterParameters exporterParameters
private Query createNewQuery(ExporterParameters exporterParameters, RequestTemplate template) {
Query query = new Query();
String sQuery = null;
if (exporterParameters.query() != null){
if (exporterParameters.query() != null) {
sQuery = exporterParameters.query();
} else if (template != null && template.getQuery() != null){
} else if (template != null && template.getQuery() != null) {
sQuery = template.getQuery();
}
query.setQuery(sQuery);
Expand All @@ -111,19 +111,19 @@ private Query createNewQuery(ExporterParameters exporterParameters, RequestTempl
private RequestTemplate checkParametersAndFetchRequestTemplate(ExporterParameters exporterParameters,
Errors errors) {
RequestTemplate result = null;
ConverterTemplate converterTemplate = null;
if (exporterParameters.templateId() != null) {
ConverterTemplate converterTemplate = converterTemplateManager.getConverterTemplate(exporterParameters.templateId());
if (result == null) {
converterTemplate = converterTemplateManager.getConverterTemplate(exporterParameters.templateId());
if (converterTemplate == null) {
errors.addError("Converter Template " + exporterParameters.templateId() + " not found");
} else {
result = new RequestTemplate();
result.setConverterTemplate(converterTemplate);
result.setQuery(exporterParameters.query());
}
}
if (exporterParameters.templateId() == null || (exporterParameters.query() == null && exporterParameters.queryId() == null)){
if (exporterParameters.templateId() == null || (exporterParameters.query() == null && exporterParameters.queryId() == null)) {
boolean fetchTemplate = true;
if (exporterParameters.requestTemplate() == null) {
if ((result == null || result.getConverterTemplate() == null) && exporterParameters.requestTemplate() == null) {
errors.addError("Request Template not defined");
fetchTemplate = false;
}
Expand All @@ -137,9 +137,12 @@ private RequestTemplate checkParametersAndFetchRequestTemplate(ExporterParameter
}
if (fetchTemplate) {
result = fetchRequestTemplate(exporterParameters, errors);
if (converterTemplate != null) {
result.setConverterTemplate(converterTemplate); // Override template if it is already defined
}
}
}
if (result.getConverterTemplate() == null){
if (result.getConverterTemplate() == null) {
errors.addError("Converter Template not defined");
}
return result;
Expand Down

0 comments on commit ddd0f77

Please sign in to comment.