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_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 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 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 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 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 update_workflow(harness, workflow, changes): """Updates the given workflow by adding changes for the given changed parameters to the current record. """ collection = get_workflow_collection(harness) workflow_id = workflow['_id'] argument = db_utils.make_single_field_argument('_id', workflow_id) updates = [] for change in changes: if '.' in change: nested_changes = change.split('.') nested_value_string = 'workflow' for nested_change in nested_changes: nested_value_string += '["'"{0}"'"]'.format(nested_change) updates.append(db_utils.make_update_argument(change, eval(nested_value_string))) else: updates.append(db_utils.make_update_argument(change, workflow[change])) update = db_utils.merge_update_args(updates) cursor = db_utils.mongo_update_one(collection, argument, update) if cursor.matched_count == 1: return get_workflow_by_id(harness, workflow_id) return None
def update_structure(database, structure, changes): """Updates the given structure by adding changes for the given changed parameters to the current record. """ collection = get_structure_collection(database) structure_id = structure['_id'] argument = db_utils.make_single_field_argument('_id', structure_id) updates = [] for change in changes: if '.' in change: nested_changes = change.split('.') nested_value_string = 'structure' for nested_change in nested_changes: nested_value_string += '["'"{0}"'"]'.format(nested_change) updates.append(db_utils.make_update_argument(change, eval(nested_value_string))) else: updates.append(db_utils.make_update_argument(change, structure[change])) update = db_utils.merge_update_args(updates) cursor = db_utils.mongo_update_one(collection, argument, update) if cursor.matched_count == 1: return get_structure_by_id(database, structure_id) return None