Example #1
0
def collection_index(collection):
    collection = get_collection(collection, authz.READ)
    results = collection_entities(collection, depth=get_depth(2),
                                  filter_schema=request.args.get('$schema'))
    return jsonify({
        'results': results
    })
Example #2
0
def collection_graph(collection):
    collection = get_collection(collection, authz.READ)
    network = Network(get_loom_config().resolver)
    schema = request.args.get('$schema')
    for entity in collection_entities(collection, depth=get_depth(3),
                                      filter_schema=schema):
        network.add(entity)
    return jsonify(network)
Example #3
0
def collection_graph(collection):
    collection = get_collection(collection, authz.READ)
    network = Network(get_loom_config().resolver)
    schema = request.args.get('$schema')
    for entity in collection_entities(collection,
                                      depth=get_depth(3),
                                      filter_schema=schema):
        network.add(entity)
    return jsonify(network)
Example #4
0
def collection_csv(collection):
    collection = get_collection(collection, authz.READ)
    schema = request.args.get('$schema')
    if schema is None:
        raise BadRequest()
    results = collection_entities(collection, depth=get_depth(2),
                                  filter_schema=schema)
    visitor, table = entities_to_table(schema, results)
    basename = '%s - %s' % (collection.title, visitor.plural)
    return make_csv_response(table, basename)
Example #5
0
def collection_csv(collection):
    collection = get_collection(collection, authz.READ)
    schema = request.args.get('$schema')
    if schema is None:
        raise BadRequest()
    results = collection_entities(collection,
                                  depth=get_depth(2),
                                  filter_schema=schema)
    visitor, table = entities_to_table(schema, results)
    basename = '%s - %s' % (collection.title, visitor.plural)
    return make_csv_response(table, basename)
Example #6
0
def collection_xlsx(collection):
    collection = get_collection(collection, authz.READ)
    results = collection_entities(collection, depth=get_depth(2),
                                  filter_schema=request.args.get('$schema'))
    by_schema = OrderedDict()
    for result in results:
        by_schema.setdefault(result.get('$schema'), [])
        by_schema[result.get('$schema')].append(result)
    sheets = OrderedDict()
    for schema, schema_results in by_schema.items():
        schema_results = list(schema_results)
        visitor, table = entities_to_table(schema, schema_results)
        sheets[visitor.plural] = table

    if '$schema' in request.args and len(sheets):
        basename = '%s - %s' % (collection.title, sheets.keys()[0])
    else:
        basename = collection.title
    return make_xlsx_response(sheets, basename)
Example #7
0
def collection_xlsx(collection):
    collection = get_collection(collection, authz.READ)
    results = collection_entities(collection,
                                  depth=get_depth(2),
                                  filter_schema=request.args.get('$schema'))
    by_schema = OrderedDict()
    for result in results:
        by_schema.setdefault(result.get('$schema'), [])
        by_schema[result.get('$schema')].append(result)
    sheets = OrderedDict()
    for schema, schema_results in by_schema.items():
        schema_results = list(schema_results)
        visitor, table = entities_to_table(schema, schema_results)
        sheets[visitor.plural] = table

    if '$schema' in request.args and len(sheets):
        basename = '%s - %s' % (collection.title, sheets.keys()[0])
    else:
        basename = collection.title
    return make_xlsx_response(sheets, basename)
Example #8
0
def collection_index(collection):
    collection = get_collection(collection, authz.READ)
    results = collection_entities(collection,
                                  depth=get_depth(2),
                                  filter_schema=request.args.get('$schema'))
    return jsonify({'results': results})