def get_enabled_functions(harness, current_only=True): """Returns the enabled functions for the specified harness. Optionally can return all records (including older) if current_only is set to False. """ collection = get_function_collection(harness) arguments = [] if current_only: arguments.append(db_utils.make_single_field_argument("remove_date", None)) arguments.append(db_utils.make_single_field_argument("status", "enabled")) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) function_list = db_utils.unload_cursor(cursor) return function_list
def get_functions_for_component(harness, component, current=True): """Returns functions for the given component for the given harness. Optional parameter allows user to return current or all functions. """ collection = get_function_collection(harness) arguments = [] if current: arguments.append(db_utils.make_single_field_argument("remove_date", None)) arguments.append(db_utils.make_single_field_argument("component", component)) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) function_list = db_utils.unload_cursor(cursor) return function_list
def get_current_templates_by_structure_name(database, structure_name): """Returns all templates in storage for the given structure name. """ collection = get_template_collection(database) arguments = [] arguments.append(db_utils.make_single_field_argument('structure', structure_name)) arguments.append(db_utils.make_single_field_argument('remove_date', None)) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument) template_list = db_utils.unload_cursor(cursor) try: return template_list except IndexError: return None
def get_structure_by_id(database, structure_id): """Returns the current profile by name. """ collection = get_structure_collection(database) arguments = [] arguments.append(db_utils.make_single_field_argument('_id', structure_id)) arguments.append(db_utils.make_single_field_argument('remove_date', None)) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument) structure_list = db_utils.unload_cursor(cursor) try: return structure_list[0] except IndexError: return None
def get_current_function_by_name(harness, name): """Returns the current function by name. """ collection = get_function_collection(harness) arguments = [] arguments.append(db_utils.make_single_field_argument("name", name)) arguments.append(db_utils.make_single_field_argument("remove_date", None)) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) function_list = db_utils.unload_cursor(cursor) try: return function_list[0] except IndexError: return None
def get_translator_by_id(database, translator_id): """Returns the current translator by id. """ collection = get_translator_collection(database) arguments = [] arguments.append(db_utils.make_single_field_argument('_id', translator_id)) arguments.append(db_utils.make_single_field_argument('remove_date', None)) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument) translator_list = db_utils.unload_cursor(cursor) try: return translator_list[0] except IndexError: return None
def get_disabled_components(database, current_only=True): """Returns the disabled components for the specified database. Optionally can return all records (including older) if current_only is set to False. """ collection = get_component_collection(database) arguments = [] if current_only: arguments.append(db_utils.make_single_field_argument('remove_date', None)) arguments.append(db_utils.make_single_field_argument('status', 'disabled')) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) component_list = db_utils.unload_cursor(cursor) return component_list
def get_current_component_by_name(database, name): """Returns the current component by name. """ collection = get_component_collection(database) arguments = [] arguments.append(db_utils.make_single_field_argument('name', name)) arguments.append(db_utils.make_single_field_argument('remove_date', None)) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) component_list = db_utils.unload_cursor(cursor) try: return component_list[0] except IndexError: return None
def remove_harness_record_by_name(harness_name): """Removes a single record from the harness database with the specified harness name. """ collection = get_harness_collection() argument = db_utils.make_single_field_argument("name", harness_name) removal = db_utils.mongo_remove_one(collection, argument) return removal
def get_current_structures(database): """Returns all the structures that haven't been removed. """ collection = get_structure_collection(database) argument = db_utils.make_single_field_argument("remove_date", None) cursor = db_utils.mongo_find_records(collection, argument=argument) return db_utils.unload_cursor(cursor)
def get_functions_by_name(harness, name): """ Returns all the functions by name, if it exists, otherwise returns False """ collection = get_function_collection(harness) argument = db_utils.make_single_field_argument("name", name) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) return db_utils.unload_cursor(cursor)
def update_workflow_status_by_id(harness, workflow_id, status): """Updates the status of the workflow with the given id to the given status. """ collection = get_workflow_collection(harness) argument = db_utils.make_single_field_argument('_id', workflow_id) update = db_utils.make_update_argument('status', status) cursor = db_utils.mongo_update_one(collection, argument, update) return cursor
def update_component_vcs_status_by_id(database, component_id, status): """Updates the vcs status of the given component with the specified status. """ collection = get_component_collection(database) argument = db_utils.make_single_field_argument('_id', component_id) update = db_utils.make_update_argument('vcs.status', status) cursor = db_utils.mongo_update_one(collection, argument, update) return cursor
def get_all_stations_by_program(program): """Returns all the stations that are within the given program. """ collection = get_station_collection() argument = db_utils.make_single_field_argument("program", program) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) return db_utils.unload_cursor(cursor)
def get_removed_functions(harness): """Returns functions that have been removed from the specified harness. Optionally can return all records (including older) if current_only is set to False. """ collection = get_function_collection(harness) argument = db_utils.make_single_field_argument("status", "removed") cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) return db_utils.unload_cursor(cursor)
def get_components_by_name(database, name): """ Returns all the components by name, if it exists, otherwise returns False """ collection = get_component_collection(database) argument = db_utils.make_single_field_argument('name', name) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) return db_utils.unload_cursor(cursor)
def get_all_current_functions(harness): """Returns all functions that are current (no removal date) in the current harness. """ collection = get_function_collection(harness) argument = db_utils.make_single_field_argument("remove_date", None) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) return db_utils.unload_cursor(cursor)
def update_function_vcs_status_by_id(harness, function_id, status): """Updates the vcs status of the given function with the specified status. """ collection = get_function_collection(harness) argument = db_utils.make_single_field_argument("_id", function_id) update = db_utils.make_update_argument("vcs.status", status) cursor = db_utils.mongo_update_one(collection, argument, update) return cursor
def get_removed_components(database): """Returns components that have been removed from the specified database. Optionally can return all records (including older) if current_only is set to False. """ collection = get_component_collection(database) argument = db_utils.make_single_field_argument('status', 'removed') cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) return db_utils.unload_cursor(cursor)
def get_all_current_components(database): """Returns all components that are current (no removal date) in the current database. """ collection = get_component_collection(database) argument = db_utils.make_single_field_argument('remove_date', None) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) return db_utils.unload_cursor(cursor)
def remove_component_by_id(database, component_id, timestamp): """Updates the component with the given id to have a removal datetime of the given datetime and sets the component status to removed. """ update_component_status_by_id(database, component_id, 'removed') collection = get_component_collection(database) argument = db_utils.make_single_field_argument('_id', component_id) update = db_utils.make_update_argument('remove_date', timestamp) cursor = db_utils.mongo_update_one(collection, argument, update) return cursor
def remove_workflow_by_id(harness, workflow_id, timestamp): """Updates the workflow with the given id to have a removal datetime of the given datetime and sets the workflow status to removed. """ update_workflow_status_by_id(harness, workflow_id, 'removed') collection = get_workflow_collection(harness) argument = db_utils.make_single_field_argument('_id', workflow_id) update = db_utils.make_update_argument('remove_date', timestamp) cursor = db_utils.mongo_update_one(collection, argument, update) return cursor
def remove_function_by_id(harness, function_id, timestamp): """Updates the function with the given id to have a removal datetime of the given datetime and sets the function status to removed. """ update_function_status_by_id(harness, function_id, "removed") collection = get_function_collection(harness) argument = db_utils.make_single_field_argument("_id", function_id) update = db_utils.make_update_argument("remove_date", timestamp) cursor = db_utils.mongo_update_one(collection, argument, update) return cursor
def update_component_functions_by_id(database, component_id, functions): """Updates the status of the component with the given id to the given status. """ collection = get_component_collection(database) argument = db_utils.make_single_field_argument('_id', component_id) update = db_utils.make_update_argument('functions', functions) cursor = db_utils.mongo_update_one(collection, argument, update) updated_component = None if cursor.modified_count == 1: updated_component = get_component_by_id(database, component_id) return updated_component
def get_function_by_id(harness, function_id): """Returns the function by the given id. """ collection = get_function_collection(harness) argument = db_utils.make_single_field_argument("_id", function_id) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) function_list = db_utils.unload_cursor(cursor) try: return function_list[0] except IndexError: return None
def get_record_by_id(database, collection, record_id): """Returns the record for the given id. """ collection = get_record_collection(database, collection) argument = db_utils.make_single_field_argument("_id", record_id) cursor = db_utils.mongo_find_records(collection, argument=argument) record_list = db_utils.unload_cursor(cursor) try: return record_list[0] except IndexError: return None
def get_harness_by_name(harness_name): """Returns the harness object with the matching passed name. """ collection = get_harness_collection() argument = db_utils.make_single_field_argument("name", harness_name) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) harness_list = db_utils.unload_cursor(cursor) try: return harness_list[0] except: return None
def get_workflow_by_id(harness, workflow_id): """Returns the workflow by the given id. """ collection = get_workflow_collection(harness) argument = db_utils.make_single_field_argument('_id', workflow_id) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) workflow_list = db_utils.unload_cursor(cursor) try: return workflow_list[0] except IndexError: return None
def get_component_by_id(database, component_id): """Returns the component by the given id. """ collection = get_component_collection(database) argument = db_utils.make_single_field_argument('_id', component_id) cursor = db_utils.mongo_find_records(collection, argument=argument, named_tuple=False) component_list = db_utils.unload_cursor(cursor) try: return component_list[0] except IndexError: return None
def get_translator_by_name(database, name, template, structure): """Returns the current translator by name. Must specify both an template name and a structure name. If no name specified, returns the default translator. """ collection = get_translator_collection(database) arguments = [] if not name: name = 'default' if not template: template = 'default' arguments.append(db_utils.make_single_field_argument('name', name)) arguments.append(db_utils.make_single_field_argument('template', template)) arguments.append(db_utils.make_single_field_argument('structure', structure)) arguments.append(db_utils.make_single_field_argument('remove_date', None)) argument = utils.merge_list_of_dicts(arguments) cursor = db_utils.mongo_find_records(collection, argument=argument) translator_list = db_utils.unload_cursor(cursor) try: return translator_list[0] except IndexError: return None