3 Description : Gargantext Import Corpus
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 Import a corpus binary.
14 {-# LANGUAGE NoImplicitPrelude #-}
15 {-# LANGUAGE OverloadedStrings #-}
16 {-# LANGUAGE FlexibleContexts #-}
17 {-# LANGUAGE RankNTypes #-}
18 {-# LANGUAGE Strict #-}
22 import Data.Either (Either(..))
23 import Data.Maybe (Maybe(..))
24 import Gargantext.API.Admin.Settings (withDevEnv, runCmdDev)
25 import Gargantext.API.Prelude (GargError)
26 import Gargantext.API.Node () -- instances
27 import Gargantext.Core.Types.Individu (User(..))
28 import Gargantext.Database.Action.Flow (getOrMkRoot, getOrMk_RootWithCorpus)
29 import Gargantext.Database.Query.Table.Node (getOrMkList)
30 import Gargantext.Database.Query.Table.User (insertUsersDemo)
31 import Gargantext.Database.Admin.Config (userMaster, corpusMasterName)
32 import Gargantext.Database.Admin.Types.Node
33 import Gargantext.Database.Admin.Trigger.Init (initTriggers)
34 import Gargantext.Database.Admin.Types.Node (CorpusId, RootId, HyperdataCorpus, ListId)
35 import Gargantext.Database.Prelude (Cmd, )
36 import Gargantext.Prelude
37 import System.Environment (getArgs)
43 let createUsers :: Cmd GargError Int64
44 createUsers = insertUsersDemo
47 mkRoots :: Cmd GargError [(UserId, RootId)]
48 mkRoots = mapM getOrMkRoot $ map UserName ["gargantua", "user1", "user2"]
49 -- TODO create all users roots
52 initMaster :: Cmd GargError (UserId, RootId, CorpusId, ListId)
54 (masterUserId, masterRootId, masterCorpusId) <- getOrMk_RootWithCorpus (UserName userMaster) (Left corpusMasterName) (Nothing :: Maybe HyperdataCorpus)
55 masterListId <- getOrMkList masterCorpusId masterUserId
56 _triggers <- initTriggers masterListId
57 pure (masterUserId, masterRootId, masterCorpusId, masterListId)
59 withDevEnv iniPath $ \env -> do
60 _ <- runCmdDev env createUsers
61 _ <- runCmdDev env mkRoots
62 x <- runCmdDev env initMaster