Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BotanyPilot
Manage
Activity
Members
Labels
Plan
Issues
6
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CETAF
BotanyPilot
Merge requests
!19
Added /v1
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Added /v1
dev
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Ernst, Marcus
requested to merge
dev
into
master
3 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
👍
0
👎
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
49c72287
1 commit,
3 years ago
1 file
+
62
−
100
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
api/v1/src/bpapi.php
+
62
−
100
Options
@@ -16,106 +16,68 @@ $queryManager = function ($request, $response, $next) {
return
$response
;
};
$app
->
group
(
'/bpapi'
,
function
(){
$this
->
get
(
'/all/{id}'
,
function
(
$request
,
$response
,
$args
){
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$qmo
->
setId
(
$collector
);
$result
=
$qmo
->
all
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
return
$request
;
});
$this
->
get
(
'/collection/{id}'
,
function
(
$request
,
$response
,
$args
){
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$qmo
->
setId
(
$collector
);
$result
=
$qmo
->
collection
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
return
$request
;
});
$this
->
get
(
'/biography/{id}'
,
function
(
$request
,
$response
,
$args
){
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$qmo
->
setId
(
$collector
);
$result
=
$qmo
->
biography
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
return
$request
;
});
$this
->
get
(
'/bibliography/{id}'
,
function
(
$request
,
$response
,
$args
){
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$qmo
->
setId
(
$collector
);
$result
=
$qmo
->
bibliography
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
return
$request
;
});
$this
->
get
(
'/collector/{id}'
,
function
(
$request
,
$response
,
$args
){
#$response->getBody()->write('Test started<br>');
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$result
=
$qmo
->
collector
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
#### RDF to JSON-LD ####
#$new = new \ML\JsonLD\JsonLD();
#$result = $new->fromRdf($result);
/*
$context = json_encode(array('@context' => array('@vocab' => 'http://schema.org/')));
$new = new \ML\JsonLD\JsonLD();
$expanded = $new->compact($result, $context);
$result = $expanded;
$result = $new->toString($expanded, true);
header('Content-Type: application/json');
echo $result;
#$result = json_decode($result);
*/
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
#var_dump($testResult);
#$route = $request->getAttribute('route');
#var_dump($route->getArguments()); # get collector id
#$response->getBody()->write('FIRST ');
#return $request;
$app
->
group
(
'/api'
,
function
(){
$this
->
group
(
'/v1'
,
function
(){
$this
->
get
(
'/all/{id}'
,
function
(
$request
,
$response
,
$args
){
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$qmo
->
setId
(
$collector
);
$result
=
$qmo
->
all
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
return
$request
;
});
$this
->
get
(
'/collection/{id}'
,
function
(
$request
,
$response
,
$args
){
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$qmo
->
setId
(
$collector
);
$result
=
$qmo
->
collection
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
return
$request
;
});
$this
->
get
(
'/biography/{id}'
,
function
(
$request
,
$response
,
$args
){
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$qmo
->
setId
(
$collector
);
$result
=
$qmo
->
biography
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
return
$request
;
});
$this
->
get
(
'/bibliography/{id}'
,
function
(
$request
,
$response
,
$args
){
$qmo
=
$request
->
getAttribute
(
'queryManagerObject'
);
$collector
=
$request
->
getAttribute
(
'id'
);
$qmo
->
setId
(
$collector
);
$result
=
$qmo
->
bibliography
(
$collector
);
$result
=
json_encode
(
$result
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_SLASHES
|
JSON_UNESCAPED_UNICODE
);
if
(
!
isset
(
$result
))
{
return
$response
->
withJSON
([
"status"
=>
"404 - Not found"
],
404
);
}
return
$response
->
withJSON
([
"status"
=>
"200 - Ok"
,
"result"
=>
json_decode
(
$result
)])
->
withHeader
(
'Content-Type'
,
'application/ld+json'
);
return
$request
;
});
});
})
->
add
(
$queryManager
);
Loading