Skip to content

[BI-1366] Subscribe Ontology#175

Merged
ctucker3 merged 8 commits intodevelopfrom
feature/BI-1366
Apr 19, 2022
Merged

[BI-1366] Subscribe Ontology#175
ctucker3 merged 8 commits intodevelopfrom
feature/BI-1366

Conversation

@ctucker3
Copy link
Contributor

@ctucker3 ctucker3 commented Apr 5, 2022

Description

Story: https://breedinginsight.atlassian.net/jira/software/c/projects/BI/boards/1?modal=detail&selectedIssue=BI-1366

Adds subscribe endpoints to the backend OntologyController. See bi-web for the different check conditions.

Includes tests for all scenarios.

Dependencies

biweb: BI-1366

Testing

See biweb.

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code and ensured it meets the acceptance criteria of the story
  • I have tested that my code works with both the brapi-java-server and BreedBase
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: <please include a link to TAF run>

@ctucker3 ctucker3 marked this pull request as ready for review April 6, 2022 15:36
@ctucker3 ctucker3 requested review from dmeidlin and timparsons April 6, 2022 15:38
return HttpResponse.ok(response);
try {
List<SharedProgram> sharedPrograms = ontologyService.getSharedOntology(programId, shared);
List<org.breedinginsight.api.model.v1.response.metadata.Status> metadataStatus = new ArrayList<>();
Copy link
Member

Choose a reason for hiding this comment

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

I think you can reduce the generic in List to just List<Status>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

Response<DataResponse<SharedProgram>> response = new Response(metadata, new DataResponse<>(sharedPrograms));
return HttpResponse.ok(response);
try {
List<SharedProgram> sharedPrograms = ontologyService.getSharedOntology(programId, shared);
Copy link
Member

Choose a reason for hiding this comment

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

Could the name of both the class and this variable be changed to SharedOntology? SharedProgram doesn't make as much sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

ontologyService.unsubscribeOntology(programId, sharingProgramId);
return HttpResponse.ok();
} catch (UnprocessableEntityException e) {
return HttpResponse.status(HttpStatus.UNPROCESSABLE_ENTITY, e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

Can you add an error log statement, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

SubscribedProgram shareRequest = ontologyService.subscribeOntology(programId, sharingProgramId);
Response<SubscribedProgram> response = new Response(shareRequest);
return HttpResponse.ok(response);
} catch (UnprocessableEntityException e) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you add an error log statement, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added


import javax.inject.Inject;
import javax.inject.Singleton;
import javax.swing.text.html.Option;
Copy link
Member

Choose a reason for hiding this comment

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

I think this can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SubscribedProgram {
Copy link
Member

Choose a reason for hiding this comment

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

Can this change to SubscribedOntology?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

// Check that shared program exists
Optional<ProgramSharedOntologyEntity> optionalSharedOntology = programOntologyDAO.getSharedOntologyById(sharingProgramId, programId);
if (optionalSharedOntology.isEmpty()) {
throw new DoesNotExistException("Shared ontology between specified programs was not found.");
Copy link
Member

Choose a reason for hiding this comment

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

Thoughts on this throwing more of an illegal state type of exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's talk more about this over a slack huddle if that works for you? Did you have a specific status in mind? The only other one I can think of is UnprocessableEntityException but the DoesNotExistException seems to fit better since the user is requesting a specific resource and it doesn't exist.

The other UnprocessableEntityException errors are thrown when the shared record is found, but there is something else that is preventing the action.

Copy link
Member

Choose a reason for hiding this comment

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

Talked with Chris, and I'm fine for it to stay as is

// Check that shared program exists
Optional<ProgramSharedOntologyEntity> optionalSharedOntology = programOntologyDAO.getSharedOntologyById(sharingProgramId, programId);
if (optionalSharedOntology.isEmpty()) {
throw new DoesNotExistException("Shared ontology between specified programs was not found.");
Copy link
Member

Choose a reason for hiding this comment

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

Same as above...thoughts on this throwing some sort of illegal state type of exception?

@ctucker3 ctucker3 requested a review from timparsons April 11, 2022 14:27
HttpResponse response = HttpResponse.status(HttpStatus.UNPROCESSABLE_ENTITY).body(e.getErrors());
return response;
} catch (UnprocessableEntityException e) {
log.error(e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to be a pain, but for these error messages, can you change this to log.error(e.getMessage(), e);, please? That way the error stack gets printed to the logs too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching that! Added.

@ctucker3 ctucker3 requested a review from timparsons April 19, 2022 13:49
@ctucker3 ctucker3 merged commit 3a51d92 into develop Apr 19, 2022
@ctucker3 ctucker3 deleted the feature/BI-1366 branch April 19, 2022 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants