Config.hs 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
{-|
Module      : Gargantext.Database
Description : Tools for Database
Copyright   : (c) CNRS, 2017-Present
License     : AGPL + CECILL v3
Maintainer  : team@gargantext.org
Stability   : experimental
Portability : POSIX

Target: just import this module and nothing else to work with
Gargantext's database.

13
TODO: configure nodes table in Haskell (Config typenames etc.)
14 15 16
-}

{-# LANGUAGE NoImplicitPrelude #-}
17
{-# LANGUAGE OverloadedStrings #-}
18 19 20 21

module Gargantext.Database.Config
    where

22

23
import Data.Text        (Text,pack)
24 25 26
import Data.Tuple.Extra (swap)
import Data.Maybe       (fromMaybe)
import Data.List        (lookup)
27 28 29 30

import Gargantext.Database.Types.Node
import Gargantext.Prelude

31 32 33 34 35 36 37 38 39 40 41
-- TODO put this in config.ini file
corpusMasterName :: Text
corpusMasterName = "Main"

userMaster :: Text
userMaster = "gargantua"

userArbitrary :: Text
userArbitrary = "user1"


42 43 44
nodeTypeId :: NodeType -> NodeTypeId
nodeTypeId n =
  case n of
45 46 47 48 49 50 51
    NodeUser      -> 1
    NodeFolder    -> 2
    NodeCorpusV3  -> 3
    NodeCorpus    -> 30
    NodeAnnuaire  -> 31
    NodeDocument  -> 4
    NodeContact   -> 41
52 53 54
  --NodeSwap   -> 19

----  Lists
55
    NodeList    -> 5
56

57
----  Scores
58
--    NodeOccurrences -> 10
59
    NodeGraph       -> 9
60
    NodeDashboard   -> 7
61
    NodeChart       -> 51
62 63

--  Cooccurrences -> 9
64
--
65 66 67
--  Specclusion  -> 11
--  Genclusion   -> 18
--  Cvalue       -> 12
68
--
69 70
--  TfidfCorpus  -> 13
--  TfidfGlobal  -> 14
71
--
72 73 74
--  TirankLocal  -> 16
--  TirankGlobal -> 17

75 76
--  Node management
--  NodeFavorites    -> 15
77 78


79
--
80
-- | Nodes are typed in the database according to a specific ID
81
--
82 83
nodeTypeInv :: [(NodeTypeId, NodeType)]
nodeTypeInv = map swap nodeTypes
84

85 86
nodeTypes :: [(NodeType, NodeTypeId)]
nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
87

88 89
fromNodeTypeId :: NodeTypeId -> NodeType
fromNodeTypeId tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
90
                            (lookup tId nodeTypeInv)