예제 #1
0
def add_functions(harness, functions):
    """Adds  multiple functions to the function collection and returns the complete
    function object.
    """
    collection = get_function_collection(harness)
    results = db_utils.mongo_insert_many(collection, functions)
    return results
예제 #2
0
def add_workflows(harness, workflows):
    """Adds  multiple workflows to the workflow collection and returns the complete
    workflow object.
    """
    collection = get_workflow_collection(harness)
    results = db_utils.mongo_insert_many(collection, workflows)
    return results
예제 #3
0
def create_structure_collection(database, structures):
    """Inserts all the given structures into the structures collection.
    Will automatically create the structures collection if it does not exist.
    Returns the structures in the collection.
    """
    collection = get_structure_collection(database)
    record_ids = db_utils.mongo_insert_many(collection, structures)
    return record_ids
예제 #4
0
def create_translator_collection(database, translators):
    """Inserts all the given translators into the translators collection.
    Will automatically create the translators collection if it does not exist.
    Returns the translators in the collection.
    """
    collection = get_translator_collection(database)
    record_ids = db_utils.mongo_insert_many(collection, translators)
    return record_ids
예제 #5
0
def create_station_collection(stations):
    """Inserts all the given stations into the stations collection.
    Will automatically create the stations collection if it does not exist.
    Returns the status of effort.
    """
    collection = get_station_collection()
    status = db_utils.mongo_insert_many(collection, stations)
    return status
예제 #6
0
def create_record_collection(database, collection, records=None):
    """Inserts all the given records into the records collection for the given structure.
    Will automatically create the records collection if it does not exist.
    Returns the records in the collection.
    """
    collection = get_record_collection(database, collection)
    if records:
        record_ids = db_utils.mongo_insert_many(collection, records)
        return record_ids
    return collection
예제 #7
0
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
예제 #8
0
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
예제 #9
0
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
예제 #10
0
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