Build only NodeType which are used and have an ID

parent f420c18a
...@@ -28,51 +28,59 @@ import Data.List (lookup) ...@@ -28,51 +28,59 @@ import Data.List (lookup)
import Gargantext.Database.Types.Node import Gargantext.Database.Types.Node
import Gargantext.Prelude import Gargantext.Prelude
-- | Nodes are typed in the database according to a specific ID nodeTypeId :: NodeType -> NodeTypeId
-- nodeTypeId n =
nodeTypeInv :: [(NodeTypeId, NodeType)] case n of
nodeTypeInv = map swap nodeTypes NodeUser -> 1
Folder -> 2
NodeCorpus -> 3
-- NodeCorpus -> 30 TODO ERRR
Annuaire -> 31
Document -> 4
UserPage -> 41
--NodeSwap -> 19
---- Lists
-- StopList -> 5
-- GroupList -> 6
-- MainList -> 7
-- MapList -> 8
nodeTypes :: [(NodeType, NodeTypeId)]
nodeTypes = [ (NodeUser , 1)
, (Folder , 2)
, (NodeCorpus , 3)
, (NodeCorpus , 30)
, (Annuaire , 31)
, (Document , 4)
, (UserPage , 41)
--, (NodeSwap , 19)
------ Lists
-- , (StopList , 5)
-- , (GroupList , 6)
-- , (MainList , 7)
-- , (MapList ,  8)
---- Scores ---- Scores
, (Occurrences , 10) Occurrences -> 10
, (Graph , 9) Graph -> 9
, (Dashboard , 5) Dashboard -> 5
, (Chart , 51) Chart -> 51
-- , (Cooccurrences , 9)
-- -- Cooccurrences -> 9
-- , (Specclusion , 11)
-- , (Genclusion , 18)
-- , (Cvalue , 12)
-- --
-- , (TfidfCorpus , 13) -- Specclusion -> 11
-- , (TfidfGlobal , 14) -- Genclusion -> 18
-- Cvalue -> 12
-- --
-- , (TirankLocal , 16) -- TfidfCorpus -> 13
-- , (TirankGlobal , 17) -- TfidfGlobal -> 14
-- --
-- TirankLocal -> 16
-- TirankGlobal -> 17
---- Node management ---- Node management
, (Favorites , 15) Favorites -> 15
-- Project -> TODO
-- Individu -> TODO
-- Classification -> TODO
-- Lists -> TODO
-- Metrics -> TODO
-- --
] -- | Nodes are typed in the database according to a specific ID
-- --
nodeTypeId :: NodeType -> NodeTypeId nodeTypeInv :: [(NodeTypeId, NodeType)]
nodeTypeId tn = fromMaybe (panic $ pack $ "Typename " <> show tn <> " does not exist") nodeTypeInv = map swap nodeTypes
(lookup tn nodeTypes)
nodeTypes :: [(NodeType, NodeTypeId)]
nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
typeId2node :: NodeTypeId -> NodeType typeId2node :: NodeTypeId -> NodeType
typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist") typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
......
...@@ -275,15 +275,20 @@ type Document = Node HyperdataDocument ...@@ -275,15 +275,20 @@ type Document = Node HyperdataDocument
------------------------------------------------------------------------ ------------------------------------------------------------------------
data NodeType = NodeUser data NodeType = NodeUser
| Project | Folder -- | Project
| Folder
| NodeCorpus | Annuaire | NodeCorpus | Annuaire
| Document | Individu | Document -- | Individu
| UserPage | Favorites | UserPage | Favorites
| Graph | Dashboard | Chart | Graph | Dashboard | Chart
| Classification -- | Classification
| Lists -- | Lists
| Metrics | Occurrences -- | Metrics
deriving (Show, Read, Eq, Generic) | Occurrences
deriving (Show, Read, Eq, Generic, Bounded, Enum)
allNodeTypes :: [NodeType]
allNodeTypes = [minBound ..]
instance FromJSON NodeType instance FromJSON NodeType
instance ToJSON NodeType instance ToJSON NodeType
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment