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_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 add_evaluation(project, evaluation): """Adds a single evaluation to the evaluation collection and returns the complete evaluation object. """ collection = get_evaluation_collection(project) result = mongo_utils.mongo_insert_one(collection, evaluation) return get_evaluation_by_id(project, result)
def add_workflow(project, workflow): """Adds a single workflow to the workflow collection and returns the complete workflow object. """ collection = get_workflow_collection(project) result = mongo_utils.mongo_insert_one(collection, workflow) return get_workflow_by_id(project, result)
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 add_new_record(database, template, record): """Inserts a new record into the specified database/collection, returning the inserted record. """ collection = get_record_collection(database, template) record_id = mongo_utils.mongo_insert_one(collection, record) return get_record_by_id(database, template, record_id)
def serialize_function(project, function): """Adds a single function to the language collection and returns the complete function object. """ collection = get_language_collection(project) result = mongo_utils.mongo_insert_one(collection, function) return get_function_by_id(project, result)
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
def create_profile_collection(database, profile): """Inserts the given profile into the profiles collection. Will automatically create the profiles collection if it does not exist. Returns the added profile. """ collection = get_profile_collection(database) profile_id = mongo_utils.mongo_insert_one(collection, profile) return get_profile_by_id(database, profile_id)
def add_function(project, function): """Adds a single function to the function collection and returns the complete function object. """ collection = get_function_collection(project) result = mongo_utils.mongo_insert_one(collection, function) result_id = result.inserted_id return get_function_by_id(project, result_id)
def add_group(database, group): """Adds a single group to the component collection and returns the complete group object. """ collection = get_group_collection(database) result = mongo_utils.mongo_insert_one(collection, group) result_id = result.inserted_id return get_group_by_id(database, result_id)
def add_component(database, component): """Adds a single component to the component collection and returns the complete component object. """ collection = get_component_collection(database) result = mongo_utils.mongo_insert_one(collection, component) result_id = result.inserted_id return get_component_by_id(database, result_id)
def add_template(database, template): """Adds a single template to the template collection for the given database. """ collection = get_template_collection(database) template_id = mongo_utils.mongo_insert_one(collection, template) return get_template_by_id(database, template_id)
def add_structure(database, structure): """Adds a single structure to the structure collection for the given database. """ collection = get_structure_collection(database) structure_id = mongo_utils.mongo_insert_one(collection, structure) return get_structure_by_id(database, structure_id)