def serialize_functions(project, functions): """Adds multiple functions to the language collection and returns a list of function objects. """ collection = get_language_collection(project) results = mongo_utils.mongo_insert_many(collection, functions) return results
def add_evaluations(project, evaluations): """Adds multiple evaluations to the evaluation collection and returns the complete evaluation object. """ collection = get_evaluation_collection(project) results = mongo_utils.mongo_insert_many(collection, evaluations) return results
def add_workflows(project, workflows): """Adds multiple workflows to the workflow collection and returns the complete workflow object. """ collection = get_workflow_collection(project) results = mongo_utils.mongo_insert_many(collection, workflows) return results
def create_translator_collection(database, translators): """Inserts all the given translators into the translators collection. Will automatically create the translators collection if it does not exist. Returns the translators in the collection. """ collection = get_translator_collection(database) record_ids = mongo_utils.mongo_insert_many(collection, translators) return record_ids
def create_structure_collection(database, structures): """Inserts all the given structures into the structures collection. Will automatically create the structures collection if it does not exist. Returns the structures in the collection. """ collection = get_structure_collection(database) record_ids = mongo_utils.mongo_insert_many(collection, structures) return record_ids
def create_record_collection(database, collection, records=None): """Inserts all the given records into the records collection for the given structure. Will automatically create the records collection if it does not exist. Returns the records in the collection. """ collection = get_record_collection(database, collection) if records: record_ids = mongo_utils.mongo_insert_many(collection, records) return record_ids return collection
def create_function_collection(project, functions=None): """Inserts all the given functions into the functions collection. Returns the status of effort. """ collection = get_function_collection(project) status = False if functions: if type(functions) is dict: status = mongo_utils.mongo_insert_one(collection, functions) else: if len(functions) == 1: status = mongo_utils.mongo_insert_one(collection, functions[0]) else: status = mongo_utils.mongo_insert_many(collection, functions) return status
def create_group_collection(database, groups=None): """Inserts all the given groups into the groups collection. Returns the status of effort. """ collection = get_group_collection(database) status = False if groups: if type(groups) is dict: status = mongo_utils.mongo_insert_one(collection, groups) else: if len(groups) == 1: status = mongo_utils.mongo_insert_one(collection, groups[0]) else: status = mongo_utils.mongo_insert_many(collection, groups) return status
def create_workflow_collection(project, workflows=None): """Inserts all the given workflows into the workflows collection. Will automatically create the stations collection if it does not exist. Returns the status of effort. """ collection = get_workflow_collection(project) status = False if workflows: if type(workflows) is dict: status = mongo_utils.mongo_insert_one(collection, workflows) else: if len(workflows) == 1: status = mongo_utils.mongo_insert_one(collection, workflows[0]) else: status = mongo_utils.mongo_insert_many(collection, workflows) return status
def create_new_project(project=None): """Attempts to create a new project from the passed dictionary project object. If it is successful, returns the new project object. If it fails, returns None. """ collection = get_project_collection() if type(project) in [dict, OrderedDict]: result = mongo_utils.mongo_insert_one(collection, project) return result else: if len(project) == 1: result = mongo_utils.mongo_insert_one(collection, project[0]) return result else: result = mongo_utils.mongo_insert_many(collection, project) return result return None
def create_component_collection(database, components=None): """Inserts all the given components into the components collection. Returns the status of effort. """ collection = get_component_collection(database) status = False if components: if type(components) is dict: status = mongo_utils.mongo_insert_one(collection, components) else: if len(components) == 1: status = mongo_utils.mongo_insert_one(collection, components[0]) else: status = mongo_utils.mongo_insert_many(collection, components) return status
def create_evaluation_collection(project, evaluations=None): """Inserts all the given evaluations into the evaluations collection. Will automatically create the stations collection if it does not exist. Returns the status of effort. """ collection = get_evaluation_collection(project) status = False if evaluations: if type(evaluations) is dict: status = mongo_utils.mongo_insert_one(collection, evaluations) else: if len(evaluations) == 1: status = mongo_utils.mongo_insert_one(collection, evaluations[0]) else: status = mongo_utils.mongo_insert_many(collection, evaluations) return status