Commit 325970ef authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DEMO] adapting Contact Type.

parent 3a2ce776
...@@ -80,6 +80,7 @@ import Gargantext.API.Node ( Roots , roots ...@@ -80,6 +80,7 @@ import Gargantext.API.Node ( Roots , roots
, HyperdataCorpus , HyperdataCorpus
, HyperdataAnnuaire , HyperdataAnnuaire
) )
import Gargantext.Database.Node.Contact (HyperdataContact)
import Gargantext.Database.Types.Node () import Gargantext.Database.Types.Node ()
import Gargantext.API.Count ( CountAPI, count, Query) import Gargantext.API.Count ( CountAPI, count, Query)
import Gargantext.API.Search ( SearchAPI, search, SearchQuery) import Gargantext.API.Search ( SearchAPI, search, SearchQuery)
...@@ -283,7 +284,7 @@ serverGargAPI env = do ...@@ -283,7 +284,7 @@ serverGargAPI env = do
:<|> roots conn :<|> roots conn
:<|> nodeAPI conn (Proxy :: Proxy HyperdataAny) :<|> nodeAPI conn (Proxy :: Proxy HyperdataAny)
:<|> nodeAPI conn (Proxy :: Proxy HyperdataCorpus) :<|> nodeAPI conn (Proxy :: Proxy HyperdataCorpus)
:<|> nodeAPI conn (Proxy :: Proxy HyperdataAnnuaire) :<|> nodeAPI conn (Proxy :: Proxy HyperdataContact)
:<|> nodesAPI conn :<|> nodesAPI conn
:<|> count -- TODO: undefined :<|> count -- TODO: undefined
:<|> search conn :<|> search conn
......
...@@ -272,8 +272,7 @@ deleteNodes ns = mkCmd $ \conn -> ...@@ -272,8 +272,7 @@ deleteNodes ns = mkCmd $ \conn ->
getNodesWith :: JSONB a => Connection -> Int -> proxy a -> Maybe NodeType getNodesWith :: JSONB a => Connection -> Int -> proxy a -> Maybe NodeType
-> Maybe Offset -> Maybe Limit -> IO [Node a] -> Maybe Offset -> Maybe Limit -> IO [Node a]
getNodesWith conn parentId _ nodeType maybeOffset maybeLimit = getNodesWith conn parentId _ nodeType maybeOffset maybeLimit =
runQuery conn $ selectNodesWith runQuery conn $ selectNodesWith parentId nodeType maybeOffset maybeLimit
parentId nodeType maybeOffset maybeLimit
-- NP check type -- NP check type
......
...@@ -22,6 +22,7 @@ module Gargantext.Database.Node.Contact ...@@ -22,6 +22,7 @@ module Gargantext.Database.Node.Contact
import Control.Lens (makeLenses) import Control.Lens (makeLenses)
import Data.Aeson.TH (deriveJSON) import Data.Aeson.TH (deriveJSON)
import Data.Swagger (ToSchema)
import Data.Text (Text) import Data.Text (Text)
import Data.Time (UTCTime) import Data.Time (UTCTime)
import Database.PostgreSQL.Simple.FromField (FromField, fromField) import Database.PostgreSQL.Simple.FromField (FromField, fromField)
...@@ -32,17 +33,22 @@ import Gargantext.Database.Types.Node (Node,Hyperdata,NodeType(..)) ...@@ -32,17 +33,22 @@ import Gargantext.Database.Types.Node (Node,Hyperdata,NodeType(..))
import Gargantext.Database.Utils (fromField') import Gargantext.Database.Utils (fromField')
import Gargantext.Prelude import Gargantext.Prelude
import Opaleye (QueryRunnerColumnDefault, queryRunnerColumnDefault, PGJsonb, fieldQueryRunnerColumn) import Opaleye (QueryRunnerColumnDefault, queryRunnerColumnDefault, PGJsonb, fieldQueryRunnerColumn)
import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
------------------------------------------------------------------------ ------------------------------------------------------------------------
type NodeContact = Node HyperdataContact type NodeContact = Node HyperdataContact
data HyperdataContact = data HyperdataContact =
HyperdataContact { _hc_who :: Maybe ContactWho HyperdataContact { _hc_bdd :: Maybe Text -- ID of Database source
, _hc_who :: Maybe ContactWho
, _hc_where :: Maybe [ContactWhere] , _hc_where :: Maybe [ContactWhere]
, _hc_metaData :: Maybe ContactMetaData , _hc_title :: Maybe Text -- TODO remove (only demo)
, _hc_uniqId :: Maybe Text , _hc_source :: Maybe Text -- TODO remove (only demo)
, _hc_lastValidation :: Maybe Text
, _hc_uniqIdBdd :: Maybe Text , _hc_uniqIdBdd :: Maybe Text
, _hc_uniqId :: Maybe Text
} deriving (Eq, Show, Generic) } deriving (Eq, Show, Generic)
...@@ -54,6 +60,7 @@ data ContactMetaData = ...@@ -54,6 +60,7 @@ data ContactMetaData =
arbitraryHyperdataContact :: HyperdataContact arbitraryHyperdataContact :: HyperdataContact
arbitraryHyperdataContact = HyperdataContact Nothing Nothing Nothing arbitraryHyperdataContact = HyperdataContact Nothing Nothing Nothing
Nothing Nothing Nothing
Nothing Nothing Nothing Nothing
data ContactWho = data ContactWho =
...@@ -97,6 +104,14 @@ nodeContactW maybeName maybeContact aId = ...@@ -97,6 +104,14 @@ nodeContactW maybeName maybeContact aId =
-- | Main instances of Contact -- | Main instances of Contact
instance ToSchema HyperdataContact
instance ToSchema ContactWho
instance ToSchema ContactWhere
instance ToSchema ContactTouch
instance Arbitrary HyperdataContact where
arbitrary = elements [HyperdataContact Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing]
-- | Specific Gargantext instance -- | Specific Gargantext instance
instance Hyperdata HyperdataContact instance Hyperdata HyperdataContact
......
...@@ -77,7 +77,7 @@ imtUser2gargContact (IMTUser id' entite' mail' nom' prenom' fonction' tel' _fax' ...@@ -77,7 +77,7 @@ imtUser2gargContact (IMTUser id' entite' mail' nom' prenom' fonction' tel' _fax'
service' _groupe' bureau' url' _pservice' _pfonction' _afonction' service' _groupe' bureau' url' _pservice' _pfonction' _afonction'
_grprech' lieu' _aprecision' _atel' _sexe' _statut' _idutilentite' _grprech' lieu' _aprecision' _atel' _sexe' _statut' _idutilentite'
_entite2' _service2' _group2' _actif' _idutilsiecoles' date_modification') _entite2' _service2' _group2' _actif' _idutilsiecoles' date_modification')
= HyperdataContact (Just qui) (Just [ou]) (Just meta) Nothing Nothing = HyperdataContact (Just qui) (Just [ou]) (Just meta) ((<>) <$> prenom' <*> nom') entite' Nothing Nothing
where where
qui = ContactWho (Just id') prenom' nom' (Just $ catMaybes [service']) Nothing qui = ContactWho (Just id') prenom' nom' (Just $ catMaybes [service']) Nothing
ou = ContactWhere (toList entite') (toList service') fonction' bureau' (Just "France") lieu' contact Nothing Nothing ou = ContactWhere (toList entite') (toList service') fonction' bureau' (Just "France") lieu' contact Nothing Nothing
......
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