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
23 import Gargantext.Core.Types (Name)
24 import Gargantext.Database.Query.Table.Node
25 import Gargantext.Database.Query.Table.Node.User
26 import Gargantext.Database.Query.Table.Node.Error
27 import Gargantext.Database.Admin.Types.Node
28 import Gargantext.Database.Prelude (Cmd)
29 import Prelude hiding (null, id, map, sum)
31 ------------------------------------------------------------------------
32 -- | TODO mk all others nodes
33 mkNodeWithParent :: HasNodeError err
39 mkNodeWithParent NodeUser (Just _) _ _ = nodeError UserNoParent
41 ------------------------------------------------------------------------
42 mkNodeWithParent NodeUser Nothing uId name =
43 insertNodesWithParentR Nothing [node NodeUser name fake_HyperdataUser Nothing uId]
45 mkNodeWithParent _ Nothing _ _ = nodeError HasParent
46 ------------------------------------------------------------------------
47 mkNodeWithParent NodeFolder (Just i) uId name =
48 insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
52 mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
53 insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
57 mkNodeWithParent NodeFolderShared (Just i) uId _ =
58 insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
62 mkNodeWithParent NodeFolderPublic (Just i) uId _ =
63 insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
67 mkNodeWithParent NodeTeam (Just i) uId name =
68 insertNodesWithParentR (Just i) [node NodeTeam name hd Nothing uId]
71 ------------------------------------------------------------------------
72 mkNodeWithParent NodeCorpus (Just i) uId name =
73 insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
77 mkNodeWithParent NodeAnnuaire (Just i) uId name =
78 insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
82 mkNodeWithParent NodeList (Just i) uId name =
83 insertNodesWithParentR (Just i) [node NodeList name hd Nothing uId]
87 mkNodeWithParent NodeGraph (Just i) uId _name =
88 insertNodesWithParentR (Just i) [node NodeGraph "Graph" hd Nothing uId]
92 mkNodeWithParent _ _ _ _ = nodeError NotImplYet