Build only NodeType which are used and have an ID

parent f420c18a
......@@ -28,51 +28,59 @@ import Data.List (lookup)
import Gargantext.Database.Types.Node
import Gargantext.Prelude
-- | Nodes are typed in the database according to a specific ID
--
nodeTypeInv :: [(NodeTypeId, NodeType)]
nodeTypeInv = map swap nodeTypes
nodeTypeId :: NodeType -> NodeTypeId
nodeTypeId n =
case n of
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
, (Occurrences , 10)
, (Graph , 9)
, (Dashboard , 5)
, (Chart , 51)
-- , (Cooccurrences , 9)
--
-- , (Specclusion , 11)
-- , (Genclusion , 18)
-- , (Cvalue , 12)
Occurrences -> 10
Graph -> 9
Dashboard -> 5
Chart -> 51
-- Cooccurrences -> 9
--
-- , (TfidfCorpus , 13)
-- , (TfidfGlobal , 14)
-- Specclusion -> 11
-- Genclusion -> 18
-- Cvalue -> 12
--
-- , (TirankLocal , 16)
-- , (TirankGlobal , 17)
-- TfidfCorpus -> 13
-- TfidfGlobal -> 14
--
-- TirankLocal -> 16
-- TirankGlobal -> 17
---- 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
nodeTypeId tn = fromMaybe (panic $ pack $ "Typename " <> show tn <> " does not exist")
(lookup tn nodeTypes)
nodeTypeInv :: [(NodeTypeId, NodeType)]
nodeTypeInv = map swap nodeTypes
nodeTypes :: [(NodeType, NodeTypeId)]
nodeTypes = [ (n, nodeTypeId n) | n <- allNodeTypes ]
typeId2node :: NodeTypeId -> NodeType
typeId2node tId = fromMaybe (panic $ pack $ "Type Id " <> show tId <> " does not exist")
......
......@@ -275,15 +275,20 @@ type Document = Node HyperdataDocument
------------------------------------------------------------------------
data NodeType = NodeUser
| Project | Folder
-- | Project
| Folder
| NodeCorpus | Annuaire
| Document | Individu
| Document -- | Individu
| UserPage | Favorites
| Graph | Dashboard | Chart
| Classification
| Lists
| Metrics | Occurrences
deriving (Show, Read, Eq, Generic)
-- | Classification
-- | Lists
-- | Metrics
| Occurrences
deriving (Show, Read, Eq, Generic, Bounded, Enum)
allNodeTypes :: [NodeType]
allNodeTypes = [minBound ..]
instance FromJSON 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