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 submissionEnvelopes/search/findByUuid endpoint #59

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 @@ -23,7 +23,7 @@ public interface SubmissionEnvelopeRepository extends MongoRepository<Submission
@RestResource(exported = false)
SubmissionEnvelope findByUuid(Uuid uuid);

@RestResource(rel = "findByUuid")
@RestResource(rel = "findByUuid", path = "findByUuid")
SubmissionEnvelope findByUuidUuid(@Param("uuid") UUID uuid);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does Uuid appear twice in the method name?

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably because of the non-exported findByUuid method?

Copy link
Contributor

@MightyAx MightyAx Apr 22, 2021

Choose a reason for hiding this comment

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

A bit of a late response here but i can explain, this is due to the automated spring mongo methods interacting with our Uuid class.

SubmissionEnvelope extends AbstractEntity which contains the uuid property of type Uuid from org.humancellatlas.ingest.core.Uuid.
The Uuid class contains a single property uuid of type UUID from java.util.UUID.

So using a snippet of this example, you can see that the uuid property of the submissionEnvelope is an object containing a uuid property.
GET /submissionEnvelopes/6080a6a1dd9aab1232d308b0

{
  "submissionDate" : "2021-04-21T22:26:41.995Z",
  "updateDate" : "2021-04-22T00:07:18.005Z",
  "user" : "601c2af3ac1792031eee4261",
  "lastModifiedUser" : "anonymousUser",
  "type" : "Submission",
  "uuid" : {
    "uuid" : "9262e9bf-5ebd-44ee-b80f-15cf107b32a5"
  },
  "events" : [ ]
}

So when using mongo spring repositories, the name of the method reflects where the data is being pulled from the source document.
The non-exported findByUuid method would be used with an object containing a uuid property:

uuid_object = {"uuid": "9262e9bf-5ebd-44ee-b80f-15cf107b32a5"}
envelope = submissionEnvelopeRepository.findByUuid(uuid_object);

whereas the second method just takes the UUID, which is more usable in our rest api, Hal browser, called from ingest UI.

uuid = "9262e9bf-5ebd-44ee-b80f-15cf107b32a5"
envelope = submissionEnvelopeRepository.findByUuidUuid(uuid);

In common language whenever anyone on the team talks about the uuid they mean this "9262e9bf-5ebd-44ee-b80f-15cf107b32a5" but actually in our code that is the Uuid of the Uuid.

Why do we have a custom Uuid class? I don't know.


@RestResource(path = "findByUser", rel = "findByUser")
Expand Down