Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
515e9ba3
Commit
515e9ba3
authored
Feb 14, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API] Phylo backend basic connection
parent
40967e89
Pipeline
#2479
passed with stage
in 48 minutes and 1 second
Changes
8
Pipelines
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
357 additions
and
365 deletions
+357
-365
Main.hs
bin/gargantext-phylo/Main.hs
+1
-2
package.yaml
package.yaml
+1
-0
Client.hs
src/Gargantext/API/Client.hs
+5
-4
Node.hs
src/Gargantext/API/Node.hs
+4
-9
API.hs
src/Gargantext/Core/Viz/Phylo/API.hs
+146
-177
Tools.hs
src/Gargantext/Core/Viz/Phylo/API/Tools.hs
+196
-0
Example.hs
src/Gargantext/Core/Viz/Phylo/Example.hs
+4
-4
LegacyAPI.hs
src/Gargantext/Core/Viz/Phylo/Legacy/LegacyAPI.hs
+0
-169
No files found.
bin/gargantext-phylo/Main.hs
View file @
515e9ba3
...
...
@@ -36,7 +36,7 @@ import Gargantext.Core.Text.List.Formats.CSV (csvMapTermList)
import
Gargantext.Core.Text.Terms.WithList
(
Patterns
,
buildPatterns
,
extractTermsWithList
)
import
Gargantext.Core.Types.Main
(
ListType
(
..
))
import
Gargantext.Core.Viz.Phylo
import
Gargantext.Core.Viz.Phylo.API
import
Gargantext.Core.Viz.Phylo.API
.Tools
import
Gargantext.Core.Viz.Phylo.PhyloExport
(
toPhyloExport
,
dotToFile
)
import
Gargantext.Core.Viz.Phylo.PhyloMaker
(
toPhylo
,
toPhyloStep
)
import
Gargantext.Core.Viz.Phylo.PhyloTools
(
printIOMsg
,
printIOComment
,
setConfig
)
...
...
@@ -46,7 +46,6 @@ import Gargantext.Prelude
import
System.Directory
(
listDirectory
,
doesFileExist
)
import
System.Environment
import
qualified
Data.ByteString.Char8
as
C8
import
qualified
Data.ByteString.Lazy
as
Lazy
import
qualified
Data.Text
as
T
import
qualified
Data.Vector
as
Vector
import
qualified
Gargantext.Core.Text.Corpus.Parsers.CSV
as
Csv
...
...
package.yaml
View file @
515e9ba3
...
...
@@ -104,6 +104,7 @@ library:
-
Gargantext.Core.Viz.Graph.Index
-
Gargantext.Core.Viz.Phylo
-
Gargantext.Core.Viz.Phylo.API
-
Gargantext.Core.Viz.Phylo.API.Tools
-
Gargantext.Core.Viz.Phylo.PhyloMaker
-
Gargantext.Core.Viz.Phylo.PhyloTools
-
Gargantext.Core.Viz.Phylo.PhyloExport
...
...
src/Gargantext/API/Client.hs
View file @
515e9ba3
...
...
@@ -40,7 +40,6 @@ import Gargantext.Core.Types (NodeTableResult)
import
Gargantext.Core.Types.Main
hiding
(
Limit
,
Offset
)
import
Gargantext.Core.Viz.Graph
hiding
(
Node
,
Version
)
import
Gargantext.Core.Viz.Graph.API
import
Gargantext.Core.Viz.Phylo.Legacy.LegacyAPI
import
Gargantext.Core.Viz.Types
import
Gargantext.Database.Admin.Types.Metrics
import
Gargantext.Database.Admin.Types.Hyperdata
...
...
@@ -55,6 +54,8 @@ import Servant.Job.Core
import
Servant.Job.Types
import
System.Metrics.Json
(
Sample
,
Value
)
import
qualified
Data.Aeson
as
Aeson
-- * version API
getBackendVersion
::
ClientM
Text
...
...
@@ -131,7 +132,7 @@ getNodePieHash :: Token -> NodeId -> Maybe NodeId -> TabType -> ClientM Text
getNodeTree
::
Token
->
NodeId
->
Maybe
UTCTime
->
Maybe
UTCTime
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
(
HashedResponse
(
ChartMetrics
(
Vector
NgramsTree
)))
postNodeTreeUpdate
::
Token
->
NodeId
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
()
getNodeTreeHash
::
Token
->
NodeId
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
Text
getNodePhylo
::
Token
->
NodeId
->
Maybe
NodeId
->
Maybe
Int
->
Maybe
Int
->
ClientM
SVG
getNodePhylo
::
Token
->
NodeId
->
Maybe
NodeId
->
Maybe
Int
->
Maybe
Int
->
ClientM
Aeson
.
Value
putNodePhylo
::
Token
->
NodeId
->
Maybe
NodeId
->
ClientM
NodeId
putNodeMove
::
Token
->
NodeId
->
ParentId
->
ClientM
[
Int
]
...
...
@@ -220,7 +221,7 @@ getCorpusPieHash :: Token -> CorpusId -> Maybe NodeId -> TabType -> ClientM Text
getCorpusTree
::
Token
->
CorpusId
->
Maybe
UTCTime
->
Maybe
UTCTime
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
(
HashedResponse
(
ChartMetrics
(
Vector
NgramsTree
)))
postCorpusTreeUpdate
::
Token
->
CorpusId
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
()
getCorpusTreeHash
::
Token
->
CorpusId
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
Text
getCorpusPhylo
::
Token
->
CorpusId
->
Maybe
NodeId
->
Maybe
Int
->
Maybe
Int
->
ClientM
SVG
getCorpusPhylo
::
Token
->
CorpusId
->
Maybe
NodeId
->
Maybe
Int
->
Maybe
Int
->
ClientM
Aeson
.
Value
putCorpusPhylo
::
Token
->
CorpusId
->
Maybe
NodeId
->
ClientM
NodeId
putCorpusMove
::
Token
->
CorpusId
->
ParentId
->
ClientM
[
Int
]
...
...
@@ -314,7 +315,7 @@ getAnnuairePieHash :: Token -> AnnuaireId -> Maybe NodeId -> TabType -> ClientM
getAnnuaireTree
::
Token
->
AnnuaireId
->
Maybe
UTCTime
->
Maybe
UTCTime
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
(
HashedResponse
(
ChartMetrics
(
Vector
NgramsTree
)))
postAnnuaireTreeUpdate
::
Token
->
AnnuaireId
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
()
getAnnuaireTreeHash
::
Token
->
AnnuaireId
->
Maybe
NodeId
->
TabType
->
ListType
->
ClientM
Text
getAnnuairePhylo
::
Token
->
AnnuaireId
->
Maybe
NodeId
->
Maybe
Int
->
Maybe
Int
->
ClientM
SVG
getAnnuairePhylo
::
Token
->
AnnuaireId
->
Maybe
NodeId
->
Maybe
Int
->
Maybe
Int
->
ClientM
Aeson
.
Value
putAnnuairePhylo
::
Token
->
AnnuaireId
->
Maybe
NodeId
->
ClientM
NodeId
putAnnuaireMove
::
Token
->
AnnuaireId
->
ParentId
->
ClientM
[
Int
]
...
...
src/Gargantext/API/Node.hs
View file @
515e9ba3
...
...
@@ -36,10 +36,6 @@ import Data.Maybe
import
Data.Swagger
import
Data.Text
(
Text
())
import
GHC.Generics
(
Generic
)
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Gargantext.API.Admin.Auth
(
withAccess
)
import
Gargantext.API.Admin.Auth.Types
(
PathId
(
..
))
import
Gargantext.API.Metrics
...
...
@@ -53,7 +49,7 @@ import Gargantext.Core.Types (NodeTableResult)
import
Gargantext.Core.Types.Individu
(
User
(
..
))
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Core.Viz.Phylo.
Legacy.Legacy
API
(
PhyloAPI
,
phyloAPI
)
import
Gargantext.Core.Viz.Phylo.API
(
PhyloAPI
,
phyloAPI
)
import
Gargantext.Database.Action.Flow.Pairing
(
pairing
)
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
...
...
@@ -68,6 +64,9 @@ import Gargantext.Database.Query.Table.NodeContext (nodeContextsCategory, nodeCo
import
Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Query.Tree
(
tree
,
TreeMode
(
..
))
import
Gargantext.Prelude
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
qualified
Gargantext.API.Node.DocumentUpload
as
DocumentUpload
import
qualified
Gargantext.API.Node.DocumentsFromWriteNodes
as
DocumentsFromWriteNodes
import
qualified
Gargantext.API.Node.FrameCalcUpload
as
FrameCalcUpload
...
...
@@ -77,10 +76,6 @@ import qualified Gargantext.API.Search as Search
import
qualified
Gargantext.Database.Action.Delete
as
Action
(
deleteNode
)
import
qualified
Gargantext.Database.Query.Table.Node.Update
as
U
(
update
,
Update
(
..
))
{-
import qualified Gargantext.Core.Text.List.Learn as Learn
import qualified Data.Vector as Vec
--}
-- | Admin NodesAPI
-- TODO
...
...
src/Gargantext/Core/Viz/Phylo/API.hs
View file @
515e9ba3
This diff is collapsed.
Click to expand it.
src/Gargantext/Core/Viz/Phylo/API/Tools.hs
0 → 100644
View file @
515e9ba3
{-|
Module : Gargantext.Core.Viz.Phylo.API
Description :
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
module
Gargantext.Core.Viz.Phylo.API.Tools
where
import
Data.Proxy
import
Data.Aeson
(
Value
,
decodeFileStrict
,
eitherDecode
,
encode
)
import
Data.Map
(
Map
)
import
Data.Maybe
(
catMaybes
)
import
Data.Set
(
Set
)
import
Data.Text
(
Text
,
pack
)
import
Data.Time.Calendar
(
fromGregorian
,
diffGregorianDurationClip
,
cdMonths
,
diffDays
,
showGregorian
)
import
Data.Time.Clock.POSIX
(
posixSecondsToUTCTime
)
import
Gargantext.API.Ngrams.Prelude
(
getTermList
)
import
Gargantext.API.Ngrams.Tools
(
getRepo'
)
import
Gargantext.API.Ngrams.Types
(
NgramsTerm
(
..
))
import
Gargantext.API.Node.Corpus.Export
(
getContextNgrams
)
import
Gargantext.API.Prelude
(
GargNoServer
)
import
Gargantext.Core.Text.Context
(
TermList
)
import
Gargantext.Core.Types
(
Context
)
import
Gargantext.Core.Types.Main
(
ListType
(
MapTerm
))
import
Gargantext.Core.Viz.Phylo
(
TimeUnit
(
..
),
Date
,
Document
(
..
),
Config
(
..
),
Phylo
)
import
Gargantext.Core.Viz.Phylo.PhyloExport
(
toPhyloExport
,
dotToFile
)
import
Gargantext.Core.Viz.Phylo.PhyloMaker
(
toPhylo
,
toPhyloStep
)
import
Gargantext.Core.Viz.Phylo.PhyloTools
(
{-printIOMsg, printIOComment,-}
setConfig
)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataPhylo
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
CorpusId
,
ContextId
,
PhyloId
)
import
Gargantext.Database.Query.Table.Node
(
defaultList
,
getNodeWith
)
import
Gargantext.Database.Query.Table.NodeContext
(
selectDocNodes
)
import
Gargantext.Database.Schema.Context
import
Gargantext.Database.Schema.Node
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Prelude
import
Prelude
as
Prelude
import
System.Process
as
Shell
import
qualified
Data.ByteString.Lazy
as
Lazy
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
--------------------------------------------------------------------
getPhyloData
::
PhyloId
->
GargNoServer
(
Maybe
Phylo
)
getPhyloData
phyloId
=
do
nodePhylo
<-
getNodeWith
phyloId
(
Proxy
::
Proxy
HyperdataPhylo
)
pure
$
_hp_data
$
_node_hyperdata
nodePhylo
putPhylo
::
PhyloId
->
GargNoServer
Phylo
putPhylo
=
undefined
savePhylo
::
PhyloId
->
GargNoServer
()
savePhylo
=
undefined
--------------------------------------------------------------------
phylo2dot2json
::
Phylo
->
IO
Value
phylo2dot2json
phylo
=
do
let
file_from
=
"/tmp/fromPhylo.json"
file_dot
=
"/tmp/tmp.dot"
file_to_json
=
"/tmp/toPhylo.json"
_
<-
dotToFile
file_from
(
toPhyloExport
phylo
)
_
<-
Shell
.
callProcess
"/usr/bin/dot"
[
"-Tdot"
,
"-o"
,
file_dot
,
file_from
]
_
<-
Shell
.
callProcess
"/usr/bin/dot"
[
"-Txdot_json"
,
"-o"
,
file_to_json
,
file_dot
]
maybeValue
<-
decodeFileStrict
file_to_json
_
<-
Shell
.
callProcess
"/bin/rm"
[
"-rf"
,
file_from
,
file_to_json
,
file_dot
]
case
maybeValue
of
Nothing
->
panic
"[G.C.V.Phylo.API.phylo2dot2json] Error no file"
Just
v
->
pure
v
flowPhyloAPI
::
Config
->
CorpusId
->
GargNoServer
Phylo
flowPhyloAPI
config
cId
=
do
(
mapList
,
corpus
)
<-
corpusIdtoDocuments
(
timeUnit
config
)
cId
phyloWithCliques
<-
pure
$
toPhyloStep
corpus
mapList
config
-- writePhylo phyloWithCliquesFile phyloWithCliques
pure
$
toPhylo
(
setConfig
config
phyloWithCliques
)
--------------------------------------------------------------------
corpusIdtoDocuments
::
TimeUnit
->
CorpusId
->
GargNoServer
(
TermList
,
[
Document
])
corpusIdtoDocuments
timeUnit
corpusId
=
do
docs
<-
selectDocNodes
corpusId
lId
<-
defaultList
corpusId
repo
<-
getRepo'
[
lId
]
ngs_terms
<-
getContextNgrams
corpusId
lId
MapTerm
NgramsTerms
repo
ngs_sources
<-
getContextNgrams
corpusId
lId
MapTerm
Sources
repo
termList
<-
getTermList
lId
MapTerm
NgramsTerms
case
termList
of
Nothing
->
panic
"[G.C.V.Phylo.API] no termList found"
Just
termList'
->
pure
(
termList'
,
docs'
)
where
docs'
=
catMaybes
$
List
.
map
(
\
doc
->
context2phyloDocument
timeUnit
doc
(
ngs_terms
,
ngs_sources
)
)
docs
context2phyloDocument
::
TimeUnit
->
Context
HyperdataDocument
->
(
Map
ContextId
(
Set
NgramsTerm
),
Map
ContextId
(
Set
NgramsTerm
))
->
Maybe
Document
context2phyloDocument
timeUnit
context
(
ngs_terms
,
ngs_sources
)
=
do
let
contextId
=
_context_id
context
(
date
,
date'
)
<-
context2date
context
timeUnit
text
<-
Map
.
lookup
contextId
ngs_terms
sources
<-
Map
.
lookup
contextId
ngs_sources
pure
$
Document
date
date'
(
toText
text
)
Nothing
(
toText
sources
)
where
toText
x
=
Set
.
toList
$
Set
.
map
unNgramsTerm
x
context2date
::
Context
HyperdataDocument
->
TimeUnit
->
Maybe
(
Date
,
Text
)
context2date
context
timeUnit
=
do
let
hyperdata
=
_context_hyperdata
context
year
<-
_hd_publication_year
hyperdata
month
<-
_hd_publication_month
hyperdata
day
<-
_hd_publication_day
hyperdata
pure
(
toPhyloDate
year
month
day
timeUnit
,
toPhyloDate'
year
month
day
timeUnit
)
---------------
-- | Dates | --
---------------
toMonths
::
Integer
->
Int
->
Int
->
Date
toMonths
y
m
d
=
fromIntegral
$
cdMonths
$
diffGregorianDurationClip
(
fromGregorian
y
m
d
)
(
fromGregorian
0000
0
0
)
toDays
::
Integer
->
Int
->
Int
->
Date
toDays
y
m
d
=
fromIntegral
$
diffDays
(
fromGregorian
y
m
d
)
(
fromGregorian
0000
0
0
)
toPhyloDate
::
Int
->
Int
->
Int
->
TimeUnit
->
Date
toPhyloDate
y
m
d
tu
=
case
tu
of
Year
_
_
_
->
y
Month
_
_
_
->
toMonths
(
Prelude
.
toInteger
y
)
m
d
Week
_
_
_
->
div
(
toDays
(
Prelude
.
toInteger
y
)
m
d
)
7
Day
_
_
_
->
toDays
(
Prelude
.
toInteger
y
)
m
d
_
->
panic
"[G.C.V.Phylo.API] toPhyloDate"
toPhyloDate'
::
Int
->
Int
->
Int
->
TimeUnit
->
Text
toPhyloDate'
y
m
d
tu
=
case
tu
of
Epoch
_
_
_
->
pack
$
show
$
posixSecondsToUTCTime
$
fromIntegral
y
Year
_
_
_
->
pack
$
showGregorian
$
fromGregorian
(
toInteger
y
)
m
d
Month
_
_
_
->
pack
$
showGregorian
$
fromGregorian
(
toInteger
y
)
m
d
Week
_
_
_
->
pack
$
showGregorian
$
fromGregorian
(
toInteger
y
)
m
d
Day
_
_
_
->
pack
$
showGregorian
$
fromGregorian
(
toInteger
y
)
m
d
-- Utils
writePhylo
::
[
Char
]
->
Phylo
->
IO
()
writePhylo
path
phylo
=
Lazy
.
writeFile
path
$
encode
phylo
readPhylo
::
[
Char
]
->
IO
Phylo
readPhylo
path
=
do
phyloJson
<-
(
eitherDecode
<$>
readJson
path
)
::
IO
(
Either
String
Phylo
)
case
phyloJson
of
Left
err
->
do
putStrLn
err
undefined
Right
phylo
->
pure
phylo
-- | To read and decode a Json file
readJson
::
FilePath
->
IO
Lazy
.
ByteString
readJson
path
=
Lazy
.
readFile
path
src/Gargantext/Core/Viz/Phylo/
Phylo
Example.hs
→
src/Gargantext/Core/Viz/Phylo/Example.hs
View file @
515e9ba3
...
...
@@ -13,7 +13,7 @@ Portability : POSIX
-}
module
Gargantext.Core.Viz.Phylo.
Phylo
Example
where
module
Gargantext.Core.Viz.Phylo.Example
where
import
Control.Lens
import
Data.GraphViz.Types.Generalised
(
DotGraph
)
...
...
@@ -39,14 +39,14 @@ phyloExport :: IO ()
phyloExport
=
dotToFile
"/home/qlobbe/data/phylo/output/cesar_cleopatre_V2.dot"
phyloDot
phyloDot
::
DotGraph
DotId
phyloDot
=
toPhyloExport
phylo
2
phyloDot
=
toPhyloExport
phylo
Example
--------------------------------------------------
-- | STEP 4 | -- Process the synchronic clustering
--------------------------------------------------
phylo
2
::
Phylo
phylo
2
=
synchronicClustering
$
toHorizon
phylo1
phylo
Example
::
Phylo
phylo
Example
=
synchronicClustering
$
toHorizon
phylo1
-----------------------------------------------
-- | STEP 3 | -- Build the Level 1 of the Phylo
...
...
src/Gargantext/Core/Viz/Phylo/Legacy/LegacyAPI.hs
deleted
100644 → 0
View file @
40967e89
{-|
Module : Gargantext.Core.Viz.Phylo.API
Description : Phylo API
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE OverloadedLists #-}
-- allows to write Map and HashMap as lists
{-# LANGUAGE TypeOperators #-}
module
Gargantext.Core.Viz.Phylo.Legacy.LegacyAPI
where
-- import Data.Maybe (fromMaybe)
-- import Control.Lens ((^.))
--import Control.Monad.Reader (ask)
import
qualified
Data.ByteString
as
DB
import
qualified
Data.ByteString.Lazy
as
DBL
import
Data.Swagger
import
Network.HTTP.Media
((
//
),
(
/:
))
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Web.HttpApiData
(
readTextData
)
import
Gargantext.API.Prelude
import
Gargantext.Database.Admin.Types.Hyperdata
import
Gargantext.Database.Admin.Types.Node
-- (PhyloId, ListId, CorpusId, UserId, NodeId(..))
import
Gargantext.Database.Query.Table.Node
(
insertNodes
,
node
)
-- import Gargantext.Database.Schema.Node (node_hyperdata)
import
Gargantext.Prelude
import
Gargantext.Core.Viz.LegacyPhylo
import
Gargantext.Core.Viz.Phylo.Legacy.LegacyMain
import
Gargantext.Core.Viz.Phylo.API
import
Gargantext.Core.Viz.Phylo
(
defaultConfig
)
-- import Gargantext.Core.Viz.Phylo.Example
import
Gargantext.Core.Types
(
TODO
(
..
))
import
Data.Either
------------------------------------------------------------------------
type
PhyloAPI
=
Summary
"Phylo API"
:>
GetPhylo
-- :<|> PutPhylo
:<|>
PostPhylo
phyloAPI
::
PhyloId
->
UserId
->
GargServer
PhyloAPI
phyloAPI
n
u
=
getPhylo
n
:<|>
postPhylo
n
u
-- :<|> putPhylo n
-- :<|> deletePhylo n
newtype
SVG
=
SVG
DB
.
ByteString
instance
ToSchema
SVG
where
declareNamedSchema
_
=
declareNamedSchema
(
Proxy
::
Proxy
TODO
)
instance
Show
SVG
where
show
(
SVG
a
)
=
show
a
instance
Accept
SVG
where
contentType
_
=
"SVG"
//
"image/svg+xml"
/:
(
"charset"
,
"utf-8"
)
--instance Show a => MimeRender PlainText a where
-- mimeRender _ val = cs ("" <> show val)
instance
MimeRender
SVG
SVG
where
mimeRender
_
(
SVG
s
)
=
DBL
.
fromStrict
s
instance
MimeUnrender
SVG
SVG
where
mimeUnrender
_
lbs
=
Right
$
SVG
(
DBL
.
toStrict
lbs
)
------------------------------------------------------------------------
type
GetPhylo
=
QueryParam
"listId"
ListId
:>
QueryParam
"level"
Level
:>
QueryParam
"minSizeBranch"
MinSizeBranch
{- :> QueryParam "filiation" Filiation
:> QueryParam "childs" Bool
:> QueryParam "depth" Level
:> QueryParam "metrics" [Metric]
:> QueryParam "periodsInf" Int
:> QueryParam "periodsSup" Int
:> QueryParam "minNodes" Int
:> QueryParam "taggers" [Tagger]
:> QueryParam "sort" Sort
:> QueryParam "order" Order
:> QueryParam "export" ExportMode
:> QueryParam "display" DisplayMode
:> QueryParam "verbose" Bool
-}
:>
Get
'[
S
VG
]
SVG
-- | TODO
-- Add real text processing
-- Fix Filter parameters
getPhylo
::
PhyloId
->
GargServer
GetPhylo
getPhylo
_
_lId
_
_
=
undefined
-- getPhylo phId _lId l msb = do
-- phNode <- getNodeWith phId (Proxy :: Proxy HyperdataPhylo)
-- let
-- level = fromMaybe 2 l
-- branc = fromMaybe 2 msb
-- maybePhylo = phNode ^. (node_hyperdata . hp_data)
-- p <- liftBase $ viewPhylo2Svg
-- $ viewPhylo level branc
-- $ fromMaybe phyloFromQuery maybePhylo
-- pure (SVG p)
------------------------------------------------------------------------
type
PostPhylo
=
QueryParam
"listId"
ListId
-- :> ReqBody '[JSON] PhyloQueryBuild
:>
(
Post
'[
J
SON
]
NodeId
)
postPhylo
::
CorpusId
->
UserId
->
GargServer
PostPhylo
postPhylo
corpusId
userId
_lId
=
do
-- TODO get Reader settings
-- s <- ask
-- let
-- _vrs = Just ("1" :: Text)
-- _sft = Just (Software "Gargantext" "4")
-- _prm = initPhyloParam vrs sft (Just q)
phy
<-
flowPhyloAPI
defaultConfig
corpusId
-- params
phyloId
<-
insertNodes
[
node
NodePhylo
"Phylo"
(
HyperdataPhylo
Nothing
(
Just
phy
))
(
Just
corpusId
)
userId
]
pure
$
NodeId
(
fromIntegral
phyloId
)
------------------------------------------------------------------------
-- | DELETE Phylo == delete a node
------------------------------------------------------------------------
------------------------------------------------------------------------
{-
type PutPhylo = (Put '[JSON] Phylo )
--putPhylo :: PhyloId -> Maybe ListId -> PhyloQueryBuild -> Phylo
putPhylo :: PhyloId -> GargServer PutPhylo
putPhylo = undefined
-}
-- | Instances
-- instance Arbitrary Phylo where arbitrary = elements [phylo]
instance
Arbitrary
PhyloGroup
where
arbitrary
=
elements
[]
-- instance Arbitrary PhyloView where arbitrary = elements [phyloView]
instance
FromHttpApiData
DisplayMode
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
ExportMode
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Filiation
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Metric
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Order
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Sort
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
Tagger
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
[
Metric
]
where
parseUrlPiece
=
readTextData
instance
FromHttpApiData
[
Tagger
]
where
parseUrlPiece
=
readTextData
instance
ToParamSchema
DisplayMode
instance
ToParamSchema
ExportMode
instance
ToParamSchema
Filiation
instance
ToParamSchema
Tagger
instance
ToParamSchema
Metric
instance
ToParamSchema
Order
instance
ToParamSchema
Sort
instance
ToSchema
Order
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment