Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
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
Exemple #6
0
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
Exemple #7
0
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
Exemple #8
0
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
Exemple #9
0
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