-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed email. expect unsorted dump and sort using big-sorter. added …
…other data types. validate dump by getting count from portal api.
- Loading branch information
1 parent
46b8314
commit 9844d8a
Showing
13 changed files
with
241 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
rootProject.name = 'snapshot-change-lister' | ||
rootProject.name = 'ena-snapshot-tool' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/uk/ac/ebi/ena/dcap/scl/service/CountClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package uk.ac.ebi.ena.dcap.scl.service; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import lombok.SneakyThrows; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
|
||
@Component | ||
@Slf4j | ||
public class CountClient { | ||
static final String PORTAL_API_COUNT_URL = "https://www.ebi.ac.uk/ena/portal/api/count?result=%s&format=json"; | ||
|
||
@SneakyThrows | ||
public long getCountFromResults(String result, String query) { | ||
// Your JSON array as a string | ||
|
||
// Create ObjectMapper | ||
ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
// Parse JSON array | ||
JsonNode objNode = objectMapper.readTree(getJson(PORTAL_API_COUNT_URL, result, query)); | ||
|
||
// Iterate through objects in the array | ||
long codingValue = objNode.get("count").asLong(); | ||
return codingValue; | ||
} | ||
|
||
@SneakyThrows | ||
private String getJson(String portalApiResultsUrl, String result, String query) { | ||
|
||
String urlStr = String.format(PORTAL_API_COUNT_URL, result); | ||
if (StringUtils.isNotBlank(query)) { | ||
urlStr += "&query=" + query; | ||
} | ||
log.info("getting count from:{}", urlStr); | ||
// Create URL object | ||
URL url = new URL(urlStr); | ||
|
||
// Open a connection | ||
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); | ||
|
||
// Set the request method to GET | ||
connection.setRequestMethod("GET"); | ||
|
||
// Get the response code | ||
int responseCode = connection.getResponseCode(); | ||
|
||
// Read the response from the input stream | ||
StringBuilder response; | ||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { | ||
response = new StringBuilder(); | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
response.append(line); | ||
} | ||
|
||
} | ||
|
||
return response.toString(); | ||
} | ||
|
||
} |
Oops, something went wrong.