]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Action/Node.hs
Merge branch 'dev-default-extensions' into dev
[gargantext.git] / src / Gargantext / Database / Action / Node.hs
1 {-|
2 Module : Gargantext.Database.Action.Node
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9 -}
10
11 {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
12 {-# OPTIONS_GHC -fno-warn-orphans #-}
13
14 {-# LANGUAGE Arrows #-}
15 {-# LANGUAGE ConstraintKinds #-}
16 {-# LANGUAGE FunctionalDependencies #-}
17 {-# LANGUAGE TemplateHaskell #-}
18 {-# LANGUAGE TypeFamilies #-}
19
20 module Gargantext.Database.Action.Node
21 where
22
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)
30
31 ------------------------------------------------------------------------
32 -- | TODO mk all others nodes
33 mkNodeWithParent :: HasNodeError err
34 => NodeType
35 -> Maybe ParentId
36 -> UserId
37 -> Name
38 -> Cmd err [NodeId]
39 mkNodeWithParent NodeUser (Just _) _ _ = nodeError UserNoParent
40
41 ------------------------------------------------------------------------
42 mkNodeWithParent NodeUser Nothing uId name =
43 insertNodesWithParentR Nothing [node NodeUser name fake_HyperdataUser Nothing uId]
44
45 mkNodeWithParent _ Nothing _ _ = nodeError HasParent
46 ------------------------------------------------------------------------
47 mkNodeWithParent NodeFolder (Just i) uId name =
48 insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
49 where
50 hd = defaultFolder
51
52 mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
53 insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
54 where
55 hd = defaultFolder
56
57 mkNodeWithParent NodeFolderShared (Just i) uId _ =
58 insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
59 where
60 hd = defaultFolder
61
62 mkNodeWithParent NodeFolderPublic (Just i) uId _ =
63 insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
64 where
65 hd = defaultFolder
66
67 mkNodeWithParent NodeTeam (Just i) uId name =
68 insertNodesWithParentR (Just i) [node NodeTeam name hd Nothing uId]
69 where
70 hd = defaultFolder
71 ------------------------------------------------------------------------
72 mkNodeWithParent NodeCorpus (Just i) uId name =
73 insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
74 where
75 hd = defaultCorpus
76
77 mkNodeWithParent NodeAnnuaire (Just i) uId name =
78 insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
79 where
80 hd = defaultAnnuaire
81
82 mkNodeWithParent NodeList (Just i) uId name =
83 insertNodesWithParentR (Just i) [node NodeList name hd Nothing uId]
84 where
85 hd = defaultAnnuaire
86
87 mkNodeWithParent NodeGraph (Just i) uId _name =
88 insertNodesWithParentR (Just i) [node NodeGraph "Graph" hd Nothing uId]
89 where
90 hd = arbitraryGraph
91
92 mkNodeWithParent _ _ _ _ = nodeError NotImplYet
93