Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
232de4d2
Commit
232de4d2
authored
Sep 09, 2013
by
Matija Obreza
Browse files
Browse all by taxonomy
parent
dbbc2642
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/crophub/rest/common/persistence/domain/AccessionRepository.java
View file @
232de4d2
...
...
@@ -75,4 +75,6 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
Page
<
Accession
>
findById
(
Collection
<
Long
>
accessionIds
,
Pageable
pageable
);
Page
<
Accession
>
findByInstituteAndTaxonomy
(
FaoInstitute
institute
,
Taxonomy
taxonomy
,
Pageable
pageable
);
Page
<
Accession
>
findByTaxonomy
(
Taxonomy
taxonomy
,
Pageable
pageable
);
}
src/main/java/org/crophub/rest/common/service/GenesysService.java
View file @
232de4d2
...
...
@@ -67,4 +67,6 @@ public interface GenesysService {
Page
<
Accession
>
listAccessionsByInstituteAndTaxonomy
(
FaoInstitute
institute
,
Taxonomy
taxonomy
,
Pageable
pageable
);
Page
<
Accession
>
listAccessionsByTaxonomy
(
Taxonomy
taxonomy
,
Pageable
pageable
);
}
src/main/java/org/crophub/rest/common/service/impl/GenesysServiceImpl.java
View file @
232de4d2
...
...
@@ -183,4 +183,9 @@ public class GenesysServiceImpl implements GenesysService {
public
Page
<
Accession
>
listAccessionsByInstituteAndTaxonomy
(
FaoInstitute
institute
,
Taxonomy
taxonomy
,
Pageable
pageable
)
{
return
accessionRepository
.
findByInstituteAndTaxonomy
(
institute
,
taxonomy
,
pageable
);
}
@Override
public
Page
<
Accession
>
listAccessionsByTaxonomy
(
Taxonomy
taxonomy
,
Pageable
pageable
)
{
return
accessionRepository
.
findByTaxonomy
(
taxonomy
,
pageable
);
}
}
src/main/java/org/crophub/rest/servlet/controller/AccessionController.java
View file @
232de4d2
package
org.crophub.rest.servlet.controller
;
import
java.util.HashMap
;
import
java.util.List
;
import
org.crophub.rest.common.model.genesys.Accession
;
import
org.crophub.rest.common.model.genesys.Taxonomy
;
import
org.crophub.rest.common.model.impl.FaoInstitute
;
import
org.crophub.rest.common.service.GenesysService
;
import
org.crophub.rest.common.service.InstituteService
;
import
org.crophub.rest.common.service.TaxonomyService
;
import
org.crophub.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.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
@Controller
@RequestMapping
(
"/acn"
)
...
...
@@ -23,11 +30,15 @@ public class AccessionController extends BaseController {
@Autowired
private
GenesysService
genesysService
;
@Autowired
private
TaxonomyService
taxonomyService
;
@RequestMapping
(
"/id/{accessionId}"
)
public
String
view
(
ModelMap
model
,
@PathVariable
(
value
=
"accessionId"
)
long
accessionId
)
{
_logger
.
debug
(
"Viewing ACN "
+
accessionId
);
Accession
accession
=
genesysService
.
getAccession
(
accessionId
);
if
(
accession
==
null
)
{
Accession
accession
=
genesysService
.
getAccession
(
accessionId
);
if
(
accession
==
null
)
{
throw
new
ResourceNotFoundException
();
}
model
.
addAttribute
(
"accession"
,
accession
);
...
...
@@ -39,22 +50,23 @@ public class AccessionController extends BaseController {
model
.
addAttribute
(
"metadatas"
,
genesysService
.
listMetadata
(
accession
));
model
.
addAttribute
(
"methods"
,
genesysService
.
listMethods
(
accession
));
model
.
addAttribute
(
"methodValues"
,
genesysService
.
getAccessionTraitValues
(
accession
));
return
"/accession/details"
;
}
@RequestMapping
(
"/{holdingInstitute}/{accessionName}"
)
public
String
viewInstituteAccession
(
ModelMap
model
,
@PathVariable
(
value
=
"holdingInstitute"
)
String
holdingInstitute
,
@PathVariable
(
value
=
"accessionName"
)
String
accessionName
)
{
public
String
viewInstituteAccession
(
ModelMap
model
,
@PathVariable
(
value
=
"holdingInstitute"
)
String
holdingInstitute
,
@PathVariable
(
value
=
"accessionName"
)
String
accessionName
)
{
_logger
.
debug
(
"Viewing ACN "
+
accessionName
);
FaoInstitute
faoInstitute
=
instituteService
.
getInstitute
(
holdingInstitute
);
if
(
faoInstitute
==
null
)
{
if
(
faoInstitute
==
null
)
{
throw
new
ResourceNotFoundException
();
}
List
<
Accession
>
accessions
=
genesysService
.
listAccessions
(
faoInstitute
,
accessionName
);
if
(
accessions
.
size
()==
0
)
{
List
<
Accession
>
accessions
=
genesysService
.
listAccessions
(
faoInstitute
,
accessionName
);
if
(
accessions
.
size
()
==
0
)
{
throw
new
ResourceNotFoundException
();
}
if
(
accessions
.
size
()==
1
)
{
if
(
accessions
.
size
()
==
1
)
{
return
"redirect:/acn/id/"
+
accessions
.
get
(
0
).
getId
();
}
...
...
@@ -63,4 +75,36 @@ public class AccessionController extends BaseController {
return
"/accession/resolve"
;
}
/**
* View by Taxonomy
*
* @param model
* @param wiewsCode
* @param genus
* @param species
* @param page
* @return
*/
@RequestMapping
(
"/t/{genus}/{species}"
)
public
String
viewDataByGenusSpecies
(
ModelMap
model
,
@PathVariable
(
value
=
"genus"
)
String
genus
,
@PathVariable
(
value
=
"species"
)
String
species
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
int
page
)
{
// Taxonomy
Taxonomy
taxonomy
=
taxonomyService
.
get
(
genus
,
species
);
_logger
.
debug
(
"Got "
+
taxonomy
);
HashMap
<
Object
,
Object
>
filters
=
new
HashMap
<
Object
,
Object
>();
filters
.
put
(
"filter.taxonomy"
,
taxonomy
);
model
.
addAttribute
(
"filters"
,
filters
);
Page
<
Accession
>
accessions
=
genesysService
.
listAccessionsByTaxonomy
(
taxonomy
,
new
PageRequest
(
page
-
1
,
50
,
new
Sort
(
"accessionName"
)));
_logger
.
info
(
"Got: "
+
accessions
);
model
.
addAttribute
(
"accessions"
,
accessions
);
return
"/accession/data"
;
}
}
src/main/resources/content/language.properties
View file @
232de4d2
...
...
@@ -136,6 +136,7 @@ accession.inSvalbard.true=Super-safety duplicated in Svalbard Seed Vault.
accession.page.profile.title
=
Accession profile: {0}
accession.page.resolve.title
=
Multiple accessions found
accession.resolve
=
Multiple accessions with the name ''{0}'' found in Genesys. Select one from the list.
accession.page.data.title
=
Accession browser
taxonomy.genus
=
Genus
...
...
src/main/webapp/WEB-INF/jsp/accession/data.jsp
0 → 100644
View file @
232de4d2
<!DOCTYPE html>
<%@include
file=
"/WEB-INF/jsp/init.jsp"
%>
<html>
<head>
<title><spring:message
code=
"accession.page.data.title"
/></title>
</head>
<body>
<h1>
<spring:message
code=
"accession.page.data.title"
/>
</h1>
<%-- <div>
<a href="<c:url value="/geo/${faoInstitute.country.code3.toLowerCase()}" />"><c:out value="${faoInstitute.country.name}" /></a>
</div> --%>
<c:if
test=
"
${
filters
ne
null
}
"
>
<c:forEach
items=
"
${
filters
.
keySet
()
}
"
var=
"by"
>
<div><spring:message
code=
"
${
by
}
"
/>
:
<b>
${filters[by].taxonName}
</b></div>
</c:forEach>
</c:if>
<div
class=
"nav-header"
>
<spring:message
code=
"accessions.number"
arguments=
"
${
accessions
.
totalElements
}
"
/>
<br
/>
<spring:message
code=
"paged.pageOfPages"
arguments=
"
${
accessions
.
number
+
1
}
,${accessions.totalPages}"
/>
<a
href=
"?page=${accessions.number}"
>
⇇ Previous
</a>
<a
href=
"?page=${accessions.number + 2}"
>
Next ⇉
</a>
</div>
<table>
<thead>
<tr>
<td
class=
"idx-col"
></td>
<td><spring:message
code=
"accession.accessionName"
/></td>
<td><spring:message
code=
"accession.origin"
/></td>
<td><spring:message
code=
"accession.taxonomy"
/></td>
<td><spring:message
code=
"accession.holdingInstitute"
/></td>
<td><spring:message
code=
"accession.holdingCountry"
/></td>
</tr>
</thead>
<tbody>
<c:forEach
items=
"
${
accessions
.
content
}
"
var=
"accession"
varStatus=
"status"
>
<tr
class=
"${status.count % 2 == 0 ? 'even' : 'odd'}"
>
<td
class=
"idx-col"
>
${status.count + accessions.size * accessions.number}
</td>
<td><a
href=
"
<c:url
value=
"/acn/id/${accession.id}"
/>
"
><b><c:out
value=
"
${
accession
.
accessionName
}
"
/></b></a></td>
<td><a
href=
"
<c:url
value=
"/geo/${accession.origin.toLowerCase()}"
/>
"
><c:out
value=
"
${
accession
.
countryOfOrigin
.
name
}
"
/></a></td>
<td><c:out
value=
"
${
accession
.
taxonomy
.
taxonName
}
"
/></td>
<td><a
href=
"
<c:url
value=
"/wiews/${accession.institute.code.toLowerCase()}"
/>
"
><c:out
value=
"
${
accession
.
institute
.
code
}
"
/></a></td>
<td><a
href=
"
<c:url
value=
"/geo/${accession.institute.country.code3.toLowerCase()}"
/>
"
><c:out
value=
"
${
accession
.
institute
.
country
.
name
}
"
/></a></td>
</tr>
</c:forEach>
</tbody>
</table>
<div
class=
"nav-header"
>
<a
href=
"?page=${accessions.number}"
>
⇇ Previous
</a>
<a
href=
"?page=${accessions.number + 2}"
>
Next ⇉
</a>
</div>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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