2 Module : Gargantext.Database.Action.Query
3 Description : Main Tools of Node to the database
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 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 #-}
27 module Gargantext.Database.Action.Query
30 import Gargantext.Core.Types (Name)
31 import Gargantext.Database.Action.Query.Node
32 import Gargantext.Database.Action.Query.Node.User
33 import Gargantext.Database.Admin.Types.Errors
34 import Gargantext.Database.Admin.Types.Node
35 import Gargantext.Database.Admin.Utils (Cmd)
36 import Prelude hiding (null, id, map, sum)
38 ------------------------------------------------------------------------
39 -- | TODO mk all others nodes
40 mkNodeWithParent :: HasNodeError err
46 mkNodeWithParent NodeUser (Just _) _ _ = nodeError UserNoParent
48 ------------------------------------------------------------------------
49 mkNodeWithParent NodeUser Nothing uId name =
50 insertNodesWithParentR Nothing [node NodeUser name fake_HyperdataUser Nothing uId]
52 mkNodeWithParent _ Nothing _ _ = nodeError HasParent
53 ------------------------------------------------------------------------
54 mkNodeWithParent NodeFolder (Just i) uId name =
55 insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
59 mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
60 insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
64 mkNodeWithParent NodeFolderShared (Just i) uId _ =
65 insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
69 mkNodeWithParent NodeFolderPublic (Just i) uId _ =
70 insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
74 mkNodeWithParent NodeTeam (Just i) uId _ =
75 insertNodesWithParentR (Just i) [node NodeTeam "Team" hd Nothing uId]
78 ------------------------------------------------------------------------
79 mkNodeWithParent NodeCorpus (Just i) uId name =
80 insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
84 mkNodeWithParent NodeAnnuaire (Just i) uId name =
85 insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
89 mkNodeWithParent _ _ _ _ = nodeError NotImplYet