]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Config.hs
[API] Favorites + documents (toTrash) routes.
[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
18 module Gargantext.Database.Config
19 where
20
21
22 import Data.Text (pack)
23 import Data.Tuple.Extra (swap)
24 import Data.Maybe (fromMaybe)
25 import Data.List (lookup)
26
27 import Gargantext.Database.Types.Node
28 import Gargantext.Prelude
29
30 nodeTypeId :: NodeType -> NodeTypeId
31 nodeTypeId n =
32 case n of
33 NodeUser -> 1
34 NodeFolder -> 2
35 NodeCorpusV3 -> 3
36 NodeCorpus -> 30
37 NodeAnnuaire -> 31
38 NodeDocument -> 4
39 NodeContact -> 41
40 --NodeSwap -> 19
41
42 ---- Lists
43 -- StopList -> 5
44 -- GroupList -> 6
45 -- MainList -> 7
46 -- MapList -> 8
47
48 ---- Scores
49 -- NodeOccurrences -> 10
50 NodeGraph -> 9
51 NodeDashboard -> 5
52 NodeChart -> 51
53
54 -- Cooccurrences -> 9
55 --
56 -- Specclusion -> 11
57 -- Genclusion -> 18
58 -- Cvalue -> 12
59 --
60 -- TfidfCorpus -> 13
61 -- TfidfGlobal -> 14
62 --
63 -- TirankLocal -> 16
64 -- TirankGlobal -> 17
65
66 -- Node management
67 -- NodeFavorites -> 15
68
69
70 --
71 -- | Nodes are typed in the database according to a specific ID
72 --
73 nodeTypeInv :: [(NodeTypeId, NodeType)]
74 nodeTypeInv = map swap nodeTypes
75
76 nodeTypes :: [(NodeType, NodeTypeId)]
77 nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
78
79 typeId2node :: NodeTypeId -> NodeType
80 typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
81 (lookup tId nodeTypeInv)