def create_function_collection(harness, functions=None): """Inserts all the given functions into the functions collection. Returns the status of effort. """ collection = get_function_collection(harness) status = False if functions: if type(functions) is dict: status = db_utils.mongo_insert_one(collection, functions) else: if len(functions) == 1: status = db_utils.mongo_insert_one(collection, functions[0]) else: status = db_utils.mongo_insert_many(collection, functions) return status
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 = db_utils.mongo_insert_one(collection, components) else: if len(components) == 1: status = db_utils.mongo_insert_one(collection, components[0]) else: status = db_utils.mongo_insert_many(collection, components) return status
def create_new_harness(harness=None): """Attempts to create a new harness from the passed dictionary harness object. If it is successful, returns the new harness object. If it fails, returns None. """ collection = get_harness_collection() if type(harness) in [dict, OrderedDict]: result = db_utils.mongo_insert_one(collection, harness) return result else: if len(harness) == 1: result = db_utils.mongo_insert_one(collection, harness[0]) return result else: result = db_utils.mongo_insert_many(collection, harness) return result return None
def add_workflow(harness, workflow): """Adds a single workflow to the workflow collection and returns the complete workflow object. """ collection = get_workflow_collection(harness) result = db_utils.mongo_insert_one(collection, workflow) return get_workflow_by_id(harness, result)
def create_workflow_collection(harness, 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(harness) status = False if workflows: if type(workflows) is dict: status = db_utils.mongo_insert_one(collection, workflows) else: if len(workflows) == 1: status = db_utils.mongo_insert_one(collection, workflows[0]) else: status = db_utils.mongo_insert_many(collection, workflows) return status
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 = db_utils.mongo_insert_one(collection, record) return get_record_by_id(database, template, record_id)
def add_function(harness, function): """Adds a single function to the function collection and returns the complete function object. """ collection = get_function_collection(harness) result = db_utils.mongo_insert_one(collection, function) result_id = result.inserted_id return get_function_by_id(harness, 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 = db_utils.mongo_insert_one(collection, component) result_id = result.inserted_id return get_component_by_id(database, result_id)
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 = db_utils.mongo_insert_one(collection, profile) return get_profile_by_id(database, profile_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 = db_utils.mongo_insert_one(collection, structure) return get_structure_by_id(database, structure_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 = db_utils.mongo_insert_one(collection, template) return get_template_by_id(database, template_id)