Beispiel #1
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

    view_params['scene'] = Markup(ro.value)

    return view_params
Beispiel #2
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

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

    prov_def = ro.repr_json(full=True)
    data = {}
    workflow = ROWorkflow.get(session, prov_def['workflow'])
    if workflow is not None:
        store = {}
        workflow_def = workflow.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
            else:
                store[nid] = wnode.repr_json(full=True)
                store[nid]['url'] = request.route_url('ro_view_home', uid=nid)

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

        prov = prov_def
        fmt_data = {}
        for data_obj in prov['data']:
            dtype = data_obj['type']
            if dtype == "ref":  # internally used to reference another RO
                url = request.route_url('ro_view_home', uid=data_obj["value"])
                val = '<p><a href="%s">link to RO</a></p>' % url
            elif dtype == "int":
                val = "<p>%d</p>" % data_obj["value"]
            elif dtype == "str":
                val = "<p>%s</p>" % data_obj["value"]
            elif dtype == "url":
                val = "<p>%s</p>" % data_obj["value"]
            elif dtype in ("image", "IImage"):
                img_data = data_obj["value"].replace("\n", "")
                val = '<img src="data:image/png;base64,%s" />' % img_data
            else:
                val = "<p>%s</p>" % json.dumps(data_obj["value"])
            fmt_data[data_obj['id']] = (dtype, val)

        for pexec in prov['executions']:
            nid = pexec['node']
            for port in pexec['inputs']:
                if port['data'] is not None:
                    key = "wkf_node_%d_input_%s" % (nid, port['port'])
                    data[key] = fmt_data[port['data']]

            for port in pexec['outputs']:
                if port['data'] is not None:
                    key = "wkf_node_%d_output_%s" % (nid, port['port'])
                    data[key] = fmt_data[port['data']]

    view_params['wkf_data'] = data

    return view_params
Beispiel #3
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

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

    view_params['value'] = json.loads(ro.value)

    return view_params
Beispiel #4
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

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

    citations = [link.source for link in ro.in_links if link.type == "use"]
    view_params['citations'] = citations

    return view_params
Beispiel #5
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

    view_params['description'] = Markup(ro.html_description())
    ancestors = []
    for link in ro.in_links:
        if link.type == 'is_ancestor_of':
            ancestors.append(ResearchObject.get(session, link.source))

    view_params['ancestors'] = ancestors

    return view_params
Beispiel #6
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

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

    value = ""
    for i in range(10):
        value += ro.value[(i * 50):((i + 1) * 50)]
        value += "\n"

    if len(ro.value) > 500:
        value += "\n ..."

    view_params['value'] = value

    return view_params
Beispiel #7
0
def view(request):
    session = DBSession()
    ro, view_params = view_init_min(request, session)

    if view_params["allow_edit"] and ('new_content' in request.params or request.params.get("ro_id", "") != ""):
        if append_ro(request, session, ro) is not None:
            loc = request.current_route_url()
            return HTTPFound(location=loc)

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

    content = []
    for link in ro.out_links:
        if link.type == "contains":
            ro = ResearchObject.get(session, link.target)
            content.append((ro.name.lower(), ro))

    content.sort()
    view_params['content'] = [ro for name, ro in content]

    return view_params
Beispiel #8
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
Beispiel #9
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