]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Config.hs
[TREE]Config fix NodeTypes id.
[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 NodeCorpus -> 30 -- TODO ERRR
38 Annuaire -> 31
39 Document -> 4
40 UserPage -> 41
41 --NodeSwap -> 19
42
43 ---- Lists
44 -- StopList -> 5
45 -- GroupList -> 6
46 -- MainList -> 7
47 -- MapList -> 8
48
49 ---- Scores
50 Occurrences -> 10
51 Graph -> 9
52 Dashboard -> 5
53 Chart -> 51
54
55 -- Cooccurrences -> 9
56 --
57 -- Specclusion -> 11
58 -- Genclusion -> 18
59 -- Cvalue -> 12
60 --
61 -- TfidfCorpus -> 13
62 -- TfidfGlobal -> 14
63 --
64 -- TirankLocal -> 16
65 -- TirankGlobal -> 17
66
67 ---- Node management
68 Favorites -> 15
69
70 -- Project -> TODO
71 -- Individu -> TODO
72 -- Classification -> TODO
73 -- Lists -> TODO
74 -- Metrics -> TODO
75
76 --
77 -- | Nodes are typed in the database according to a specific ID
78 --
79 nodeTypeInv :: [(NodeTypeId, NodeType)]
80 nodeTypeInv = map swap nodeTypes
81
82 nodeTypes :: [(NodeType, NodeTypeId)]
83 nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
84
85 typeId2node :: NodeTypeId -> NodeType
86 typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
87 (lookup tId nodeTypeInv)