2 Module : Gargantext.Database.Action.Node
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
11 {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
12 {-# OPTIONS_GHC -fno-warn-orphans #-}
14 {-# LANGUAGE Arrows #-}
15 {-# LANGUAGE ConstraintKinds #-}
16 {-# LANGUAGE FunctionalDependencies #-}
17 {-# LANGUAGE TemplateHaskell #-}
18 {-# LANGUAGE TypeFamilies #-}
20 module Gargantext.Database.Action.Node
25 import Gargantext.Core.Types (Name)
26 import Gargantext.Database.Admin.Types.Hyperdata
27 import Gargantext.Database.Admin.Types.Node
28 import Gargantext.Database.Query.Table.Node
29 import Gargantext.Database.Query.Table.Node.User
30 import Gargantext.Database.Query.Table.Node.Error
31 import Gargantext.Database.Prelude (Cmd)
33 ------------------------------------------------------------------------
34 -- | TODO mk all others nodes
35 mkNodeWithParent :: HasNodeError err
41 mkNodeWithParent NodeUser (Just _) _ _ = nodeError UserNoParent
43 ------------------------------------------------------------------------
44 mkNodeWithParent NodeUser Nothing uId name =
45 insertNodesWithParentR Nothing [node NodeUser name fake_HyperdataUser Nothing uId]
47 mkNodeWithParent _ Nothing _ _ = nodeError HasParent
48 ------------------------------------------------------------------------
49 mkNodeWithParent NodeFolder (Just i) uId name =
50 insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
54 mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
55 insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
59 mkNodeWithParent NodeFolderShared (Just i) uId _ =
60 insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
64 mkNodeWithParent NodeFolderPublic (Just i) uId _ =
65 insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
69 mkNodeWithParent NodeTeam (Just i) uId name =
70 insertNodesWithParentR (Just i) [node NodeTeam name hd Nothing uId]
73 ------------------------------------------------------------------------
74 mkNodeWithParent NodeCorpus (Just i) uId name =
75 insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
79 mkNodeWithParent NodeAnnuaire (Just i) uId name =
80 insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
84 mkNodeWithParent NodeList (Just i) uId name =
85 insertNodesWithParentR (Just i) [node NodeList name hd Nothing uId]
89 mkNodeWithParent NodeGraph (Just i) uId _name =
90 insertNodesWithParentR (Just i) [node NodeGraph "Graph" hd Nothing uId]
94 mkNodeWithParent _ _ _ _ = nodeError NotImplYet