Skip to content

Commit

Permalink
CollectionReference | API to resolve reference
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Jul 8, 2022
1 parent e2fffe3 commit bbf02a4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/collections/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@
views.CollectionReferenceView.as_view(),
name='collectionversion-reference'
),
re_path(
r'^(?P<collection>{pattern})/(?P<version>{pattern})/references/(?P<reference>{pattern})/resolve/$'.format(
pattern=NAMESPACE_PATTERN),
views.CollectionReferenceResolveView.as_view(),
name='collectionversion-reference-resolve'
),
re_path(
r'^(?P<collection>{pattern})/(?P<version>{pattern})/references/(?P<reference>{pattern})/concepts/$'.format(
pattern=NAMESPACE_PATTERN),
Expand Down
19 changes: 19 additions & 0 deletions core/collections/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,25 @@ def get(self, request, *args, **kwargs):
return self.list(request, *args, **kwargs)


# Right now only for testing/debugging
class CollectionReferenceResolveView(CollectionReferenceAbstractResourcesView): # pragma: no cover
def get_serializer_class(self):
from core.sources.serializers import SourceVersionListSerializer
return SourceVersionListSerializer

def get(self, request, *args, **kwargs):
reference = self.get_queryset()
system_version = reference.resolve_system_version
valueset_versions = reference.resolve_valueset_versions
data = []
if system_version:
from core.sources.serializers import SourceVersionListSerializer
data.append(SourceVersionListSerializer(system_version).data)
if valueset_versions:
data += CollectionVersionListSerializer(valueset_versions, many=True).data
return Response(data)


class CollectionReferenceConceptsView(CollectionReferenceAbstractResourcesView):
is_searchable = True
document_model = ConceptDocument
Expand Down

0 comments on commit bbf02a4

Please sign in to comment.