]> Git — Sourcephile - gargantext.git/blob - src/Data/Gargantext/Types/Main.hs
removed warnings and upgraded to lts-9.2
[gargantext.git] / src / Data / Gargantext / Types / Main.hs
1 -- | CNRS Copyrights
2 -- Licence: https://gitlab.iscpif.fr/humanities/gargantext/blob/stable/LICENSE
3 -- Author: Alexandre Delanoë (alexandre.delanoe@iscpif.fr)
4
5 module Data.Gargantext.Types.Main where
6
7 import Protolude (fromMaybe)
8 import Data.Text (Text)
9 import Data.Time (UTCTime)
10 import Data.Gargantext.Types.Node ( NodePoly
11 , HyperdataFolder , HyperdataCorpus , HyperdataDocument
12 , HyperdataFavorites, HyperdataResource
13 , HyperdataList , HyperdataScore
14 , HyperdataGraph
15 , HyperdataPhylo
16 , HyperdataNotebook
17 )
18
19 -- | TODO add Symbolic Node / Document
20 -- TODO make instances of Nodes
21
22 -- All the Database is structred like a hierachical Tree
23 -- Where a is a NodeType:
24 data Tree a = Empty | Node' a (Tree a) (Tree a) deriving (Show)
25
26 --gargTree :: Tree NodeType
27 --gargTree = Node' NodeUser Empty
28 -- (Node' Empty
29 -- (Project Empty Empty)
30 -- )
31 --
32
33
34 data NodeType = NodeUser
35 | Folder | Project | Corpus | Document
36 | Favorites
37 | NodeSwap
38 | List | StopList | MainList | MapList | GroupList
39 | Score | Occurrences | Cooccurrences | Specclusion | Genclusion | Cvalue
40 | Tficf | TfidfCorpus | TfidfGlobal | TirankLocal | TirankGlobal
41
42 deriving (Show, Eq)
43
44
45
46 -- | NodePoly indicates that Node has a Polymorphism Type
47 type Node json = NodePoly Integer NodeTypeId Integer Integer Text UTCTime json
48 -- type Node json = NodePoly NodeId NodeTypeId UserId ParentId NodeName UTCTime json
49 type NodeTypeId = Int
50
51 --type NodeUser = Node HyperdataUser
52
53 -- | Then a Node can be either a Folder or a Corpus or a Document
54 type Folder = Node HyperdataFolder
55 type Project = Folder
56 type Corpus = Node HyperdataCorpus
57 type Document = Node HyperdataDocument
58
59 -- | Community Manager Use Case
60 type Annuaire = Corpus
61 type Individu = Document
62
63 -- | Favorites Node enable Node categorization
64 type Favorites = Node HyperdataFavorites
65
66 -- | Favorites Node enable Swap Node with some synonyms for clarity
67 type NodeSwap = Node HyperdataResource
68
69 -- | Then a Node can be a List which as some synonyms
70 type List = Node HyperdataList
71 type StopList = List
72 type MainList = List
73 type MapList = List
74 type GroupList = List
75
76 -- | Then a Node can be a Score which as some synonyms
77 type Score = Node HyperdataScore
78 type Occurrences = Score
79 type Cooccurrences = Score
80 type Specclusion = Score
81 type Genclusion = Score
82 type Cvalue = Score
83 type Tficf = Score
84 -- TODO All these Tfidf* will be replaced with TFICF
85 type TfidfCorpus = Tficf
86 type TfidfGlobal = Tficf
87 type TirankLocal = Tficf
88 type TirankGlobal = Tficf
89
90 -- | Then a Node can be either a Graph or a Phylo or a Notebook
91 type Graph = Node HyperdataGraph
92 type Phylo = Node HyperdataPhylo
93 type Notebook = Node HyperdataNotebook
94
95
96 nodeTypes :: [(NodeType, NodeTypeId)]
97 nodeTypes = [
98 --(NodeUser , 1)
99 --
100 (Project , 2)
101 , (NodeSwap , 19)
102 , (Corpus , 3)
103 , (Document , 4)
104 ------ Lists
105 , (StopList , 5)
106 , (GroupList , 6)
107 , (MainList , 7)
108 , (MapList ,  8)
109 -- Scores
110 , (Occurrences , 10)
111 , (Cooccurrences , 9)
112
113 , (Specclusion , 11)
114 , (Genclusion , 18)
115 , (Cvalue , 12)
116
117 , (TfidfCorpus , 13)
118 , (TfidfGlobal , 14)
119
120 , (TirankLocal , 16)
121 , (TirankGlobal , 17)
122
123 -- Node management
124 , (Favorites , 15)
125
126 ]
127 --
128 nodeTypeId :: NodeType -> NodeTypeId
129 nodeTypeId tn = fromMaybe (error ("Typename " ++ show tn ++ " does not exist")) (lookup tn nodeTypes)