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