2 Module : Gargantext.Database.Action.Node
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.Node
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)
40 ------------------------------------------------------------------------
41 -- | TODO mk all others nodes
42 mkNodeWithParent :: HasNodeError err
48 mkNodeWithParent NodeUser (Just _) _ _ = nodeError UserNoParent
50 ------------------------------------------------------------------------
51 mkNodeWithParent NodeUser Nothing uId name =
52 insertNodesWithParentR Nothing [node NodeUser name fake_HyperdataUser Nothing uId]
54 mkNodeWithParent _ Nothing _ _ = nodeError HasParent
55 ------------------------------------------------------------------------
56 mkNodeWithParent NodeFolder (Just i) uId name =
57 insertNodesWithParentR (Just i) [node NodeFolder name hd Nothing uId]
61 mkNodeWithParent NodeFolderPrivate (Just i) uId _ =
62 insertNodesWithParentR (Just i) [node NodeFolderPrivate "Private" hd Nothing uId]
66 mkNodeWithParent NodeFolderShared (Just i) uId _ =
67 insertNodesWithParentR (Just i) [node NodeFolderShared "Shared" hd Nothing uId]
71 mkNodeWithParent NodeFolderPublic (Just i) uId _ =
72 insertNodesWithParentR (Just i) [node NodeFolderPublic "Public" hd Nothing uId]
76 mkNodeWithParent NodeTeam (Just i) uId name =
77 insertNodesWithParentR (Just i) [node NodeTeam name hd Nothing uId]
80 ------------------------------------------------------------------------
81 mkNodeWithParent NodeCorpus (Just i) uId name =
82 insertNodesWithParentR (Just i) [node NodeCorpus name hd Nothing uId]
86 mkNodeWithParent NodeAnnuaire (Just i) uId name =
87 insertNodesWithParentR (Just i) [node NodeAnnuaire name hd Nothing uId]
91 mkNodeWithParent NodeList (Just i) uId name =
92 insertNodesWithParentR (Just i) [node NodeList name hd Nothing uId]
96 mkNodeWithParent NodeGraph (Just i) uId _name =
97 insertNodesWithParentR (Just i) [node NodeGraph "Graph" hd Nothing uId]
101 mkNodeWithParent _ _ _ _ = nodeError NotImplYet