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
8847132d
Commit
8847132d
authored
Jul 03, 2014
by
Matija Obreza
Browse files
Redirect to /explore with filters where possible
Added "species" filter
parent
091eac8f
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/persistence/domain/Taxonomy2Repository.java
View file @
8847132d
...
...
@@ -28,6 +28,9 @@ public interface Taxonomy2Repository extends JpaRepository<Taxonomy2, Long> {
@Query
(
"select distinct t.genus from Taxonomy2 t where t.genus like ?1"
)
List
<
String
>
autocompleteGenus
(
String
term
,
Pageable
page
);
@Query
(
"select distinct t.species from Taxonomy2 t where t.species like ?1"
)
List
<
String
>
autocompleteSpecies
(
String
term
,
Pageable
page
);
@Query
(
"select distinct t.taxonName from Taxonomy2 t where t.taxonName like ?1"
)
List
<
String
>
autocompleteTaxonomy
(
String
term
,
Pageable
page
);
...
...
@@ -38,4 +41,5 @@ public interface Taxonomy2Repository extends JpaRepository<Taxonomy2, Long> {
List
<
Taxonomy2
>
findByGenusAndSpecies
(
String
genus
,
String
species
);
List
<
Taxonomy2
>
findByGenusAndSpeciesAndSubtaxa
(
String
genus
,
String
species
,
String
subtaxa
);
}
src/main/java/org/genesys2/server/service/TaxonomyService.java
View file @
8847132d
...
...
@@ -24,6 +24,8 @@ public interface TaxonomyService {
List
<
String
>
autocompleteGenus
(
String
term
);
List
<
String
>
autocompleteSpecies
(
String
term
);
List
<
String
>
autocompleteTaxonomy
(
String
term
);
long
getTaxonomy2Id
(
String
genus
);
...
...
@@ -36,4 +38,7 @@ public interface TaxonomyService {
Taxonomy2
get
(
Long
id
);
Taxonomy2
get
(
String
genus
,
String
species
);
}
src/main/java/org/genesys2/server/service/impl/DirectMysqlQuery.java
View file @
8847132d
...
...
@@ -73,7 +73,7 @@ public class DirectMysqlQuery {
}
protected
DirectMysqlQuery
join
(
ObjectNode
jsonTree
)
{
if
(
hasFilter
(
jsonTree
,
"crop"
)
||
hasFilter
(
jsonTree
,
"genus"
)
||
hasFilter
(
jsonTree
,
"taxon"
))
{
if
(
hasFilter
(
jsonTree
,
"crop"
)
||
hasFilter
(
jsonTree
,
"genus"
)
||
hasFilter
(
jsonTree
,
"species"
)
||
hasFilter
(
jsonTree
,
"taxon"
))
{
innerJoin
(
"taxonomy2"
,
"t"
,
"t.id=a.taxonomyId2"
);
if
(
hasFilter
(
jsonTree
,
"crop"
))
{
innerJoin
(
"croptaxonomy"
,
"ct"
,
"ct.taxonomyId=t.id"
);
...
...
@@ -112,6 +112,7 @@ public class DirectMysqlQuery {
createQuery
(
whereBuffer
,
"a.available"
,
jsonTree
.
get
(
"available"
),
params
);
createQuery
(
whereBuffer
,
"org.slug"
,
jsonTree
.
get
(
"organization"
),
params
);
createQuery
(
whereBuffer
,
"t.genus"
,
jsonTree
.
get
(
"genus"
),
params
);
createQuery
(
whereBuffer
,
"t.species"
,
jsonTree
.
get
(
"species"
),
params
);
createQuery
(
whereBuffer
,
"t.taxonName"
,
jsonTree
.
get
(
"taxon"
),
params
);
createQuery
(
whereBuffer
,
"geo.longitude"
,
jsonTree
.
get
(
"longitude"
),
params
);
createQuery
(
whereBuffer
,
"geo.latitude"
,
jsonTree
.
get
(
"latitude"
),
params
);
...
...
src/main/java/org/genesys2/server/service/impl/GenesysFilterServiceImpl.java
View file @
8847132d
...
...
@@ -110,6 +110,7 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
this
.
availableFilters
.
add
(
new
GenesysI18nListFilterImpl
<
Integer
>(
"sampStat"
,
DataType
.
NUMERIC
).
build
(
"accession.sampleStatus"
,
new
Integer
[]
{
100
,
110
,
120
,
130
,
200
,
300
,
400
,
410
,
411
,
412
,
413
,
414
,
415
,
416
,
420
,
421
,
422
,
423
,
500
,
600
,
999
}));
this
.
availableFilters
.
add
(
new
GenesysAutocompleteFilterImpl
(
"genus"
,
"/explore/ac/genus"
));
this
.
availableFilters
.
add
(
new
GenesysAutocompleteFilterImpl
(
"species"
,
"/explore/ac/species"
));
this
.
availableFilters
.
add
(
new
GenesysAutocompleteFilterImpl
(
"taxon"
,
"/explore/ac/taxonomy"
));
this
.
availableFilters
.
add
(
new
GenesysAutocompleteFilterImpl
(
"orgCty"
,
"/explore/ac/country"
));
...
...
@@ -227,6 +228,9 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
*/
@Override
public
List
<
LabelValue
<
String
>>
autocomplete
(
String
filter
,
String
ac
)
{
if
(
LOG
.
isDebugEnabled
())
LOG
.
debug
(
"Autocomplete "
+
filter
+
" ac="
+
ac
);
List
<
LabelValue
<
String
>>
completed
=
new
ArrayList
<
LabelValue
<
String
>>();
if
(
"instCode"
.
equalsIgnoreCase
(
filter
))
{
List
<
FaoInstitute
>
faoInst
=
searchService
.
autocomplete
(
ac
,
FaoInstitute
.
class
);
...
...
@@ -240,8 +244,13 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
}
}
else
if
(
"genus"
.
equalsIgnoreCase
(
filter
))
{
List
<
String
>
genera
=
taxonomyService
.
autocompleteGenus
(
ac
);
for
(
String
genus
:
genera
)
{
completed
.
add
(
new
LabelValue
<
String
>(
genus
,
genus
));
for
(
String
value
:
genera
)
{
completed
.
add
(
new
LabelValue
<
String
>(
value
,
value
));
}
}
else
if
(
"species"
.
equalsIgnoreCase
(
filter
))
{
List
<
String
>
species
=
taxonomyService
.
autocompleteSpecies
(
ac
);
for
(
String
value
:
species
)
{
completed
.
add
(
new
LabelValue
<
String
>(
value
,
value
));
}
}
else
if
(
"taxonomy"
.
equalsIgnoreCase
(
filter
))
{
List
<
String
>
taxa
=
taxonomyService
.
autocompleteTaxonomy
(
ac
);
...
...
src/main/java/org/genesys2/server/service/impl/TaxonomyServiceImpl.java
View file @
8847132d
...
...
@@ -49,6 +49,11 @@ public class TaxonomyServiceImpl implements TaxonomyService {
return
taxonomy2Repository
.
autocompleteGenus
(
term
+
"%"
,
new
PageRequest
(
0
,
10
));
}
@Override
public
List
<
String
>
autocompleteSpecies
(
String
term
)
{
return
taxonomy2Repository
.
autocompleteSpecies
(
term
+
"%"
,
new
PageRequest
(
0
,
10
));
}
@Override
public
List
<
String
>
autocompleteTaxonomy
(
String
term
)
{
return
taxonomy2Repository
.
autocompleteTaxonomy
(
"%"
+
term
+
"%"
,
new
PageRequest
(
0
,
10
));
...
...
@@ -94,10 +99,10 @@ public class TaxonomyServiceImpl implements TaxonomyService {
Taxonomy2
speciesTaxa
=
internalEnsure
(
genus
,
species
,
""
,
""
,
""
);
taxSpeciesId
=
speciesTaxa
.
getId
();
taxGenusId
=
speciesTaxa
.
getTaxGenus
();
}
else
if
(!
StringUtils
.
equals
(
species
,
"sp."
)
&&
(
subtaxa
.
equals
(
""
)
&&
spAuthor
.
equals
(
""
)
&&
subtAuthor
.
equals
(
""
)))
{
}
else
if
(!
StringUtils
.
equals
(
species
,
"sp."
)
&&
(
subtaxa
.
equals
(
""
)
&&
spAuthor
.
equals
(
""
)
&&
subtAuthor
.
equals
(
""
)))
{
Taxonomy2
genusTaxa
=
internalEnsure
(
genus
,
"sp."
,
""
,
""
,
""
);
taxGenusId
=
genusTaxa
.
getId
();
taxSpeciesId
=
genusTaxa
.
getId
();
taxSpeciesId
=
genusTaxa
.
getId
();
}
// Loop it a bit if required
...
...
@@ -159,6 +164,11 @@ public class TaxonomyServiceImpl implements TaxonomyService {
return
tax
.
getId
();
}
@Override
public
Taxonomy2
get
(
String
genus
,
String
species
)
{
return
taxonomy2Repository
.
findByGenusAndSpeciesAndSpAuthorAndSubtaxaAndSubtAuthor
(
genus
,
species
,
""
,
""
,
""
);
}
@Override
public
long
countTaxonomy2
()
{
return
taxonomy2Repository
.
count
();
...
...
src/main/java/org/genesys2/server/servlet/controller/ExplorerController.java
View file @
8847132d
...
...
@@ -226,7 +226,7 @@ public class ExplorerController extends BaseController {
@RequestMapping
(
value
=
"/explore/ac/{field}"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@ResponseBody
public
List
<
LabelValue
<
String
>>
autocomplete
(
@PathVariable
(
"field"
)
String
filter
,
@RequestParam
(
value
=
"term"
,
required
=
fals
e
)
String
ac
)
{
public
List
<
LabelValue
<
String
>>
autocomplete
(
@PathVariable
(
"field"
)
String
filter
,
@RequestParam
(
value
=
"term"
,
required
=
tru
e
)
String
ac
)
{
return
filterService
.
autocomplete
(
filter
,
ac
);
}
...
...
src/main/java/org/genesys2/server/servlet/controller/OrganizationController.java
View file @
8847132d
...
...
@@ -18,11 +18,9 @@ package org.genesys2.server.servlet.controller;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Locale
;
import
org.genesys2.server.model.genesys.Accession
;
import
org.genesys2.server.model.impl.FaoInstitute
;
import
org.genesys2.server.model.impl.Organization
;
import
org.genesys2.server.service.ContentService
;
...
...
@@ -32,7 +30,6 @@ import org.genesys2.server.service.OrganizationService;
import
org.genesys2.server.service.TaxonomyService
;
import
org.genesys2.spring.ResourceNotFoundException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.security.access.prepost.PreAuthorize
;
...
...
@@ -147,27 +144,18 @@ public class OrganizationController extends BaseController {
return
"redirect:/org/"
+
organization
.
getSlug
();
}
@RequestMapping
(
"/{
wiewsCode
}/data"
)
public
String
viewData
(
ModelMap
model
,
@PathVariable
(
value
=
"
wiewsCode
"
)
String
s
lug
,
@RequestMapping
(
"/{
orgSlug
}/data"
)
public
String
viewData
(
ModelMap
model
,
@PathVariable
(
value
=
"
orgSlug
"
)
String
orgS
lug
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
)
{
_logger
.
debug
(
"Viewing organization "
+
s
lug
);
Organization
organization
=
organizationService
.
getOrganization
(
s
lug
);
_logger
.
debug
(
"Viewing organization "
+
orgS
lug
);
Organization
organization
=
organizationService
.
getOrganization
(
orgS
lug
);
if
(
organization
==
null
)
{
throw
new
ResourceNotFoundException
();
}
_logger
.
warn
(
"Searching accessions of: "
+
organization
);
Page
<
Accession
>
accessions
=
genesysService
.
listAccessionsByOrganization
(
organization
,
new
PageRequest
(
page
-
1
,
50
,
new
Sort
(
"accessionName"
)));
_logger
.
info
(
"Got: "
+
accessions
);
model
.
addAttribute
(
"pagedData"
,
accessions
);
HashMap
<
Object
,
Object
>
filters
=
new
HashMap
<
Object
,
Object
>();
filters
.
put
(
"filter.organization"
,
organization
);
model
.
addAttribute
(
"filters"
,
filters
);
model
.
addAttribute
(
"jsonFilter"
,
"{\"organization\":[\""
+
organization
.
getSlug
()
+
"\"]}"
);
return
"/accession/explore"
;
model
.
addAttribute
(
"filter"
,
"{\"organization\":[\""
+
organization
.
getSlug
()
+
"\"]}"
);
model
.
addAttribute
(
"page"
,
page
);
return
"redirect:/explore"
;
}
}
src/main/java/org/genesys2/server/servlet/controller/WiewsController.java
View file @
8847132d
...
...
@@ -23,7 +23,7 @@ import java.util.Map;
import
javax.servlet.http.HttpServletResponse
;
import
org.genesys2.server.model.genesys.
Accession
;
import
org.genesys2.server.model.genesys.
Taxonomy2
;
import
org.genesys2.server.model.impl.FaoInstitute
;
import
org.genesys2.server.service.ContentService
;
import
org.genesys2.server.service.GenesysService
;
...
...
@@ -160,18 +160,9 @@ public class WiewsController extends BaseController {
throw
new
ResourceNotFoundException
();
}
_logger
.
warn
(
"Searching accessions of: "
+
faoInstitute
);
Page
<
Accession
>
accessions
=
genesysService
.
listAccessionsByInstitute
(
faoInstitute
,
new
PageRequest
(
page
-
1
,
50
,
new
Sort
(
"accessionName"
)));
_logger
.
info
(
"Got: "
+
accessions
);
model
.
addAttribute
(
"pagedData"
,
accessions
);
HashMap
<
Object
,
Object
>
filters
=
new
HashMap
<
Object
,
Object
>();
filters
.
put
(
"filter.holdingInstitute"
,
faoInstitute
);
model
.
addAttribute
(
"filters"
,
filters
);
model
.
addAttribute
(
"jsonFilter"
,
"{\"instCode\":[\""
+
faoInstitute
.
getCode
()
+
"\"]}"
);
return
"/accession/explore"
;
model
.
addAttribute
(
"filter"
,
"{\"instCode\":[\""
+
faoInstitute
.
getCode
()
+
"\"]}"
);
model
.
addAttribute
(
"page"
,
page
);
return
"redirect:/explore"
;
}
@RequestMapping
(
"/{wiewsCode}/t/{genus}/{species:.+}"
)
...
...
@@ -182,26 +173,18 @@ public class WiewsController extends BaseController {
if
(
faoInstitute
==
null
)
{
throw
new
ResourceNotFoundException
();
}
model
.
addAttribute
(
"faoInstitute"
,
faoInstitute
);
// Taxonomy
long
taxonomyId
=
taxonomyService
.
getTaxonomy2Id
(
genus
,
species
);
_logger
.
debug
(
"Got "
+
taxonomyId
);
_logger
.
warn
(
"Searching accessions of: "
+
faoInstitute
);
Page
<
Accession
>
accessions
=
genesysService
.
listAccessionsByInstituteAndSpecies
(
faoInstitute
,
taxonomyId
,
new
PageRequest
(
page
-
1
,
50
,
new
Sort
(
"accessionName"
)));
_logger
.
info
(
"Got: "
+
accessions
);
model
.
addAttribute
(
"pagedData"
,
accessions
);
HashMap
<
Object
,
Object
>
filters
=
new
HashMap
<
Object
,
Object
>();
filters
.
put
(
"filter.taxonomy"
,
taxonomyId
);
filters
.
put
(
"filter.holdingInstitute"
,
faoInstitute
);
model
.
addAttribute
(
"filters"
,
filters
);
model
.
addAttribute
(
"jsonFilter"
,
"{\"instCode\":[\""
+
faoInstitute
.
getCode
()
+
"\"],\"species\":[\""
+
taxonomyId
+
"\"]}"
);
Taxonomy2
taxonomy2
=
taxonomyService
.
get
(
genus
,
species
);
if
(
taxonomy2
==
null
)
{
throw
new
ResourceNotFoundException
();
}
_logger
.
debug
(
"Got "
+
taxonomy2
);
return
"/accession/explore"
;
model
.
addAttribute
(
"filter"
,
"{\"instCode\":[\""
+
faoInstitute
.
getCode
()
+
"\"],\"genus\":[\""
+
taxonomy2
.
getGenus
()
+
"\"],\"species\":[\""
+
taxonomy2
.
getSpecies
()
+
"\"]}"
);
model
.
addAttribute
(
"page"
,
page
);
return
"redirect:/explore"
;
}
@RequestMapping
(
value
=
"/{wiewsCode}/dwca"
,
method
=
RequestMethod
.
POST
)
...
...
src/main/resources/content/language.properties
View file @
8847132d
...
...
@@ -331,6 +331,7 @@ filter.latitude=Latitude
filter.longitude
=
Longitude
filter.elevation
=
Elevation
filter.genus
=
Genus
filter.species
=
Species
filter.taxSpecies
=
Species
filter.taxon
=
Taxonomical name
filter.inSvalbard
=
Safety duplicated in Svalbard
...
...
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