Skip to content

Commit

Permalink
Added: Explorer Ids to create and edit query
Browse files Browse the repository at this point in the history
  • Loading branch information
djuarezgf committed Feb 13, 2024
1 parent 870baca commit 960ddbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Email template for Accept/Reject/Request changes in project
- User Autocomplete
- Explorer Ids to create and edit query
- Decode redirect explorer URL
14 changes: 12 additions & 2 deletions src/main/java/de/samply/query/QueryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.stereotype.Service;

import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -54,7 +56,7 @@ public String createQuery(
tempQuery.setOutputFormat(outputFormat);
tempQuery.setTemplateId(templateId);
tempQuery.setHumanReadable(humanReadable);
tempQuery.setExplorerUrl(explorerUrl);
tempQuery.setExplorerUrl(decodeUrlIfNecessary(explorerUrl));
tempQuery.setContext(queryContext);
tempQuery = this.queryRepository.save(tempQuery);
return tempQuery.getCode();
Expand Down Expand Up @@ -101,7 +103,7 @@ public void editQuery(@NotNull String projectCode,
changedKeyValueMap.put("human readable", humanReadable);
}
if (explorerUrl != null) {
projectQuery.setExplorerUrl(explorerUrl);
projectQuery.setExplorerUrl(decodeUrlIfNecessary(explorerUrl));
changedKeyValueMap.put("explorer url", explorerUrl);
}
if (queryContext != null) {
Expand All @@ -117,6 +119,14 @@ public void editQuery(@NotNull String projectCode,
}
}

private String decodeUrlIfNecessary(String encodedUrl) {
try {
return URLDecoder.decode(encodedUrl, StandardCharsets.UTF_8);
} catch (Exception e) {
return encodedUrl;
}
}

private String printInOneLine(Map<String, String> changedKeyValuesMaps) {
try {
return objectMapper.writeValueAsString(changedKeyValuesMaps);
Expand Down

0 comments on commit 960ddbb

Please sign in to comment.