]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Config.hs
[API][DB] Tree NodeTree: done.
[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 -- | Nodes are typed in the database according to a specific ID
32 --
33 nodeTypeInv :: [(NodeTypeId, NodeType)]
34 nodeTypeInv = map swap nodeTypes
35
36 nodeTypes :: [(NodeType, NodeTypeId)]
37 nodeTypes = [ (NodeUser , 1)
38 , (Folder , 2)
39 , (NodeCorpus , 3)
40 , (NodeCorpus , 30)
41 , (Annuaire , 31)
42 , (Document , 4)
43 , (UserPage , 41)
44 --, (NodeSwap , 19)
45 ------ Lists
46 -- , (StopList , 5)
47 -- , (GroupList , 6)
48 -- , (MainList , 7)
49 -- , (MapList ,  8)
50 ---- Scores
51 , (Occurrences , 10)
52 -- , (Cooccurrences , 9)
53 --
54 -- , (Specclusion , 11)
55 -- , (Genclusion , 18)
56 -- , (Cvalue , 12)
57 --
58 -- , (TfidfCorpus , 13)
59 -- , (TfidfGlobal , 14)
60 --
61 -- , (TirankLocal , 16)
62 -- , (TirankGlobal , 17)
63 --
64 ---- Node management
65 , (Favorites , 15)
66 --
67 ]
68 --
69 nodeTypeId :: NodeType -> NodeTypeId
70 nodeTypeId tn = fromMaybe (panic $ pack $ "Typename " <> show tn <> " does not exist")
71 (lookup tn nodeTypes)
72
73
74 typeId2node :: NodeTypeId -> NodeType
75 typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
76 (lookup tId nodeTypeInv)