Skip to content
Snippets Groups Projects
Commit a7dad278 authored by Megan Henning's avatar Megan Henning Committed by Gunnar Schaefer
Browse files

Move reaper upload, change uid upload logic

parent 7b2788c6
No related branches found
No related tags found
No related merge requests found
......@@ -84,10 +84,10 @@ endpoints = [
# General-purpose upload & download
route('/download', Download, h='download', m=['GET', 'POST']),
route('/upload/<strategy:label|uid|uid-match>', Upload, h='upload', m=['POST']),
route('/clean-packfiles', Upload, h='clean_packfile_tokens', m=['POST']),
route('/engine', Upload, h='engine', m=['POST']),
route('/download', Download, h='download', m=['GET', 'POST']),
route('/upload/<strategy:label|uid|uid-match|reaper>', Upload, h='upload', m=['POST']),
route('/clean-packfiles', Upload, h='clean_packfile_tokens', m=['POST']),
route('/engine', Upload, h='engine', m=['POST']),
# Top-level endpoints
......
......@@ -135,7 +135,8 @@ class UIDPlacer(Placer):
Sessions and acquisitions are identified by UID.
"""
metadata_schema = 'uidupload.json'
create_hierarchy = staticmethod(hierarchy.upsert_bottom_up_hierarchy)
create_hierarchy = staticmethod(hierarchy.upsert_top_down_hierarchy)
match_type = 'uid'
def __init__(self, container_type, container, id_, metadata, timestamp, origin, context):
super(UIDPlacer, self).__init__(container_type, container, id_, metadata, timestamp, origin, context)
......@@ -151,7 +152,7 @@ class UIDPlacer(Placer):
metadata_validator(self.metadata, 'POST')
# If not a superuser request, pass uid of user making the upload request
targets = self.create_hierarchy(self.metadata, user=self.context.get('uid'), site=self.context.get('site'))
targets = self.create_hierarchy(self.metadata, type_=self.match_type, user=self.context.get('uid'), site=self.context.get('site'))
self.metadata_for_file = {}
......@@ -201,6 +202,18 @@ class UIDPlacer(Placer):
self.recalc_session_compliance()
return self.saved
class ReaperUIDPlacer(UIDPlacer):
"""
A placer that creates or matches based on UID.
Ignores project and group information if it finds session with matching UID.
Allows users to move sessions during scans without causing new data to be
created in referenced project/group.
"""
metadata_schema = 'uidmatchupload.json'
create_hierarchy = staticmethod(hierarchy.hierarchy.upsert_bottom_up_hierarchy)
match_type = 'uid'
class LabelPlacer(UIDPlacer):
"""
......@@ -212,6 +225,7 @@ class LabelPlacer(UIDPlacer):
metadata_schema = 'labelupload.json'
create_hierarchy = staticmethod(hierarchy.upsert_top_down_hierarchy)
match_type = 'label'
class UIDMatchPlacer(UIDPlacer):
......@@ -221,6 +235,7 @@ class UIDMatchPlacer(UIDPlacer):
metadata_schema = 'uidmatchupload.json'
create_hierarchy = staticmethod(hierarchy.find_existing_hierarchy)
match_type = 'uid'
class EnginePlacer(Placer):
......
......@@ -21,6 +21,7 @@ Strategy = util.Enum('Strategy', {
'labelupload' : pl.LabelPlacer,
'uidupload' : pl.UIDPlacer,
'uidmatch' : pl.UIDMatchPlacer,
'reaper' : pl.UIDReaperPlacer,
'analysis' : pl.AnalysisPlacer, # Upload N files to an analysis as input and output (no db updates)
'analysis_job': pl.AnalysisJobPlacer # Upload N files to an analysis as output from job results
})
......@@ -165,6 +166,8 @@ class Upload(base.RequestHandler):
strategy = Strategy.uidupload
elif strategy == 'uid-match':
strategy = Strategy.uidmatch
elif strategy == 'reaper':
strategy = Strategy.reaper
else:
self.abort(500, 'stragegy {} not implemented'.format(strategy))
return process_upload(self.request, strategy, origin=self.origin, context=context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment