Commit c3fc3946 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[API] New route for new corpus or new documents in existing corpus.

parent 5e332ef8
...@@ -76,6 +76,7 @@ import Gargantext.API.Node ...@@ -76,6 +76,7 @@ import Gargantext.API.Node
import Gargantext.API.Search ( SearchAPI, search, SearchQuery) import Gargantext.API.Search ( SearchAPI, search, SearchQuery)
import Gargantext.API.Types import Gargantext.API.Types
import Gargantext.API.Upload import Gargantext.API.Upload
import qualified Gargantext.API.Corpus.New as New
import Gargantext.Core.Types (HasInvalidError(..)) import Gargantext.Core.Types (HasInvalidError(..))
import Gargantext.Database.Facet import Gargantext.Database.Facet
import Gargantext.Database.Schema.Node (HasNodeError(..), NodeError) import Gargantext.Database.Schema.Node (HasNodeError(..), NodeError)
...@@ -262,7 +263,7 @@ type GargAPI' = ...@@ -262,7 +263,7 @@ type GargAPI' =
:<|> "count" :> Summary "Count endpoint" :<|> "count" :> Summary "Count endpoint"
:> ReqBody '[JSON] Query :> CountAPI :> ReqBody '[JSON] Query :> CountAPI
-- Corpus endpoint -- Corpus endpoint --> TODO rename s/search/filter/g
:<|> "search":> Summary "Search endpoint" :<|> "search":> Summary "Search endpoint"
:> ReqBody '[JSON] SearchQuery :> ReqBody '[JSON] SearchQuery
:> QueryParam "offset" Int :> QueryParam "offset" Int
...@@ -281,6 +282,8 @@ type GargAPI' = ...@@ -281,6 +282,8 @@ type GargAPI' =
:<|> "upload" :> ApiUpload :<|> "upload" :> ApiUpload
:<|> "new" :> New.Api
-- :<|> "scraper" :> WithCallbacks ScraperAPI -- :<|> "scraper" :> WithCallbacks ScraperAPI
...@@ -324,6 +327,7 @@ serverGargAPI -- orchestrator ...@@ -324,6 +327,7 @@ serverGargAPI -- orchestrator
:<|> graphAPI -- TODO: mock :<|> graphAPI -- TODO: mock
:<|> treeAPI :<|> treeAPI
:<|> upload :<|> upload
:<|> New.api
-- :<|> orchestrator -- :<|> orchestrator
where where
fakeUserId = 1 -- TODO fakeUserId = 1 -- TODO
......
{-|
Module : Gargantext.API.Corpus.New
Description : New corpus API
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
New corpus means either:
- new corpus
- new data in existing corpus
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
module Gargantext.API.Corpus.New
where
import Servant
import Gargantext.Prelude
import Gargantext.API.Count (Query(..))
import Gargantext.Database.Types.Node (CorpusId)
--import Gargantext.Database.Flow (flowCorpusSearchInDatabase)
type Api = Summary "New Corpus endpoint"
:> ReqBody '[JSON] Query
:> Post '[JSON] CorpusId
api :: Monad m => Query -> m CorpusId
api _ = pure 1
...@@ -69,6 +69,7 @@ data QueryBool = QueryBool Text ...@@ -69,6 +69,7 @@ data QueryBool = QueryBool Text
queries :: [QueryBool] queries :: [QueryBool]
queries = [QueryBool (pack "(X OR X') AND (Y OR Y') NOT (Z OR Z')")] queries = [QueryBool (pack "(X OR X') AND (Y OR Y') NOT (Z OR Z')")]
--queries = [QueryBool (pack "(X + X') * (Y + Y') - (Z + Z')")]
instance Arbitrary QueryBool where instance Arbitrary QueryBool where
arbitrary = elements queries arbitrary = elements queries
......
mercredi 15 mai 2019, 07:54:33 (UTC+0200)
{-|
Module : Gargantext.Text.Crawlers
Description : All crawlers of Gargantext in one file.
Copyright : (c) CNRS, 2017
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module Gargantext.Text.Crawlers
where
--import Gargantext.Prelude
--import qualified PUBMED as PubMed
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Gargantext.Text.Parsers.Isidore where
import Data.Text (Text)
import Data.Either
import Gargantext.Prelude
import Data.Aeson
import Data.Proxy
import GHC.Generics
import Network.HTTP.Client (newManager)
import Network.HTTP.Client.TLS (tlsManagerSettings)
import Servant.API
import Servant.Client
type IsidoreAPI = "sparql" :> Capture "query" Text :> Get '[JSON] [IsidoreDoc]
data IsidoreDoc =
IsidoreDoc {title :: Maybe Text}
deriving (Show, Generic)
instance FromJSON IsidoreDoc
instance ToJSON IsidoreDoc
isidoreDocsApi :: Proxy IsidoreAPI
isidoreDocsApi = Proxy
isidoreDocs :: ClientM [IsidoreDoc]
isidoreDocs = client isidoreDocsApi
getIsidoreDocs :: IO [IsidoreDoc]
getIsidoreDocs = do
manager' <- newManager tlsManagerSettings
res <- runClientM isidoreDocs $ mkClientEnv manager' $ BaseUrl Https "https://www.rechercheisidore.fr" 8080 ""
case res of
Left _ -> panic "err"
Right res' -> pure res'
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