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 objects_lookup():
    content = request.get_json()
    type_int = CPL.object_str_to_type(str(content['type']))
    objects = connection.lookup_all_objects(
        str(content['prefix']), str(content['name']), type_int,
        cpl_bundle(str(content['bundle']) if content['bundle'] else None))
    return jsonify(ids=[o.id for o in objects])
Esempio n. 4
0
def object_post():
    content = request.get_json()
    type_int = CPL.object_str_to_type(str(content['type']))
    o = connection.create_object(str(content['prefix']),
                                 str(content['name']),
                                 type_int,
                                 cpl_bundle(int(content['bundle'])))
    return jsonify(id=o.id)
Esempio n. 5
0
def objects_lookup():
    content = request.get_json()
    type_int = CPL.object_str_to_type(str(content['type']))
    objects = connection.lookup_all_objects(str(content['prefix']),
                                            str(content['name']),
                                            type_int,
                                            cpl_bundle(str(content['bundle'])
                                                       if content['bundle'] 
                                                       else None))
    return jsonify(ids=[o.id for o in objects])    
Esempio n. 6
0
def bundle_property_post(id):
    content = request.get_json()
    cpl_bundle(id).add_property(str(content['prefix']),
                                str(content['name']),
                                str(content['value']))
    return jsonify(success=True)
Esempio n. 7
0
def bundle_property_get(id, prefix=None, name=None):
    properties = cpl_bundle(id).properties(prefix, name)
    return jsonify(properties=[serialize_property_tuple(prop) for prop in properties])
Esempio n. 8
0
def bundle_prefix_post(id):
    content = request.get_json()
    cpl_bundle(id).add_prefix(str(content['prefix']),
                              str(content['iri']))
    return jsonify(success=True)
Esempio n. 9
0
def bundle_prefix_post(id):
    content = request.get_json()
    cpl_bundle(id).add_prefix(str(content['prefix']), str(content['iri']))
    return jsonify(success=True)
Esempio n. 10
0
def bundle_get(id):
    info = cpl_bundle(id).info()
    return jsonify(name=info.name,
               creation_time=info.creation_time,
               creation_session=info.creation_session.id)
Esempio n. 11
0
def object_post():
    content = request.get_json()
    type_int = CPL.object_str_to_type(str(content['type']))
    o = connection.create_object(str(content['prefix']), str(content['name']),
                                 type_int, cpl_bundle(int(content['bundle'])))
    return jsonify(id=o.id)
Esempio n. 12
0
def bundle_relations_get(id):
    relations = connection.get_bundle_relations(cpl_bundle(id))
    return jsonify(relations=[serialize_relation_info(r) for r in relations])
Esempio n. 13
0
def bundle_objects_get(id):
    objects = connection.get_bundle_objects(cpl_bundle(id))
    return jsonify(objects=[serialize_object_info(o) for o in objects])
Esempio n. 14
0
def bundle_property_post(id):
    content = request.get_json()
    cpl_bundle(id).add_property(str(content['prefix']), str(content['name']),
                                str(content['value']))
    return jsonify(success=True)
Esempio n. 15
0
def bundle_property_get(id, prefix=None, name=None):
    properties = cpl_bundle(id).properties(prefix, name)
    return jsonify(
        properties=[serialize_property_tuple(prop) for prop in properties])
Esempio n. 16
0
def bundle_objects_get(id):
    objects = connection.get_bundle_objects(cpl_bundle(id))
    return jsonify(objects=[serialize_object_info(o) for o in objects])
Esempio n. 17
0
def bundle_relations_get(id):
    relations = connection.get_bundle_relations(cpl_bundle(id))
    return jsonify(relations=[serialize_relation_info(r) for r in relations])
Esempio n. 18
0
def bundle_json_get(id):
    json = connection.export_bundle_json([cpl_bundle(id)])
    return jsonify(JSON=json)
Esempio n. 19
0
def bundle_get(id):
    info = cpl_bundle(id).info()
    return jsonify(name=info.name,
                   creation_time=info.creation_time,
                   creation_session=info.creation_session.id)
Esempio n. 20
0
def bundle_delete(id):
    connection.delete_bundle(cpl_bundle(id))
    return jsonify(success=True)
Esempio n. 21
0
def bundle_json_get(id):
    json = connection.export_bundle_json([cpl_bundle(id)])
    return jsonify(JSON=json)
Esempio n. 22
0
def bundle_prefix_get(id, prefix=None):
    prefixes = cpl_bundle(id).prefixes(prefix)
    return jsonify(prefixes=[serialize_prefix_tuple(pre) for pre in prefixes])
Esempio n. 23
0
def bundle_delete(id):
    connection.delete_bundle(cpl_bundle(id))
    return jsonify(success=True)
Esempio n. 24
0
def bundle_prefix_get(id, prefix=None):
    prefixes = cpl_bundle(id).prefixes(prefix)
    return jsonify(prefixes=[serialize_prefix_tuple(pre) for pre in prefixes])