]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Config.hs
Merge branch 'dev-phylo' of ssh://gitlab.iscpif.fr:20022/gargantext/haskell-gargantex...
[gargantext.git] / src / Gargantext / Database / Config.hs
1 {-|
2 Module : Gargantext.Database
3 Description : Tools for Database
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 Target: just import this module and nothing else to work with
11 Gargantext's database.
12
13 TODO: configure nodes table in Haskell (Config typenames etc.)
14 -}
15
16 {-# LANGUAGE NoImplicitPrelude #-}
17 {-# LANGUAGE OverloadedStrings #-}
18
19 module Gargantext.Database.Config
20 where
21
22
23 import Data.Text (Text,pack)
24 import Data.Tuple.Extra (swap)
25 import Data.Maybe (fromMaybe)
26 import Data.List (lookup)
27
28 import Gargantext.Database.Types.Node
29 import Gargantext.Prelude
30
31 -- TODO put this in config.ini file
32 corpusMasterName :: Text
33 corpusMasterName = "Main"
34
35 userMaster :: Text
36 userMaster = "gargantua"
37
38 userArbitrary :: Text
39 userArbitrary = "user1"
40
41 nodeTypeId :: NodeType -> NodeTypeId
42 nodeTypeId n =
43 case n of
44 NodeUser -> 1
45 NodeFolder -> 2
46 NodeFolderPrivate -> 20
47 NodeFolderShared -> 21
48 NodeTeam -> 210
49 NodeFolderPublic -> 22
50 NodeCorpusV3 -> 3
51 NodeCorpus -> 30
52 NodeAnnuaire -> 31
53 NodeTexts -> 40
54 NodeDocument -> 4
55 NodeContact -> 41
56 --NodeSwap -> 19
57
58 ---- Lists
59 NodeList -> 5
60 NodeListCooc -> 50
61 NodeListModel -> 52
62
63 ---- Scores
64 -- NodeOccurrences -> 10
65 NodeGraph -> 9
66 NodePhylo -> 90
67 NodeChart -> 7
68 NodeDashboard -> 71
69 NodeNoteBook -> 88
70
71 -- Cooccurrences -> 9
72 --
73 -- Specclusion -> 11
74 -- Genclusion -> 18
75 -- Cvalue -> 12
76 --
77 -- TfidfCorpus -> 13
78 -- TfidfGlobal -> 14
79 --
80 -- TirankLocal -> 16
81 -- TirankGlobal -> 17
82
83 -- Node management
84 -- NodeFavorites -> 15
85
86
87 --
88 -- | Nodes are typed in the database according to a specific ID
89 --
90 nodeTypeInv :: [(NodeTypeId, NodeType)]
91 nodeTypeInv = map swap nodeTypes
92
93 nodeTypes :: [(NodeType, NodeTypeId)]
94 nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
95
96 fromNodeTypeId :: NodeTypeId -> NodeType
97 fromNodeTypeId tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
98 (lookup tId nodeTypeInv)
99