Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
1469bb55
Commit
1469bb55
authored
Mar 18, 2015
by
Matija Obreza
Browse files
WebAPI: Added support for /v0/acn/overview with filters
parent
b7c71acd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/servlet/controller/webapi/WebApiController.java
View file @
1469bb55
...
...
@@ -17,9 +17,12 @@
package
org.genesys2.server.servlet.controller.webapi
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.genesys2.server.model.elastic.AccessionDetails
;
import
org.genesys2.server.service.ElasticService
;
import
org.genesys2.server.service.FilterConstants
;
import
org.genesys2.server.service.GenesysService
;
import
org.genesys2.server.service.impl.FilterHandler.AppliedFilters
;
import
org.genesys2.server.service.impl.SearchException
;
...
...
@@ -30,6 +33,7 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.elasticsearch.core.facet.result.TermResult
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
...
...
@@ -56,6 +60,18 @@ public class WebApiController extends RestController {
@Autowired
private
ElasticService
elasticService
;
/**
* To be removed. Use the scripts /html/js/webapi.js or
* /html/js/webapi.min.js
*
* @param model
* @param clientId
* @param clientSecret
* @return
* @deprecated To be removed in May 2015
*/
// TODO Remove
@Deprecated
@RequestMapping
(
value
=
"/genesys-webapi.js"
,
method
=
RequestMethod
.
GET
)
public
String
getScript
(
ModelMap
model
,
@RequestParam
(
"client_id"
)
String
clientId
,
@RequestParam
(
value
=
"client_secret"
,
required
=
false
)
String
clientSecret
)
{
...
...
@@ -78,6 +94,36 @@ public class WebApiController extends RestController {
return
accessions
;
}
@RequestMapping
(
value
=
"/v0/acn/overview"
,
method
=
RequestMethod
.
POST
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ResponseBody
public
Map
<
String
,
TermResult
>
overview
(
@RequestBody
String
filters
)
throws
IOException
,
SearchException
{
AppliedFilters
appliedFilters
=
mapper
.
readValue
(
filters
,
AppliedFilters
.
class
);
Map
<
String
,
TermResult
>
overview
=
new
HashMap
<
String
,
TermResult
>();
overview
.
put
(
"statsInstCode"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
INSTCODE
,
20
));
overview
.
put
(
"statsInstCountry"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
INSTITUTE_COUNTRY_ISO3
,
20
));
overview
.
put
(
"statsOrgCty"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
ORGCTY_ISO3
,
20
));
overview
.
put
(
"statsDonorCode"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
DONORCODE
,
20
));
overview
.
put
(
"statsMLS"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
MLSSTATUS
,
2
));
overview
.
put
(
"statsAvailable"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
AVAILABLE
,
2
));
overview
.
put
(
"statsHistoric"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
HISTORIC
,
2
));
overview
.
put
(
"statsStorage"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
STORAGE
,
30
));
overview
.
put
(
"statsDuplSite"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
DUPLSITE
,
20
));
overview
.
put
(
"statsSGSV"
,
elasticService
.
termStatistics
(
appliedFilters
,
FilterConstants
.
SGSV
,
2
));
overview
.
put
(
"statsGenus"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
TAXONOMY_GENUS
,
20
));
overview
.
put
(
"statsSpecies"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
TAXONOMY_GENUSSPECIES
,
20
));
overview
.
put
(
"statsCrops"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
CROPS
,
30
));
overview
.
put
(
"statsSampStat"
,
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
SAMPSTAT
,
30
));
return
overview
;
}
public
static
class
JsonData
{
public
String
filter
=
""
;
public
Integer
startAt
=
1
;
...
...
src/main/webapp/html/js/webapi.js
View file @
1469bb55
...
...
@@ -38,3 +38,22 @@ GenesysPGR.prototype.listAccessions = function (filter, opts) {
}
});
};
GenesysPGR
.
prototype
.
overview
=
function
(
filter
,
opts
)
{
var
o
=
$
.
extend
({},
GenesysPGR
.
defaultOptions
,
opts
);
$
.
ajax
(
this
.
getUrl
(
'
/v0/acn/overview
'
),
{
dataType
:
'
json
'
,
type
:
'
POST
'
,
contentType
:
'
application/json; charset=utf-8
'
,
data
:
JSON
.
stringify
(
filter
),
success
:
function
(
accessions
)
{
o
.
success
(
accessions
);
},
error
:
function
(
errorAsync
)
{
o
.
error
(
errorAsync
);
}
});
};
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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