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.Action.Query.User
34 import Gargantext.Database.Admin.Types.Errors
35 import Gargantext.Database.Admin.Types.Node
36 import Gargantext.Database.Admin.Utils (Cmd)
37 import Gargantext.Database.Schema.Node
38 import Opaleye hiding (FromField)
39 import Prelude hiding (null, id, map, sum)
41 ------------------------------------------------------------------------
42 -- | TODO mk all others nodes
43 mkNodeWithParent :: HasNodeError err
49 mkNodeWithParent NodeUser (Just _) _ _ = nodeError UserNoParent
51 ------------------------------------------------------------------------
52 mkNodeWithParent NodeUser Nothing uId name =
53 insertNodesWithParentR Nothing [node NodeUser name fake_HyperdataUser Nothing uId]
55 mkNodeWithParent _ Nothing _ _ = nodeError HasParent
56 ------------------------------------------------------------------------
57 mkNodeWithParent NodeFolder (Just i) uId name =
58 insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
62 mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
63 insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
67 mkNodeWithParent NodeFolderShared (Just i) uId _ =
68 insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
72 mkNodeWithParent NodeFolderPublic (Just i) uId _ =
73 insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
77 mkNodeWithParent NodeTeam (Just i) uId _ =
78 insertNodesWithParentR (Just i) [node NodeTeam "Team" hd Nothing uId]
81 ------------------------------------------------------------------------
82 mkNodeWithParent NodeCorpus (Just i) uId name =
83 insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
87 mkNodeWithParent NodeAnnuaire (Just i) uId name =
88 insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
92 mkNodeWithParent _ _ _ _ = nodeError NotImplYet