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