2 Module : Gargantext.Ext.IMTUser
3 Description : Interface to get IMT users
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
10 We can not import the IMT Client API code since it is copyrighted.
11 Here is writtent a common interface.
16 module Gargantext.Ext.IMTUser (deserialiseImtUsersFromFile)
19 import Codec.Serialise
20 import Data.Maybe (Maybe, catMaybes)
21 import Data.Text (Text)
22 import GHC.Generics (Generic)
23 import Gargantext.Database.Query.Table.Node.Contact -- (HyperdataContact, ContactWho, ContactWhere, ContactTouch, ContactMetaData)
24 import Gargantext.Prelude
25 import System.IO (FilePath)
26 import qualified Data.ByteString.Lazy as BSL
28 ------------------------------------------------------------------------
30 instance Serialise IMTUser
32 deserialiseImtUsersFromFile :: FilePath -> IO [HyperdataContact]
33 deserialiseImtUsersFromFile filepath = map imtUser2gargContact <$> deserialiseFromFile' filepath
35 deserialiseFromFile' :: FilePath -> IO [IMTUser]
36 deserialiseFromFile' filepath = deserialise <$> BSL.readFile filepath
38 data IMTUser = IMTUser
40 , entite :: Maybe Text
43 , prenom :: Maybe Text
44 , fonction :: Maybe Text
47 , service :: Maybe Text
48 , groupe :: Maybe Text
49 , bureau :: Maybe Text
51 , pservice :: Maybe Text
52 , pfonction :: Maybe Text
53 , afonction :: Maybe Text
54 , grprech :: Maybe Text
56 , aprecision :: Maybe Text
59 , statut :: Maybe Text
60 , idutilentite :: Maybe Text
61 , entite2 :: Maybe Text
62 , service2 :: Maybe Text
63 , groupe2 :: Maybe Text
65 , idutilsiecoles :: Maybe Text
66 , date_modification :: Maybe Text
67 } deriving (Eq, Show, Generic)
69 imtUser2gargContact :: IMTUser -> HyperdataContact
70 imtUser2gargContact (IMTUser id' entite' mail' nom' prenom' fonction' tel' _fax'
71 service' _groupe' bureau' url' _pservice' _pfonction' _afonction'
72 _grprech' lieu' _aprecision' _atel' _sexe' _statut' _idutilentite'
73 _entite2' _service2' _group2' _actif' _idutilsiecoles' date_modification')
74 = HyperdataContact (Just "IMT Annuaire") (Just qui) [ou] ((<>) <$> (fmap (\p -> p <> " ") prenom') <*> nom') entite' date_modification' Nothing Nothing
76 qui = ContactWho (Just id') prenom' nom' (catMaybes [service']) []
77 ou = ContactWhere (toList entite') (toList service') fonction' bureau' (Just "France") lieu' contact Nothing Nothing
78 contact = Just $ ContactTouch mail' tel' url'
79 -- meta = ContactMetaData (Just "IMT annuaire") date_modification'