Esempio n. 1
0
def object_relation_post(id):
    content = request.get_json()
    type_int = CPL.relation_str_to_type(str(content['type']))
    if content['dest']:
        relation = cpl_object(id).relation_to(
            cpl_object(int(content['dest'])), type_int,
            cpl_bundle(int(content['bundle'])))
    else:
        relation = cpl_object(id).relation_from(
            cpl_object(int(content['src'])), type_int,
            cpl_bundle(int(content['bundle'])))
    return jsonify(id=relation.id)
Esempio n. 2
0
def object_relation_post(id):
    content = request.get_json()
    type_int = CPL.relation_str_to_type(str(content['type']))
    if content['dest']:
        relation = cpl_object(id).relation_to(cpl_object(int(content['dest'])),
                                              type_int,
                                              cpl_bundle(int(content['bundle'])))
    else:
        relation = cpl_object(id).relation_from(cpl_object(int(content['src'])),
                                                type_int,
                                                cpl_bundle(int(content['bundle'])))
    return jsonify(id=relation.id)
Esempio n. 3
0
def json_post():
    content = request.get_json()
    if content.get('anchor_objects'):
        anchors = [(cpl_object(int(a['id'])), str(a['name'])) for a in content['anchor_objects']]
    else:
        anchors = None
    bundle = connection.import_document_json(str(json.dumps(content['JSON'],ensure_ascii = False)),
                                    str(content['bundle_name']),
                                    anchors)
    return jsonify(id=bundle.id)
Esempio n. 4
0
def json_post():
    content = request.get_json()
    if content.get('anchor_objects'):
        anchors = [(cpl_object(int(a['id'])), str(a['name']))
                   for a in content['anchor_objects']]
    else:
        anchors = None
    bundle = connection.import_document_json(
        str(json.dumps(content['JSON'], ensure_ascii=False)),
        str(content['bundle_name']), anchors)
    return jsonify(id=bundle.id)
Esempio n. 5
0
def object_descendants_get(id):
    relations = cpl_object(id).relations(CPL.D_DESCENDANTS)
    return jsonify([serialize_relation_info(info) for info in relations])
Esempio n. 6
0
def object_ancestors_get(id):
    relations = cpl_object(id).relations()
    return jsonify(relations=[serialize_relation_info(info) for info in relations])
Esempio n. 7
0
def object_property_post(id):
    content = request.get_json()
    cpl_object(id).add_property(str(content['prefix']),
                                str(content['name']),
                                str(content['value']))
    return jsonify(success=True)
Esempio n. 8
0
def object_property_get(id, prefix=None, property=None):
    properties = cpl_object(id).properties(prefix, property)
    return jsonify(properties=
        [serialize_property_tuple(prop) for prop in properties])
Esempio n. 9
0
def object_get(id):
    info = cpl_object(id).info
    return jsonify(serialize_object_info(info))
Esempio n. 10
0
def object_descendants_get(id):
    relations = cpl_object(id).relations(CPL.D_DESCENDANTS)
    return jsonify([serialize_relation_info(info) for info in relations])
Esempio n. 11
0
def object_ancestors_get(id):
    relations = cpl_object(id).relations()
    return jsonify(
        relations=[serialize_relation_info(info) for info in relations])
Esempio n. 12
0
def object_property_post(id):
    content = request.get_json()
    cpl_object(id).add_property(str(content['prefix']), str(content['name']),
                                str(content['value']))
    return jsonify(success=True)
Esempio n. 13
0
def object_property_get(id, prefix=None, property=None):
    properties = cpl_object(id).properties(prefix, property)
    return jsonify(
        properties=[serialize_property_tuple(prop) for prop in properties])
Esempio n. 14
0
def object_get(id):
    info = cpl_object(id).info
    return jsonify(serialize_object_info(info))