Beispiel #1
0
def save(data, relation=None):
    """ Save or update a relation with the given properties. """
    data = validate(data, relation)

    operation = 'create' if relation is None else 'update'
    if relation is None:
        relation = Relation()
        relation.project = data.get('project')
        relation.author = data.get('author')
        db.session.add(relation)

    relation.source = data.get('source')
    relation.target = data.get('target')
    relation.schema = data.get('schema')

    prop_names = set()
    for name, prop in data.get('properties').items():
        prop_names.add(name)
        prop['name'] = name
        prop['author'] = data.get('author')
        properties_logic.save(relation, prop)

    for prop in relation.properties:
        if prop.name not in prop_names:
            prop.active = False

    db.session.flush()
    _relation_changed.delay(relation.id, operation)
    return relation
Beispiel #2
0
def save(data, relation=None):
    """ Save or update a relation with the given properties. """
    data = validate(data, relation)

    operation = "create" if relation is None else "update"
    if relation is None:
        relation = Relation()
        relation.project = data.get("project")
        relation.author = data.get("author")
        db.session.add(relation)

    relation.source = data.get("source")
    relation.target = data.get("target")
    relation.schema = data.get("schema")

    prop_names = set()
    for name, prop in data.get("properties").items():
        prop_names.add(name)
        prop["name"] = name
        prop["author"] = data.get("author")
        properties_logic.save(relation, prop)

    for prop in relation.properties:
        if prop.name not in prop_names:
            prop.active = False

    db.session.flush()
    _relation_changed.delay(relation.id, operation)
    return relation
Beispiel #3
0
def save(data, relation=None):
    """ Save or update a relation with the given properties. """
    data = validate(data, relation)

    operation = 'create' if relation is None else 'update'
    if relation is None:
        relation = Relation()
        relation.project = data.get('project')
        relation.author = data.get('author')
        db.session.add(relation)

    relation.source = data.get('source')
    relation.target = data.get('target')
    relation.schema = data.get('schema')

    prop_names = set()
    for name, prop in data.get('properties').items():
        prop_names.add(name)
        prop['name'] = name
        prop['author'] = data.get('author')
        properties_logic.save(relation, prop)

    for prop in relation.properties:
        if prop.name not in prop_names:
            prop.active = False

    db.session.flush()
    _relation_changed.delay(relation.id, operation)
    return relation
Beispiel #4
0
def save(data, relation=None):
    """ Save or update a relation with the given properties. """

    data = validate(data)

    if relation is None:
        relation = Relation()
        relation.project = data.get('project')
        relation.author = data.get('author')
        db.session.add(relation)

    relation.source = data.get('source')
    relation.target = data.get('target')
    relation.schema = data.get('schema')
    properties_logic.set_many(relation, data.get('author'),
        data.get('properties'))
    db.session.flush()
    
    _relation_changed.delay(relation.id)
    return relation
Beispiel #5
0
def save(data, relation=None):
    """ Save or update a relation with the given properties. """

    data = validate(data)

    if relation is None:
        relation = Relation()
        relation.project = data.get('project')
        relation.author = data.get('author')
        db.session.add(relation)

    relation.source = data.get('source')
    relation.target = data.get('target')
    relation.schema = data.get('schema')
    properties_logic.set_many(relation, data.get('author'),
                              data.get('properties'))
    db.session.flush()

    _relation_changed.delay(relation.id)
    return relation