Stability : experimental
Portability : POSIX
-All Database related stuff here.
-
Target: just import this module and nothing else to work with
Gargantext's database.
+TODO: configure nodes table in Haskell (Config typenames etc.)
-}
{-# LANGUAGE NoImplicitPrelude #-}
+{-# LANGUAGE OverloadedStrings #-}
module Gargantext.Database.Config
where
-import Data.Text (pack)
+import Data.Text (Text,pack)
import Data.Tuple.Extra (swap)
import Data.Maybe (fromMaybe)
import Data.List (lookup)
import Gargantext.Database.Types.Node
import Gargantext.Prelude
--- | Nodes are typed in the database according to a specific ID
---
-nodeTypeInv :: [(NodeTypeId, NodeType)]
-nodeTypeInv = map swap nodeTypes
+-- TODO put this in config.ini file
+corpusMasterName :: Text
+corpusMasterName = "Main"
+
+userMaster :: Text
+userMaster = "gargantua"
+
+userArbitrary :: Text
+userArbitrary = "user1"
+
+nodeTypeId :: NodeType -> NodeTypeId
+nodeTypeId n =
+ case n of
+ NodeUser -> 1
+ NodeFolder -> 2
+ NodeFolderPrivate -> 20
+ NodeFolderShared -> 21
+ NodeTeam -> 210
+ NodeFolderPublic -> 22
+ NodeCorpusV3 -> 3
+ NodeCorpus -> 30
+ NodeAnnuaire -> 31
+ NodeTexts -> 40
+ NodeDocument -> 4
+ NodeContact -> 41
+ --NodeSwap -> 19
+
+---- Lists
+ NodeList -> 5
+ NodeListCooc -> 50
+ NodeListModel -> 52
-nodeTypes :: [(NodeType, NodeTypeId)]
-nodeTypes = [ (NodeUser , 1)
- , (Folder , 2)
- , (NodeCorpus , 3)
- , (NodeCorpus , 30)
- , (Annuaire , 31)
- , (Document , 4)
- , (UserPage , 41)
- --, (NodeSwap , 19)
------- Lists
--- , (StopList , 5)
--- , (GroupList , 6)
--- , (MainList , 7)
--- , (MapList , 8)
---- Scores
- , (Occurrences , 10)
--- , (Cooccurrences , 9)
---
--- , (Specclusion , 11)
--- , (Genclusion , 18)
--- , (Cvalue , 12)
+-- NodeOccurrences -> 10
+ NodeGraph -> 9
+ NodePhylo -> 90
+ NodeChart -> 7
+ NodeDashboard -> 71
+ NodeNoteBook -> 88
+
+-- Cooccurrences -> 9
--
--- , (TfidfCorpus , 13)
--- , (TfidfGlobal , 14)
+-- Specclusion -> 11
+-- Genclusion -> 18
+-- Cvalue -> 12
--
--- , (TirankLocal , 16)
--- , (TirankGlobal , 17)
+-- TfidfCorpus -> 13
+-- TfidfGlobal -> 14
--
----- Node management
- , (Favorites , 15)
+-- TirankLocal -> 16
+-- TirankGlobal -> 17
+
+-- Node management
+-- NodeFavorites -> 15
+
+
--
- ]
+-- | Nodes are typed in the database according to a specific ID
--
-nodeTypeId :: NodeType -> NodeTypeId
-nodeTypeId tn = fromMaybe (panic $ pack $ "Typename " <> show tn <> " does not exist")
- (lookup tn nodeTypes)
+nodeTypeInv :: [(NodeTypeId, NodeType)]
+nodeTypeInv = map swap nodeTypes
+
+nodeTypes :: [(NodeType, NodeTypeId)]
+nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
+fromNodeTypeId :: NodeTypeId -> NodeType
+fromNodeTypeId tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
+ (lookup tId nodeTypeInv)
-typeId2node :: NodeTypeId -> NodeType
-typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
- (lookup tId nodeTypeInv)