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

Feature/mc 9772 - New endpoints for Data Model subset and intersects #244

Merged
merged 9 commits into from
Feb 16, 2022

Conversation

aaronforshaw
Copy link
Contributor

@aaronforshaw aaronforshaw commented Feb 8, 2022

New "subset" endpoint

Add a new endpoint PUT /dataModels/{sourceId}/subset/{targetId} which copies / removes a subset of data elements from a source to target. Example of body:

{
    "additions": ["2d095b0d-b695-4376-a75c-5d51f2e338ca", "cb84ba54-f553-4ebe-9474-c9d162d132be"], 
    "deletions": ["9ca458d4-9d37-4947-93fb-758dbc7298f0"]
}

It is mandatory to include both the "additions" and "deletions" properties in the body, however either may be an empty collection []

For each addition:

  1. Check that a data element with the specified ID exists in source
  2. If it does not already exist in target, create a copy of the data element in target, reconstructing any ancestor data class hierarchy, so that the path of the data element relative to the target is equal to that of the data element in the source relative to the source. For example, if the data element belongs to a data class C1 in source, then ensure C1 is created in target
  3. Create a data type in target, if the data type does not already exist

For each deletion:

  1. Check that a data element with the specified ID exists in source
  2. Find the data element in the target with a path matching that of the data element in the source
  3. If found then delete the data element from target.

After deletions, data classes in the target which no longer have subsetted items are deleted.

New "intersects" endpoint

Add a new endpoint GET /dataModels/{sourceId}/intersects/{targetId}, the objective of which is to identify the data element IDs from the target which also exist (i.e. match by path) in the source, responding with a collection of those data elements, expressed using IDs from the source.

For every data element in the target:

  1. Get the path of the data element in the target
  2. Use this path to retrieve a corresponding data element in the source
  3. Add the ID of the retrieved data element in the source to a collection of IDs to be returned

Example of response body:

{
    "intersects": ["2d095b0d-b695-4376-a75c-5d51f2e338ca", "cb84ba54-f553-4ebe-9474-c9d162d132be"]
}

Copy link
Contributor

@olliefreeman olliefreeman left a comment

Choose a reason for hiding this comment

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

Overall logic is fine, just a few tweaks please

@olliefreeman olliefreeman merged commit bc9b60b into develop Feb 16, 2022
@olliefreeman olliefreeman deleted the feature/mc-9772 branch February 16, 2022 17:04
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.

None yet

2 participants