Exemplo n.º 1
0
def query():
    """Get start points

    Returns
    -------
    json
        startpoint: list of start points
        error: True if error, else False
        errorMessage: the error message of error, else an empty string
    """
    try:
        tse = TriplestoreExplorer(current_app, session)
        results_handler = ResultsHandler(current_app, session)

        startpoints = tse.get_startpoints()
        public_queries = results_handler.get_public_queries()
    except Exception as e:
        traceback.print_exc(file=sys.stdout)
        return jsonify({
            'startpoints': [],
            "publicQueries": [],
            'error': True,
            'errorMessage': str(e)
        }), 500

    return jsonify({
        'startpoints': startpoints,
        "publicQueries": public_queries,
        'error': False,
        'errorMessage': ''
    })
Exemplo n.º 2
0
def query():
    """Get start points

    Returns
    -------
    json
        startpoint: list of start points
        error: True if error, else False
        errorMessage: the error message of error, else an empty string
    """
    try:
        # If public datasets and queries are protected, dont return anything to unlogged users
        if "user" not in session and current_app.iniconfig.getboolean("askomics", "protect_public"):
            startpoints = []
            public_queries = []
            public_form_queries = []
        else:
            tse = TriplestoreExplorer(current_app, session)
            results_handler = ResultsHandler(current_app, session)
            startpoints = tse.get_startpoints()
            public_queries = results_handler.get_public_queries()
            public_form_queries = results_handler.get_public_form_queries()

    except Exception as e:
        traceback.print_exc(file=sys.stdout)
        return jsonify({
            'startpoints': [],
            "publicQueries": [],
            "publicFormQueries": [],
            'error': True,
            'errorMessage': str(e)
        }), 500

    return jsonify({
        'startpoints': startpoints,
        "publicQueries": public_queries,
        "publicFormQueries": public_form_queries,
        'error': False,
        'errorMessage': ''
    })