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
b10395a0
Commit
b10395a0
authored
Sep 17, 2013
by
Matija Obreza
Browse files
Make institute statistics pageable
parent
a79de6bc
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/crophub/rest/common/persistence/domain/AccessionRepository.java
View file @
b10395a0
...
...
@@ -38,11 +38,11 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Query
(
"select count(a) from Accession a where a.institute = ?1"
)
long
countByInstitute
(
FaoInstitute
institute
);
@Query
(
"select t.genus, count(a)
as x
from Accession a inner join a.taxonomy t where a.institute = ?1 group by t.genus order by
x
desc"
)
List
<
Object
[]>
statisticsGenusInInstitute
(
FaoInstitute
institute
);
@Query
(
"select t.genus, count(a) from Accession a inner join a.taxonomy t where a.institute = ?1 group by t.genus order by
count(a)
desc"
)
Page
<
Object
[]>
statisticsGenusInInstitute
(
FaoInstitute
institute
,
Pageable
pageable
);
@Query
(
"select taxonomy, count(a)
as x
from Accession a where a.institute = ?1 group by a.taxonomy order by
x
desc"
)
List
<
Object
[]>
statisticsTaxonomyInInstitute
(
FaoInstitute
institute
);
@Query
(
"select taxonomy, count(a) from Accession a where a.institute = ?1 group by a.taxonomy order by
count(a)
desc"
)
Page
<
Object
[]>
statisticsTaxonomyInInstitute
(
FaoInstitute
institute
,
Pageable
pageable
);
@Query
(
"select count(a) from Accession a where a.origin = ?1"
)
long
countByOrigin
(
String
isoCode3
);
...
...
src/main/java/org/crophub/rest/common/service/GenesysService.java
View file @
b10395a0
...
...
@@ -82,9 +82,9 @@ public interface GenesysService {
Page
<
Accession
>
listAccessions
(
Collection
<
Long
>
accessionIds
,
Pageable
pageable
);
List
<
Object
[]>
statisticsGenusByInstitute
(
FaoInstitute
faoInstitute
);
Page
<
Object
[]>
statisticsGenusByInstitute
(
FaoInstitute
faoInstitute
,
Pageable
pageable
);
List
<
Object
[]>
statisticsTaxonomyByInstitute
(
FaoInstitute
faoInstitute
);
Page
<
Object
[]>
statisticsTaxonomyByInstitute
(
FaoInstitute
faoInstitute
,
Pageable
pageable
);
Page
<
Accession
>
listAccessionsByInstituteAndTaxonomy
(
FaoInstitute
institute
,
Taxonomy
taxonomy
,
Pageable
pageable
);
...
...
src/main/java/org/crophub/rest/common/service/impl/GenesysServiceImpl.java
View file @
b10395a0
...
...
@@ -215,13 +215,13 @@ public class GenesysServiceImpl implements GenesysService, TraitService {
}
@Override
public
List
<
Object
[]>
statisticsGenusByInstitute
(
FaoInstitute
institute
)
{
return
accessionRepository
.
statisticsGenusInInstitute
(
institute
);
public
Page
<
Object
[]>
statisticsGenusByInstitute
(
FaoInstitute
institute
,
Pageable
pageable
)
{
return
accessionRepository
.
statisticsGenusInInstitute
(
institute
,
pageable
);
}
@Override
public
List
<
Object
[]>
statisticsTaxonomyByInstitute
(
FaoInstitute
institute
)
{
return
accessionRepository
.
statisticsTaxonomyInInstitute
(
institute
);
public
Page
<
Object
[]>
statisticsTaxonomyByInstitute
(
FaoInstitute
institute
,
Pageable
pageable
)
{
return
accessionRepository
.
statisticsTaxonomyInInstitute
(
institute
,
pageable
);
}
@Override
...
...
src/main/java/org/crophub/rest/servlet/controller/WiewsController.java
View file @
b10395a0
...
...
@@ -77,10 +77,8 @@ public class WiewsController extends BaseController {
model
.
addAttribute
(
"countByInstitute"
,
genesysService
.
countByInstitute
(
faoInstitute
));
// FIXME some institutes have *a lot* of different taxa
// TODO needs pagination
model
.
addAttribute
(
"statisticsGenus"
,
genesysService
.
statisticsGenusByInstitute
(
faoInstitute
).
subList
(
0
,
30
));
model
.
addAttribute
(
"statisticsTaxonomy"
,
genesysService
.
statisticsTaxonomyByInstitute
(
faoInstitute
).
subList
(
0
,
30
));
model
.
addAttribute
(
"statisticsGenus"
,
genesysService
.
statisticsGenusByInstitute
(
faoInstitute
,
new
PageRequest
(
0
,
30
)));
model
.
addAttribute
(
"statisticsTaxonomy"
,
genesysService
.
statisticsTaxonomyByInstitute
(
faoInstitute
,
new
PageRequest
(
0
,
30
)));
return
"/wiews/details"
;
}
...
...
src/main/webapp/WEB-INF/jsp/wiews/details.jsp
View file @
b10395a0
...
...
@@ -57,18 +57,18 @@
<div
class=
"clearfix"
style=
"margin-top: 2em;"
>
<div
class=
"pull-left"
style=
"margin-right: 3em;"
>
<h4>
Top
30
by Genus
</h4>
<h4>
Top
${statisticsGenus.numberOfElements}
by Genus
</h4>
<ul
class=
"funny-list statistics"
>
<c:forEach
items=
"
${
statisticsGenus
}
"
var=
"stat"
varStatus=
"status"
>
<c:forEach
items=
"
${
statisticsGenus
.
content
}
"
var=
"stat"
varStatus=
"status"
>
<li><span
class=
"stats-number"
><fmt:formatNumber
value=
"
${
stat
[
1
]
}
"
/></span>
<c:out
value=
"
${
stat
[
0
]
}
"
/></li>
</c:forEach>
</ul>
</div>
<div
class=
"pull-left"
style=
"margin-right: 3em;"
>
<h4>
Top
30
by Species
</h4>
<h4>
Top
${statisticsTaxonomy.numberOfElements}
by Species
</h4>
<ul
class=
"funny-list statistics"
>
<c:forEach
items=
"
${
statisticsTaxonomy
}
"
var=
"stat"
varStatus=
"status"
>
<c:forEach
items=
"
${
statisticsTaxonomy
.
content
}
"
var=
"stat"
varStatus=
"status"
>
<li><span
class=
"stats-number"
><fmt:formatNumber
value=
"
${
stat
[
1
]
}
"
/></span>
<a
href=
"
<c:url
value=
"/wiews/${faoInstitute.code.toLowerCase()}/t/${stat[0].genus}/${stat[0].species}"
/>
"
><c:out
value=
"
${
stat
[
0
].
taxonName
}
"
/></a></li>
</c:forEach>
</ul>
...
...
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