Skip to content

Conversation

@SeanBerrieHRI
Copy link

No description provided.

- Added isSameSchema function, allowing RDF models to be compared.
- Added GetAllSchemas function, fetching all current schemas in the FDP.
- Added SchemaToolsTest.java, testing this new feature.
- Improved readability in SchemaTools.java by splitting up functons inside run.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
10.8% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Contributor

@PatrickDekkerHealthRI PatrickDekkerHealthRI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the FDP GetAllSchema can be removed i think ?

Comment on lines +189 to +234

public List<SchemaDataResponse> GetAllSchemas(){
logger.info("Getting all metadata schemas");
try {
HttpClient client = HttpClient.newBuilder()
.build();

HttpRequest request = HttpRequest.newBuilder()
.GET()
.uri(new URI(url + "/metadata-schemas/"))
.header("accept", "application/json")
.header("Content-Type", "application/json")
.header("Authorization", String.valueOf(token))
.build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

// Handle each response based on Fair Data Point (FDP) Swagger documentation.
switch (response.statusCode()) {
case 200 -> logger.info("Successfully received all schemas from FDP");
case 400 ->
throw new IllegalArgumentException(String.valueOf(HttpStatus.SC_BAD_REQUEST));
case 401 ->
throw new SecurityException(String.valueOf(HttpStatus.SC_UNAUTHORIZED));
case 403 ->
throw new SecurityException(String.valueOf(HttpStatus.SC_FORBIDDEN));
case 404 ->
throw new IOException(String.valueOf(HttpStatus.SC_NOT_FOUND));
case 500 ->
throw new IOException(String.valueOf(HttpStatus.SC_INTERNAL_SERVER_ERROR));
default -> {
throw new RuntimeException("Unexpected HTTP status: " + response.statusCode());
}
}

ObjectMapper objectMapper = new ObjectMapper();
TypeReference<List<SchemaDataResponse>> schemaDataTypeReference = new TypeReference<List<SchemaDataResponse>>(){};
List<SchemaDataResponse> schemaDataResponseList = objectMapper.readValue(response.body(), schemaDataTypeReference);

return schemaDataResponseList;

} catch (Exception e) {
throw new RuntimeException(e);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants