Esempio n. 1
0
def to_rest_index(schema):
    data = to_basic(schema)
    data['obj'] = schema.obj
    data['project'] = projects_logic.to_rest_index(schema.project)
    data['api_url'] = url_for('schemata_api.view',
                              slug=schema.project.slug,
                              name=schema.name)
    return data
Esempio n. 2
0
def to_rest_index(permission):
    return {
        "id": permission.id,
        "reader": permission.reader,
        "editor": permission.editor,
        "admin": permission.admin,
        "project": projects_logic.to_rest_index(permission.project),
        "account": accounts_logic.to_rest_index(permission.account),
        "api_url": url_for("permissions_api.view", slug=permission.project.slug, id=permission.id),
    }
Esempio n. 3
0
def to_rest_base(entity):
    data = {
        'id': entity.id,
        'project': projects_logic.to_rest_index(entity.project),
        'api_url': url_for('entities_api.view', id=entity.id),
        'same_as': entity.same_as
    }
    if entity.same_as:
        data['same_as_url'] = url_for('entities_api.view', id=entity.same_as)
    return data
Esempio n. 4
0
def to_rest_base(relation):
    from grano.logic import entities as entities_logic
    return {
        'id': relation.id,
        'properties': {},
        'project': projects_logic.to_rest_index(relation.project),
        'api_url': url_for('relations_api.view', id=relation.id),
        'schema': schemata_logic.to_rest_index(relation.schema),
        'source': entities_logic.to_rest_index(relation.source),
        'target': entities_logic.to_rest_index(relation.target)
    }
Esempio n. 5
0
def to_rest_base(relation):
    from grano.logic import entities as entities_logic
    return {
        'id': relation.id,
        'properties': {},
        'project': projects_logic.to_rest_index(relation.project),
        'api_url': url_for('relations_api.view', id=relation.id),
        'schema': schemata_logic.to_rest_index(relation.schema),
        'source': entities_logic.to_rest_index(relation.source),
        'target': entities_logic.to_rest_index(relation.target)
    }
Esempio n. 6
0
def to_rest_base(relation):
    from grano.logic import entities as entities_logic

    return {
        "id": relation.id,
        "properties": {},
        "project": projects_logic.to_rest_index(relation.project),
        "api_url": url_for("relations_api.view", id=relation.id),
        "schema": schemata_logic.to_rest_index(relation.schema),
        "source": entities_logic.to_rest_index(relation.source),
        "target": entities_logic.to_rest_index(relation.target),
    }
Esempio n. 7
0
def to_index(relation):
    """ Convert a relation into a form appropriate for indexing within an 
    entity (ie. do not include entity data). """

    data = {
        'id': relation.id,
        'project': projects_logic.to_rest_index(relation.project),
        'source': relation.source_id,
        'target': relation.target_id,
        'schema': schemata_logic.to_index(relation.schema),
    }

    for prop in relation.active_properties:
        data[prop.name] = prop.value

    return data
Esempio n. 8
0
def to_index(relation):
    """ Convert a relation into a form appropriate for indexing within an 
    entity (ie. do not include entity data). """

    data = {
        'id': relation.id,
        'project': projects_logic.to_rest_index(relation.project),
        'source': relation.source_id,
        'target': relation.target_id,
        'schema': schemata_logic.to_index(relation.schema),
    }

    for prop in relation.active_properties:
        data[prop.name] = prop.value

    return data
Esempio n. 9
0
def to_index(entity):
    """ Convert an entity to a form appropriate for search indexing. """

    schemata = list(entity.schemata)
    data = {
        'id':
        entity.id,
        'project':
        projects_logic.to_rest_index(entity.project),
        'schemata':
        [schemata_logic.to_index(s) for s in schemata if s.name != 'base'],
        'num_schemata':
        len(schemata),
        'num_properties':
        0,
        #    'inbound': [],
        #    'outbound': [],
        #    'relations': [],
        'names': []
    }

    #for rel in entity.inbound:
    #    rel_data = relations.to_index(rel)
    #    data['inbound'].append(rel_data)
    #    data['relations'].append(rel_data)

    #for rel in entity.outbound:
    #    rel_data = relations.to_index(rel)
    #    data['outbound'].append(rel_data)
    #    data['relations'].append(rel_data)

    data['num_relations'] = entity.degree

    for prop in entity.properties:
        if prop.name == 'name':
            data['names'].append(prop.value)
        if prop.active:
            data[prop.name] = prop.value
            data['num_properties'] += 1

    return data
Esempio n. 10
0
def to_index(entity):
    """ Convert an entity to a form appropriate for search indexing. """

    schemata = list(entity.schemata)
    data = {
        'id': entity.id,
        'project': projects_logic.to_rest_index(entity.project),
        'schemata': [schemata_logic.to_index(s) for s in schemata if s.name != 'base'],
        'num_schemata': len(schemata),
        'num_properties': 0,
    #    'inbound': [],
    #    'outbound': [],
    #    'relations': [],
        'names': []
        }

    #for rel in entity.inbound:
    #    rel_data = relations.to_index(rel)
    #    data['inbound'].append(rel_data)
    #    data['relations'].append(rel_data)

    #for rel in entity.outbound:
    #    rel_data = relations.to_index(rel)
    #    data['outbound'].append(rel_data)
    #    data['relations'].append(rel_data)

    data['num_relations'] = entity.degree

    for prop in entity.properties:
        if prop.name == 'name':
            data['names'].append(prop.value)
        if prop.active:
            data[prop.name] = prop.value
            data['num_properties'] += 1

    return data
Esempio n. 11
0
def to_rest_index(schema):
    data = to_basic(schema)
    data['obj'] = schema.obj
    data['project'] = projects_logic.to_rest_index(schema.project)
    data['api_url'] = url_for('schemata_api.view', slug=schema.project.slug, name=schema.name)
    return data
Esempio n. 12
0
def to_rest_base(entity):
    return {
        'id': entity.id,
        'project': projects_logic.to_rest_index(entity.project),
        'api_url': url_for('entities_api.view', id=entity.id)
    }
Esempio n. 13
0
def to_rest_base(entity):
    return {
        'id': entity.id,
        'project': projects_logic.to_rest_index(entity.project),
        'api_url': url_for('entities_api.view', id=entity.id)
    }