Esempio n. 1
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

    view_params['description'] = Markup(ro.html_description())

    store = {}
    node_def = ro.repr_json(full=True)
    for port in chain(node_def['inputs'], node_def['outputs']):
        iid = port['interface']
        iface = ROInterface.get(session, iid)
        if iface is None:
            pass
        else:
            store[iid] = iface.repr_json(full=True)
            store[iid]['url'] = request.route_url('ro_view_home', uid=iid)

    txt, viewbox = svg.export_node(node_def, store, (800, 300))
    view_params['svg_repr'] = txt
    view_params['svg_viewbox'] = json.dumps(viewbox)

    return view_params
Esempio n. 2
0
def data_type(session, interface):
    """Find a RO type that implements this interface
    or its closest ancestor.

    Notes: default to 'data'

    Args:
        session (Session): previously open session
        interface (str): uid of interface

    Returns:
        (str): name of RO type
    """
    front = [interface]
    while len(front) > 0:
        uid = front.pop(0)
        if uid in data_factory:
            return data_factory[uid]

        roi = ROInterface.get(session, uid)
        front.extend(roi.ancestors())

    return "data"
Esempio n. 3
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

    view_params['description'] = Markup(ro.html_description())

    store = {}
    workflow_def = ro.repr_json(full=True)
    for node_def in workflow_def['nodes']:
        nid = node_def['id']
        wnode = ROWorkflowNode.get(session, nid)
        if wnode is None:
            pass
        # elif wnode.category == "alias":
        #     wnode = resolve_target(session, wnode)
        #     store[nid] = wnode.load_definition()
        #     store[nid]['url'] = request.route_url('project_content_alias_view_item', pid=wnode.project, cid=nid)
        else:
            store[nid] = wnode.repr_json(full=True)
            store[nid]['url'] = request.route_url('ro_view_home', uid=nid)

    for nid, node in store.items():
        for port in node['inputs'] + node['outputs']:
            iid = port['interface']
            iface = ROInterface.get(session, iid)
            if iface is None:
                pass
            else:
                store[iid] = iface.repr_json(full=True)
                store[iid]['url'] = request.route_url('ro_view_home', uid=iid)

    txt, viewbox = svg.export_workflow(workflow_def, store, (800, 600))
    view_params['svg_repr'] = txt
    view_params['svg_viewbox'] = json.dumps(viewbox)

    return view_params