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[hmi-server]: Pack metadata on climate dataset #3104

Merged
merged 1 commit into from
Mar 21, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import feign.FeignException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
Expand Down Expand Up @@ -170,10 +171,21 @@ public ResponseEntity<Dataset> fetchEsgf(@PathVariable final String esgfId) {
try{
final ResponseEntity<JsonNode> response = climateDataProxy.fetchEsgf(esgfId);

if(response.getBody() == null)
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "Unable to fetch ESGF. Response body was null");

String name = esgfId;
if(response.getBody().get("dataset") != null){
name = response.getBody().get("dataset").asText();
}


final Dataset dataset = new Dataset();
dataset.setEsgfId(esgfId);
dataset.setMetadata(response.getBody());
dataset.setName(esgfId);
dataset.setName(name);
dataset.setMetadata(response.getBody().get("metadata"));
((ObjectNode) dataset.getMetadata()).set("urls", response.getBody().get("urls"));


return ResponseEntity.ok(dataset);
} catch(final FeignException.FeignClientException e) {
Expand Down
Loading