Skip to content

Commit

Permalink
added keyword, theme, responsibleOrganization to dap data summary
Browse files Browse the repository at this point in the history
  • Loading branch information
RayPlante committed Jul 24, 2024
1 parent 70bffa2 commit b8f3bcc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion python/nistoar/midas/dap/service/mds3.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def create_record(self, name, data=None, meta=None) -> ProjectRecord:
m = re.search(r'/v(\d+\.\d+(\.\d+)*)#?$', schemaid)
if schemaid.startswith(NERDM_SCH_ID_BASE) and m:
ver = m.group(1).split('.')
for v in range(len(ver)):
for i in range(len(ver)):
if i >= len(self._minnerdmver):
break;
if ver[i] < self._minnerdmver[1]:
Expand Down Expand Up @@ -800,6 +800,13 @@ def _summarize(self, nerd: NERDResource):
out["contactPoint"] = resmd["contactPoint"]
if 'landingPage' in resmd:
out["landingPage"] = resmd["landingPage"]
out["keyword"] = resmd.get("keyword", [])
out["theme"] = list(set(resmd.get("theme", []) + [t.get('tag') for t in resmd.get('topic', [])]))
if resmd.get('responsibleOrganization'):
out['responsibleOrganization'] = list(set(
[org.title for org in resmd['responsibleOrganization']] + \
reduce(lambda x, y: x+y, [org.subunit for org in resmd['responsibleOrganization']], [])
))
out["author_count"] = nerd.authors.count
out["file_count"] = nerd.files.count
out["nonfile_count"] = nerd.nonfiles.count
Expand Down
4 changes: 2 additions & 2 deletions python/tests/nistoar/midas/dap/service/test_mds3_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def test_create(self):
self.assertIs(resp['meta']["creatorisContact"], False)
self.assertEqual(resp['data']['@id'], 'ark:/88434/mds3-0002')
self.assertEqual(resp['data']['doi'], 'doi:10.88888/mds3-0002')
self.assertNotIn('keyword', resp['data']) # because ['data'] is just a summary
self.assertNotIn('authors', resp['data']) # because ['data'] is just a summary
self.assertIn('contactPoint', resp['data']) # this is included in ['data'] summary

self.resp = []
Expand Down Expand Up @@ -248,7 +248,7 @@ def test_put_patch(self):
self.assertIs(resp['meta']["creatorisContact"], False)
self.assertEqual(resp['data']['@id'], 'ark:/88434/mds3-0001')
self.assertEqual(resp['data']['doi'], 'doi:10.88888/mds3-0001')
self.assertNotIn('keyword', resp['data']) # because ['data'] is just a summary
self.assertNotIn('authors', resp['data']) # because ['data'] is just a summary
self.assertIn('contactPoint', resp['data']) # this is included in ['data'] summary

self.resp = []
Expand Down
4 changes: 2 additions & 2 deletions python/tests/nistoar/midas/dap/service/test_mds3_app_wfm.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def test_create(self):
self.assertIs(resp['meta']["creatorisContact"], False)
self.assertEqual(resp['data']['@id'], 'ark:/88434/mds3-0002')
self.assertEqual(resp['data']['doi'], 'doi:10.88888/mds3-0002')
self.assertNotIn('keyword', resp['data']) # because ['data'] is just a summary
self.assertNotIn('authors', resp['data']) # because ['data'] is just a summary
self.assertIn('contactPoint', resp['data']) # this is included in ['data'] summary

self.resp = []
Expand Down Expand Up @@ -298,7 +298,7 @@ def test_put_patch(self):
self.assertIs(resp['meta']["creatorisContact"], False)
self.assertEqual(resp['data']['@id'], 'ark:/88434/mds3-0001')
self.assertEqual(resp['data']['doi'], 'doi:10.88888/mds3-0001')
self.assertNotIn('keyword', resp['data']) # because ['data'] is just a summary
self.assertNotIn('authors', resp['data']) # because ['data'] is just a summary
self.assertIn('contactPoint', resp['data']) # this is included in ['data'] summary

self.resp = []
Expand Down

0 comments on commit b8f3bcc

Please sign in to comment.