def index(): error, param = checkonlyone(["uuids", "titles"], request) if error: return abort(400, {'error': error}) error = checkparams(["levels", "type_analysis"], request) if error: return abort(400, {'error': error}) levels = request.json['levels'] type_analysis = request.json['type_analysis'] if param == "titles": with get_neo4j_db() as session: ids = session.write_transaction( getUuidsFromNodes, ("external_id", request.json[param])) paths = parseBoltPathsFlat( session.write_transaction(queryPath, type_analysis, ids, levels), type_analysis, session) return jsonify({"data": {"paths": paths, "uuids": ids}}), 200 ids = request.json["uuids"] with get_neo4j_db() as session: unit = queryPathApoc if current_app.config["APOC"] else queryPath paths = parseBoltPathsFlat( session.write_transaction(unit, type_analysis, ids, levels), type_analysis, session) return jsonify({"data": {"paths": paths, "uuids": ids}}), 200
def levelsFromPath(): levels = request.json['levels'] struct_id = request.json["struct_id"] with get_neo4j_db() as session: ids = session.write_transaction(getUuidsFromNodes, ("struct_id", struct_id)) paths = parseBoltPathsTree(ids, levels, session) return jsonify({"data": paths}), 200
def indexTop(): """ List top groups file: {0}/v1/swagger/groups_index_top.yml """ with get_neo4j_db() as session: groups = session.read_transaction(getTopGroups) groups = parseBoltRecords(groups) return jsonify({"data": groups}), 200
def index(): if not request.args: return abort(400, {'message': 'Error args not found'}) error, keyvalue = findInArgs("name", request.args) if error: return abort(400, {'message': error}) with get_neo4j_db() as session: nodes = parseBoltRecords(session.write_transaction(searchResourceReg, keyvalue[0], keyvalue[1])) return jsonify({"data": nodes}), 200
def typeGroups(): """ Get groups types file: {0}/v1/swagger/groups_types.yml """ nodes = {} with get_neo4j_db() as session: lista = session.write_transaction(queryMatchType, "Group") nodes["types"] = [x["type"] for x in lista.data()] return jsonify({"data": nodes}), 200
def show(id): """ Get a specified group file: {0}/v1/swagger/groups_show.yml """ with get_neo4j_db() as session: nodes = parseBoltRecords( session.write_transaction(queryGetNode, "Group", id)) if not nodes: return jsonify({"data": []}), 200 return jsonify({"data": nodes[0]}), 200
def treeGroups(): """ Get groups tree file: {0}/v1/swagger/groups_tree.yml """ nodes = {} with get_neo4j_db() as session: result = session.write_transaction(queryGroupTree) nodes["tree"] = [x["value"] for x in result.data()] return jsonify({"data": nodes}), 200
def cache(): with get_neo4j_db() as session: result = session.read_transaction(queryExtenalIds) system_external_ids = defaultdict(list) for r in result: system_external_id = r["system_external_id"] external_id = r["external_id"] system_external_ids[system_external_id].append(external_id) cache_structures_external_ids(system_external_ids) return '', 204
def writeQuery(): try: with get_neo4j_db() as session: result = session.run(request.json['query']) except exceptions.ConstraintError as exception: return abort(400, {'Exception message': exception.message}) except exceptions.CypherSyntaxError as exception: return abort(400, {'Exception message': exception.message}) except exceptions.CypherTypeError as exception: return abort(400, {'Exception message': exception.message}) except: return abort(400, {'Exception message': 'Unknown Error'}) return "", 204
def index(): """ Get a list of groups file: {0}/v1/swagger/groups_index.yml """ filters = "" if request.args: filters = buildNodeFilterEqual(request.args.items()) with get_neo4j_db() as session: nodes = parseBoltRecords( session.write_transaction(queryMatchNode, "Group", filters)) return jsonify({"data": nodes}), 200
def indexContains(id): """ List nodes with contains relation with group id passed in url file: {0}/v1/swagger/groups_index_contains.yml """ with get_neo4j_db() as session: # We could have several names for the same node. # We have to query first all the nodes having the same # name as the node queried in the request nodes = session.read_transaction(listGroupContains, id) nodes = parseBoltRecords(nodes) return jsonify({"data": nodes}), 200
def contains(id): """ Get contained groups ids from a specified group file: {0}/v1/swagger/groups_contains.yml """ with get_neo4j_db() as session: nodes = parseBoltRecords( session.write_transaction(queryGetNode, "Group", id)) if not nodes: return jsonify({"data": []}), 200 lista = session.write_transaction(queryGroupContains, id) nodes[0]["contains"] = [x["(id(r))"] for x in lista.data()] return jsonify({"data": nodes}), 200
def topGroup(): """ Get group toptype file: {0}/v1/swagger/groups_toptype.yml """ result = {} with get_neo4j_db() as session: types = session.write_transaction(getTopGroupType) types = [x["type"] for x in types.data()] if not types: result["type"] = "" return jsonify(result, 200) result["type"] = types[0] return jsonify({"data": result}), 200
def pathGroups(): """ Get groups path file: {0}/v1/swagger/groups_path.yml """ error = checkparams(["levels", "type_analysis"], request) if error: return abort(400, {'message': error}) levels = request.json["levels"] type_analysis = request.json["type_analysis"] group_ids = request.json["uuids"] with get_neo4j_db() as session: ids = session.write_transaction(queryGetResourcesFromGroups, group_ids) paths = parseBoltPathsFlat( session.write_transaction(queryPath, type_analysis, ids, levels), type_analysis, session) return jsonify({"data": {"paths": paths, "uuids": ids}}), 200