Skip to content

Commit

Permalink
Handle the cases where the visas are a mix of Fega and non-fega visas
Browse files Browse the repository at this point in the history
  • Loading branch information
Parisa68 committed Nov 25, 2024
1 parent 93ebe1e commit 12e331a
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.extern.slf4j.Slf4j;
import no.uio.ifi.localega.doa.dto.DestinationFormat;
import no.uio.ifi.localega.doa.dto.ExportRequest;
import no.uio.ifi.localega.doa.model.Dataset;
import no.uio.ifi.localega.doa.model.DatasetEventLog;
import no.uio.ifi.localega.doa.services.AAIService;
import no.uio.ifi.localega.doa.services.MetadataService;
Expand All @@ -26,6 +27,7 @@
import java.io.InputStream;
import java.util.Base64;
import java.util.Collection;
import java.util.Objects;

/**
* RabbitMQ listener that processes incoming export requests.
Expand Down Expand Up @@ -81,7 +83,17 @@ public void listen(String message) {
String stableDatasetId = metadataService.getDataset(datasetsDbTableId).getStableId();
log.info("Reference id {} mapped to dataset id {}", requestedDatasetId, stableDatasetId);
requestedDatasetId = stableDatasetId; // use stable dataset id instead of reference to complete the export as normal
Collection<String> approvedMappedDatasetIds = approvedDatasetIds.stream().map(x -> metadataService.getDataset(metadataService.findByReferenceId(x).getDatasetId()).getStableId()).toList();
Collection<String> approvedMappedDatasetIds = approvedDatasetIds.stream()
.map(x -> {
var reference = metadataService.findByReferenceId(x);
if (reference != null && reference.getDatasetId() != null) {
var dataset = metadataService.getDataset(reference.getDatasetId());
return dataset != null ? dataset.getStableId() : x;
} else {
return x;
}
})
.toList();
approvedDatasetIds = approvedMappedDatasetIds;
}
exportDataset(user, approvedDatasetIds, requestedDatasetId, exportRequest.getPublicKey(), exportRequest.getStartCoordinate(), exportRequest.getEndCoordinate());
Expand Down

0 comments on commit 12e331a

Please sign in to comment.