]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Action/Node.hs
Merge branch 'dev' into dev-list-charts
[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 Protolude
24
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)
32
33 ------------------------------------------------------------------------
34 -- | TODO mk all others nodes
35 mkNodeWithParent :: HasNodeError err
36 => NodeType
37 -> Maybe ParentId
38 -> UserId
39 -> Name
40 -> Cmd err [NodeId]
41 mkNodeWithParent NodeUser (Just _) _ _ = nodeError UserNoParent
42
43 ------------------------------------------------------------------------
44 mkNodeWithParent NodeUser Nothing uId name =
45 insertNodesWithParentR Nothing [node NodeUser name fake_HyperdataUser Nothing uId]
46
47 mkNodeWithParent _ Nothing _ _ = nodeError HasParent
48 ------------------------------------------------------------------------
49 mkNodeWithParent NodeFolder (Just i) uId name =
50 insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
51 where
52 hd = defaultFolder
53
54 mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
55 insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
56 where
57 hd = defaultFolder
58
59 mkNodeWithParent NodeFolderShared (Just i) uId _ =
60 insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
61 where
62 hd = defaultFolder
63
64 mkNodeWithParent NodeFolderPublic (Just i) uId _ =
65 insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
66 where
67 hd = defaultFolder
68
69 mkNodeWithParent NodeTeam (Just i) uId name =
70 insertNodesWithParentR (Just i) [node NodeTeam name hd Nothing uId]
71 where
72 hd = defaultFolder
73 ------------------------------------------------------------------------
74 mkNodeWithParent NodeCorpus (Just i) uId name =
75 insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
76 where
77 hd = defaultCorpus
78
79 mkNodeWithParent NodeAnnuaire (Just i) uId name =
80 insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
81 where
82 hd = defaultAnnuaire
83
84 mkNodeWithParent NodeList (Just i) uId name =
85 insertNodesWithParentR (Just i) [node NodeList name hd Nothing uId]
86 where
87 hd = defaultAnnuaire
88
89 mkNodeWithParent NodeGraph (Just i) uId _name =
90 insertNodesWithParentR (Just i) [node NodeGraph "Graph" hd Nothing uId]
91 where
92 hd = arbitraryGraph
93
94 mkNodeWithParent _ _ _ _ = nodeError NotImplYet
95