From 174503fe290f3e5020214988fd1c061605c530ce Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Tue, 31 Mar 2015 15:35:19 -0700 Subject: [PATCH] support trying to figure out object type based on what collection its going to be posted to --- htsworkflow/submission/encoded.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/htsworkflow/submission/encoded.py b/htsworkflow/submission/encoded.py index 5a7866f..83f5826 100644 --- a/htsworkflow/submission/encoded.py +++ b/htsworkflow/submission/encoded.py @@ -230,6 +230,32 @@ class ENCODED: return obj_type[0] def get_schema_url(self, object_type): + """Create the ENCODED jsonschema url. + + Return the ENCODED object schema url be either + object type name or the collection name one posts to. + + For example + server.get_schema_url('experiment') and + server.get_schema_url('/experiments/') both resolve to + SERVER/profiles/experiment.json + + Arguments: + object_type (str): either ENCODED object name or collection + + Returns: + Schema URL + """ + collection_to_type = { + '/biosamples/': 'biosample', + '/datasets/': 'dataset', + '/documents/': 'document', + '/experiments/': 'experiment', + '/libraries/': 'library', + '/replicates/': 'replicate', + } + object_type = collection_to_type.get(object_type, object_type) + return self.prepare_url(ENCODED_SCHEMA_ROOT + object_type + '.json') + '#' def _is_encoded_object(self, obj): -- 2.30.2