Esempio n. 1
0
def get_all_acquisitions():
    acquisitions = ElasticsearchClient().get_all(index)
    result = list()
    for hit in acquisitions:
        result.append(document.dump(document.from_database(hit['_source'])))

    return jsonify(result)
Esempio n. 2
0
def get_movement_by_id(id):
    id_movement = ElasticsearchClient().get_id(index, id)
    if id_movement:
        return jsonify(
            document.dump(document.from_database(id_movement['_source'])))
    else:
        raise InvalidRequest('Movement not found', 404)
Esempio n. 3
0
def get_acquisition_by_id(id):
    id_acquisition = ElasticsearchClient().get_id(index, id)
    if id_acquisition:
        return jsonify(
            document.dump(document.from_database(id_acquisition['_source'])))
    else:
        raise InvalidRequest('Aquisition not found', 404)
Esempio n. 4
0
def add_consult():
    try:
        new_consult = document.load(request.get_json())
    except ValidationError as err:
        raise InvalidRequest(err.messages)

    id = ElasticsearchClient().insert(index, document.to_database(new_consult))
    new_consult['id'] = id

    return jsonify(document.dump(document.from_database(new_consult)))