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)
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)
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])
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)
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])
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)
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])
def bundle_prefix_post(id): content = request.get_json() cpl_bundle(id).add_prefix(str(content['prefix']), str(content['iri'])) return jsonify(success=True)
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)
def bundle_relations_get(id): relations = connection.get_bundle_relations(cpl_bundle(id)) return jsonify(relations=[serialize_relation_info(r) for r in relations])
def bundle_objects_get(id): objects = connection.get_bundle_objects(cpl_bundle(id)) return jsonify(objects=[serialize_object_info(o) for o in objects])
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])
def bundle_json_get(id): json = connection.export_bundle_json([cpl_bundle(id)]) return jsonify(JSON=json)
def bundle_delete(id): connection.delete_bundle(cpl_bundle(id)) return jsonify(success=True)
def bundle_prefix_get(id, prefix=None): prefixes = cpl_bundle(id).prefixes(prefix) return jsonify(prefixes=[serialize_prefix_tuple(pre) for pre in prefixes])