]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Config.hs
[DATE] parser -> UTCTime
[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 All Database related stuff here.
11
12 Target: just import this module and nothing else to work with
13 Gargantext's database.
14
15 -}
16
17 {-# LANGUAGE NoImplicitPrelude #-}
18
19 module Gargantext.Database.Config
20 where
21
22
23 import Data.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 nodeTypeId :: NodeType -> NodeTypeId
32 nodeTypeId n =
33 case n of
34 NodeUser -> 1
35 Folder -> 2
36 --NodeCorpus -> 3
37 NodeCorpusV3 -> 3
38 NodeCorpus -> 30
39 Annuaire -> 31
40 Document -> 4
41 UserPage -> 41
42 --NodeSwap -> 19
43
44 ---- Lists
45 -- StopList -> 5
46 -- GroupList -> 6
47 -- MainList -> 7
48 -- MapList -> 8
49
50 ---- Scores
51 Occurrences -> 10
52 Graph -> 9
53 Dashboard -> 5
54 Chart -> 51
55
56 -- Cooccurrences -> 9
57 --
58 -- Specclusion -> 11
59 -- Genclusion -> 18
60 -- Cvalue -> 12
61 --
62 -- TfidfCorpus -> 13
63 -- TfidfGlobal -> 14
64 --
65 -- TirankLocal -> 16
66 -- TirankGlobal -> 17
67
68 ---- Node management
69 Favorites -> 15
70
71 -- Project -> TODO
72 -- Individu -> TODO
73 -- Classification -> TODO
74 -- Lists -> TODO
75 -- Metrics -> TODO
76
77 --
78 -- | Nodes are typed in the database according to a specific ID
79 --
80 nodeTypeInv :: [(NodeTypeId, NodeType)]
81 nodeTypeInv = map swap nodeTypes
82
83 nodeTypes :: [(NodeType, NodeTypeId)]
84 nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
85
86 typeId2node :: NodeTypeId -> NodeType
87 typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
88 (lookup tId nodeTypeInv)