shrub/pkg/arvo/ted/graph/create.hoon

62 lines
1.7 KiB
Plaintext
Raw Normal View History

2020-09-04 10:42:20 +03:00
/- spider, graph=graph-store, *metadata-store, *group, group-store
/+ strandio, resource, graph-view
2020-09-02 08:18:07 +03:00
=>
|%
++ strand strand:spider
++ poke poke:strandio
++ poke-our poke-our:strandio
2020-09-04 10:51:28 +03:00
::
2020-09-02 08:18:07 +03:00
++ handle-group
2020-09-04 10:42:20 +03:00
|= [rid=resource =associated:graph-view]
2020-09-02 08:18:07 +03:00
=/ m (strand ,resource)
2020-09-04 10:42:20 +03:00
?: ?=(%group -.associated)
(pure:m rid.associated)
2020-09-02 08:18:07 +03:00
=/ =action:group-store
2020-09-04 10:42:20 +03:00
[%add-group rid policy.associated %&]
2020-09-02 08:18:07 +03:00
;< ~ bind:m (poke-our %group-store %group-action !>(action))
;< ~ bind:m
(poke-our %group-push-hook %push-hook-action !>([%add rid]))
(pure:m rid)
--
2020-09-04 10:51:28 +03:00
::
2020-09-02 08:18:07 +03:00
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
=+ !<([=action:graph-view ~] arg)
2020-09-02 08:18:07 +03:00
?> ?=(%create -.action)
;< =bowl:spider bind:m get-bowl:strandio
:: Add graph to graph-store
::
2020-09-11 06:08:16 +03:00
?. =(our.bowl entity.rid.action)
(strand-fail:strandio %bad-request ~)
2020-09-02 08:18:07 +03:00
=/ =update:graph
2020-09-15 04:23:13 +03:00
[%0 now.bowl %add-graph rid.action *graph:graph mark.action]
2020-09-04 10:42:20 +03:00
;< ~ bind:m
(poke-our %graph-store graph-update+!>(update))
;< ~ bind:m
(poke-our %graph-push-hook %push-hook-action !>([%add rid.action]))
2020-09-02 08:18:07 +03:00
:: Add group, if graph is unmanaged
::
;< group=resource bind:m
(handle-group rid.action associated.action)
=/ group-path=path
(en-path:resource group)
:: Setup metadata
::
=/ =metadata
%* . *metadata
title title.action
description description.action
2020-09-02 08:18:07 +03:00
date-created now.bowl
creator our.bowl
module module.action
2020-09-02 08:18:07 +03:00
==
=/ act=metadata-action
[%add group-path graph+(en-path:resource rid.action) metadata]
2020-09-02 08:18:07 +03:00
;< ~ bind:m (poke-our %metadata-hook %metadata-action !>(act))
;< ~ bind:m
(poke-our %metadata-hook %metadata-hook-action !>([%add-owned group-path]))
(pure:m !>(~))