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
4266167e
Commit
4266167e
authored
Oct 08, 2015
by
Matija Obreza
Browse files
Rationalization of maps query
parent
3364bd31
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/service/FilterConstants.java
View file @
4266167e
...
...
@@ -64,6 +64,9 @@ public interface FilterConstants {
public
static
final
String
INSTITUTE_COUNTRY_ISO3
=
"institute.country.iso3"
;
/// Used in mapping library
public
static
final
String
INSTITUTE_COUNTRY_ISO2
=
"institute.country.iso2"
;
public
static
final
String
INSTITUTE_NETWORK
=
"institute.networks"
;
public
static
final
String
IN_SGSV
=
"inSgsv"
;
...
...
@@ -73,4 +76,5 @@ public interface FilterConstants {
public
static
final
String
HISTORIC
=
"historic"
;
public
static
final
String
SEQUENTIAL_NUMBER
=
"seqNo"
;
}
src/main/java/org/genesys2/server/servlet/controller/AccessionsWorldMapController.java
View file @
4266167e
package
org.genesys2.server.servlet.controller
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.genesys2.server.service.ElasticService
;
import
org.genesys2.server.service.FilterConstants
;
import
org.genesys2.server.service.GeoService
;
import
org.genesys2.server.service.impl.FilterHandler.AppliedFilters
;
import
org.genesys2.server.service.impl.SearchException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.elasticsearch.core.facet.result.Term
;
import
org.springframework.data.elasticsearch.core.facet.result.TermResult
;
import
org.springframework.http.MediaType
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.fasterxml.jackson.core.JsonParseException
;
import
com.fasterxml.jackson.databind.JsonMappingException
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
@Controller
@RequestMapping
(
"/charts"
)
public
class
AccessionsWorldMapController
extends
BaseController
{
@RequestMapping
(
"/charts/collections"
)
public
String
chartsCollection
(){
return
"/charts/collection"
;
}
@RequestMapping
(
value
=
"/data"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@ResponseBody
()
public
List
<
Map
<
String
,
Object
>>
accessionsCollection
(){
List
<
Map
<
String
,
Object
>>
resultList
=
new
ArrayList
<>();
Map
<
String
,
Object
>
countryInfo
=
new
HashMap
<>();
countryInfo
.
put
(
"code"
,
"AF"
);
countryInfo
.
put
(
"country"
,
"Afghanistan"
);
countryInfo
.
put
(
"z"
,
30552
);
resultList
.
add
(
countryInfo
);
countryInfo
=
new
HashMap
<>();
countryInfo
.
put
(
"code"
,
"AL"
);
countryInfo
.
put
(
"country"
,
"Albania"
);
countryInfo
.
put
(
"z"
,
28907
);
resultList
.
add
(
countryInfo
);
countryInfo
=
new
HashMap
<>();
countryInfo
.
put
(
"code"
,
"US"
);
countryInfo
.
put
(
"country"
,
"USA"
);
countryInfo
.
put
(
"z"
,
289070
);
resultList
.
add
(
countryInfo
);
return
resultList
;
}
@Autowired
private
ElasticService
elasticService
;
@Autowired
private
GeoService
geoService
;
@Autowired
private
ObjectMapper
mapper
;
@RequestMapping
(
"/collections"
)
public
String
chartsCollection
()
{
return
"/charts/collection"
;
}
@RequestMapping
(
value
=
"/collections/data"
,
method
=
RequestMethod
.
GET
,
produces
=
{
MediaType
.
APPLICATION_JSON_VALUE
})
@ResponseBody
public
List
<
Map
<
String
,
Object
>>
accessionsCollection
(
@RequestParam
(
value
=
"filter"
,
required
=
false
,
defaultValue
=
"{}"
)
String
jsonFilter
)
throws
JsonParseException
,
JsonMappingException
,
IOException
,
SearchException
{
AppliedFilters
appliedFilters
=
mapper
.
readValue
(
jsonFilter
,
AppliedFilters
.
class
);
// Load all term results
TermResult
countryStatistics
=
elasticService
.
termStatisticsAuto
(
appliedFilters
,
FilterConstants
.
INSTITUTE_COUNTRY_ISO2
,
Integer
.
MAX_VALUE
);
List
<
Map
<
String
,
Object
>>
resultList
=
new
ArrayList
<>();
for
(
Term
term
:
countryStatistics
.
getTerms
())
{
Map
<
String
,
Object
>
countryInfo
=
new
HashMap
<>();
// ISO2 country code needs to be upper-case for highcharts library
countryInfo
.
put
(
"code"
,
term
.
getTerm
().
toUpperCase
());
countryInfo
.
put
(
"country"
,
geoService
.
getCountry
(
term
.
getTerm
()).
getName
(
getLocale
()));
countryInfo
.
put
(
"z"
,
term
.
getCount
());
resultList
.
add
(
countryInfo
);
}
return
resultList
;
}
}
src/main/resources/content/language.properties
View file @
4266167e
...
...
@@ -692,3 +692,7 @@ see-also.overview=Overview of the collection
see-also.country
=
More about PGR conservation in {0}
help.page.intro
=
Visit the tutorials section to learn how to use Genesys.
chart.collections.title
=
Accessions in genebanks around the world
chart.attribution-text
=
www.genesys-pgr.org ©
chart.collections.series
=
Number of accessions in genebanks
src/main/webapp/WEB-INF/jsp/charts/collection.jsp
View file @
4266167e
...
...
@@ -12,7 +12,7 @@
$
(
function
()
{
'
use strict
'
;
$
.
getJSON
(
'
/data
'
,
function
(
data
)
{
$
.
getJSON
(
'
/
${pageContext.response.locale}/charts/collections/
data
'
,
function
(
data
)
{
var
mapData
=
Highcharts
.
geojson
(
Highcharts
.
maps
[
'
custom/world
'
]);
$
(
'
#container
'
).
highcharts
(
'
Map
'
,
{
...
...
@@ -21,11 +21,11 @@
},
title
:
{
text
:
'
Accessions in genebanks around the world
'
text
:
'
<spring:message
code=
"chart.collections.title"
/>
'
},
subtitle
:
{
text
:
'
Genesys data 2015
'
text
:
'
<spring:message
code=
"chart.attribution-text"
/>
'
},
legend
:
{
...
...
@@ -47,9 +47,10 @@
},
{
type
:
'
mapbubble
'
,
mapData
:
mapData
,
name
:
'
Number of accessions in genebanks
'
,
name
:
'
<spring:message
code=
"chart.collections.series"
/>
'
,
joinBy
:
[
'
iso-a2
'
,
'
code
'
],
data
:
data
,
color
:
'
#88ba42
'
,
minSize
:
20
,
maxSize
:
'
12%
'
,
tooltip
:
{
...
...
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