Ejemplo n.º 1
0
def get_structure_by_name(database, structure_name, current=True):
    """Returns the structure or structures for the given database that have the
    given name. Optionally only returns current structures (non removed structures).
    """
    if current:
        return structure_dao.get_structure_by_name(database, structure_name)
    return None
Ejemplo n.º 2
0
def get_structure_by_name(database, structure_name, current=True):
    """Returns the structure or structures for the given database that have the
    given name. Optionally only returns current structures (non removed structures).
    """
    if current:
        return structure_dao.get_structure_by_name(database, structure_name)
    return None
Ejemplo n.º 3
0
def remove_template_from_structure(database, structure, template):
    """Removes the reference of the given template from the given structure. Returns
    the updated structure object.
    """
    if type(structure) not in [dict, OrderedDict]:
        structure = structure_dao.get_structure_by_name(database, structure)
    if type(template) in [dict, OrderedDict]:
        template = template['name']
    structure = structure_model.remove_template(structure, template)
    structure = structure_dao.update_structure(database, structure, changes=['templates'])
    return structure
Ejemplo n.º 4
0
def add_template_to_structure(database, structure, template):
    """Updates the given structure by adding a reference to its template to
    the structure template list. Returns the updated structure.
    """
    if type(database) in [dict, OrderedDict]:
        database = database['database']
    if type(structure) not in [dict, OrderedDict]:
        structure = structure_dao.get_structure_by_name(database, structure)
    if type(template) in [dict, OrderedDict]:
        template = template['name']
    structure = structure_model.add_template(structure, template)
    structure = structure_dao.update_structure(database, structure, changes=['templates'])
    return structure
Ejemplo n.º 5
0
def add_template_to_structure(database, structure, template, order=None):
    """Updates the given structure by adding a reference to its template to
    the structure template list. Returns the updated structure.
    """
    if type(database) in [dict, OrderedDict]:
        database = database['database']
    if type(structure) not in [dict, OrderedDict]:
        structure = structure_dao.get_structure_by_name(database, structure)
    if type(template) in [dict, OrderedDict]:
        template = template['name']
    structure = structure_model.add_template(structure, template, order=order)
    structure = structure_dao.update_structure(database, structure, changes=['templates'])
    return structure