]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Action/Node.hs
[OPTIM] after profiling, optimize serialisation
[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 DeriveGeneric #-}
16 {-# LANGUAGE ConstraintKinds #-}
17 {-# LANGUAGE FlexibleContexts #-}
18 {-# LANGUAGE FlexibleInstances #-}
19 {-# LANGUAGE FunctionalDependencies #-}
20 {-# LANGUAGE OverloadedStrings #-}
21 {-# LANGUAGE MultiParamTypeClasses #-}
22 {-# LANGUAGE NoImplicitPrelude #-}
23 {-# LANGUAGE RankNTypes #-}
24 {-# LANGUAGE TemplateHaskell #-}
25 {-# LANGUAGE TypeFamilies #-}
26
27 module Gargantext.Database.Action.Node
28 where
29
30 import Gargantext.Core.Types (Name)
31 import Gargantext.Database.Query.Table.Node
32 import Gargantext.Database.Query.Table.Node.User
33 import Gargantext.Database.Query.Table.Node.Error
34 import Gargantext.Database.Admin.Types.Node
35 import Gargantext.Database.Prelude (Cmd)
36 import Prelude hiding (null, id, map, sum)
37
38 ------------------------------------------------------------------------
39 -- | TODO mk all others nodes
40 mkNodeWithParent :: HasNodeError err
41 => NodeType
42 -> Maybe ParentId
43 -> UserId
44 -> Name
45 -> Cmd err [NodeId]
46 mkNodeWithParent NodeUser (Just _) _ _ = nodeError UserNoParent
47
48 ------------------------------------------------------------------------
49 mkNodeWithParent NodeUser Nothing uId name =
50 insertNodesWithParentR Nothing [node NodeUser name fake_HyperdataUser Nothing uId]
51
52 mkNodeWithParent _ Nothing _ _ = nodeError HasParent
53 ------------------------------------------------------------------------
54 mkNodeWithParent NodeFolder (Just i) uId name =
55 insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
56 where
57 hd = defaultFolder
58
59 mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
60 insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
61 where
62 hd = defaultFolder
63
64 mkNodeWithParent NodeFolderShared (Just i) uId _ =
65 insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
66 where
67 hd = defaultFolder
68
69 mkNodeWithParent NodeFolderPublic (Just i) uId _ =
70 insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
71 where
72 hd = defaultFolder
73
74 mkNodeWithParent NodeTeam (Just i) uId name =
75 insertNodesWithParentR (Just i) [node NodeTeam name hd Nothing uId]
76 where
77 hd = defaultFolder
78 ------------------------------------------------------------------------
79 mkNodeWithParent NodeCorpus (Just i) uId name =
80 insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
81 where
82 hd = defaultCorpus
83
84 mkNodeWithParent NodeAnnuaire (Just i) uId name =
85 insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
86 where
87 hd = defaultAnnuaire
88
89 mkNodeWithParent NodeList (Just i) uId name =
90 insertNodesWithParentR (Just i) [node NodeList name hd Nothing uId]
91 where
92 hd = defaultAnnuaire
93
94 mkNodeWithParent NodeGraph (Just i) uId _name =
95 insertNodesWithParentR (Just i) [node NodeGraph "Graph" hd Nothing uId]
96 where
97 hd = arbitraryGraph
98
99 mkNodeWithParent _ _ _ _ = nodeError NotImplYet
100