Commit 3c2ccb96 authored by abuddenberg's avatar abuddenberg
Browse files

Changed a couple of Activity calls to create_or_update to support newer, more...

Changed a couple of Activity calls to create_or_update to support newer, more granular Activities in GCIS. Added a method to list all known Activities
parent fe33e343
......@@ -153,8 +153,9 @@ class GcisClient(object):
for dataset in image.datasets:
if not self.dataset_exists(dataset.identifier):
self.create_dataset(dataset)
if not self.activity_exists(dataset.activity.identifier):
self.create_activity(dataset.activity)
# if not self.activity_exists(dataset.activity.identifier):
# self.create_activity(dataset.activity))
self.create_or_update_activity(dataset.activity)
self.associate_dataset_with_image(dataset.identifier, image.identifier,
activity_id=dataset.activity.identifier)
return resp
......@@ -163,7 +164,8 @@ class GcisClient(object):
def update_image(self, image, old_id=None):
url = '{b}/image/{img}'.format(b=self.base_url, img=old_id or image.identifier)
for dataset in image.datasets:
self.update_activity(dataset.activity)
# self.update_activity(dataset.activity)
self.create_or_update_activity(dataset.activity)
self.associate_dataset_with_image(dataset.identifier, image.identifier,
activity_id=dataset.activity.identifier)
for c in image.contributors:
......@@ -385,6 +387,11 @@ class GcisClient(object):
else:
self.create_activity(activity)
def get_activity_list(self):
url = '{b}/activity'.format(b=self.base_url)
return self.s.get(url, params={'all': 1}, verify=False).json()
@exists
def person_exists(self, person_id):
url = '{b}/person/{pid}'.format(b=self.base_url, pid=person_id)
......
......@@ -26,7 +26,7 @@ def move_images_to_gcis(webform_client, gcis_client, webform_url, gcis_id, repor
def sync_dataset_metadata(gcis_client, datasets, skip=[]):
for ds in [ds for ds in datasets if ds.identifier not in skip]:
gcis_client.create_or_update_dataset(ds)
gcis_client.create_or_update_activity(ds.activity)
# gcis_client.create_or_update_activity(ds.activity)
def realize_contributors(gcis_client, contributors):
......
......@@ -124,7 +124,7 @@ class WebformClient:
k not in ['href', 'uri', 'identifier', 'start_time', 'end_time']}
#Add synthetic identifier
activity_json['identifier'] = dataset.identifier + '-process'
activity_json['identifier'] = '-'.join((image_obj.identifier.split('-')[0], dataset.identifier, 'process'))
dataset.activity = Activity(activity_json)
#TODO: Extract DOIs from citation
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment