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