Commit b0f022fd authored by Matija Obreza's avatar Matija Obreza

Updates

parent 332422ee
/**
* Copyright 2013 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
package org.crophub.rest.common.persistence.domain;
import org.crophub.rest.common.model.genesys.AllEnvironment;
import org.springframework.data.jpa.repository.JpaRepository;
public interface AccessionEnvironmentRepository extends JpaRepository<AllEnvironment, Long> {
}
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.crophub.rest.common.service;
import java.util.Collection;
......@@ -26,6 +25,7 @@ import org.crophub.rest.common.model.genesys.AllAccnames;
import org.crophub.rest.common.model.genesys.AllAcqBreeding;
import org.crophub.rest.common.model.genesys.AllAcqCollect;
import org.crophub.rest.common.model.genesys.AllAcqExchange;
import org.crophub.rest.common.model.genesys.AllEnvironment;
import org.crophub.rest.common.model.genesys.ExperimentTrait;
import org.crophub.rest.common.model.genesys.Metadata;
import org.crophub.rest.common.model.genesys.Method;
......@@ -55,12 +55,14 @@ public interface GenesysService {
AllAccnames listAccessionNames(Accession accession);
List<AllAcqExchange> listAccessionExchange(Accession accession);
AllAcqExchange listAccessionExchange(Accession accession);
List<AllAcqCollect> listAccessionCollect(Accession accession);
AllAcqCollect listAccessionCollect(Accession accession);
List<AllAcqBreeding> listAccessionBreeding(Accession accession);
AllAcqBreeding listAccessionBreeding(Accession accession);
AllEnvironment listAccessionEnvironment(Accession accession);
List<Metadata> listMetadata(Accession accession);
Page<Metadata> listMetadata(PageRequest pageRequest);
......
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.crophub.rest.common.service.impl;
import java.util.Collection;
......@@ -28,6 +27,7 @@ import org.crophub.rest.common.model.genesys.AllAccnames;
import org.crophub.rest.common.model.genesys.AllAcqBreeding;
import org.crophub.rest.common.model.genesys.AllAcqCollect;
import org.crophub.rest.common.model.genesys.AllAcqExchange;
import org.crophub.rest.common.model.genesys.AllEnvironment;
import org.crophub.rest.common.model.genesys.ExperimentTrait;
import org.crophub.rest.common.model.genesys.Metadata;
import org.crophub.rest.common.model.genesys.Method;
......@@ -37,6 +37,8 @@ import org.crophub.rest.common.model.impl.Crop;
import org.crophub.rest.common.model.impl.FaoInstitute;
import org.crophub.rest.common.persistence.domain.AccessionBreedingRepository;
import org.crophub.rest.common.persistence.domain.AccessionCollectRepository;
import org.crophub.rest.common.persistence.domain.AccessionEnvironmentRepository;
import org.crophub.rest.common.persistence.domain.AccessionExchangeRepository;
import org.crophub.rest.common.persistence.domain.AccessionNameRepository;
import org.crophub.rest.common.persistence.domain.AccessionRepository;
import org.crophub.rest.common.persistence.domain.AccessionTraitRepository;
......@@ -69,6 +71,10 @@ public class GenesysServiceImpl implements GenesysService {
@Autowired
private AccessionNameRepository accessionNamesRepository;
@Autowired
private AccessionExchangeRepository accessionExchangeRepository;
@Autowired
private AccessionEnvironmentRepository accessionEnvironmentRepository;
@Autowired
private AccessionTraitRepository accessionTraitRepository;
@Autowired
private MetadataRepository metadataRepository;
......@@ -76,7 +82,7 @@ public class GenesysServiceImpl implements GenesysService {
private MetadataMethodRepository metadataMethodRepository;
@Autowired
private TraitValueRepository traitValueRepository;
@Autowired
private CropTaxonomyRepository cropTaxonomyRepository;
......@@ -127,21 +133,23 @@ public class GenesysServiceImpl implements GenesysService {
}
@Override
public List<AllAcqBreeding> listAccessionBreeding(Accession accession) {
// TODO Auto-generated method stub
return null;
public AllAcqBreeding listAccessionBreeding(Accession accession) {
return accessionBreedingRepository.findOne(accession.getId());
}
@Override
public AllEnvironment listAccessionEnvironment(Accession accession) {
return accessionEnvironmentRepository.findOne(accession.getId());
}
@Override
public List<AllAcqCollect> listAccessionCollect(Accession accession) {
// TODO Auto-generated method stub
return null;
public AllAcqCollect listAccessionCollect(Accession accession) {
return accessionCollectRepository.findOne(accession.getId());
}
@Override
public List<AllAcqExchange> listAccessionExchange(Accession accession) {
// TODO Auto-generated method stub
return null;
public AllAcqExchange listAccessionExchange(Accession accession) {
return accessionExchangeRepository.findOne(accession.getId());
}
@Override
......@@ -190,7 +198,7 @@ public class GenesysServiceImpl implements GenesysService {
List<Method> methods = metadataMethodRepository.listMetadataMethods(metadata);
return traitValueRepository.getValues(metadata, methods, accessions);
}
@Override
public List<Object[]> statisticsGenusByInstitute(FaoInstitute institute) {
return accessionRepository.statisticsGenusInInstitute(institute);
......@@ -200,22 +208,22 @@ public class GenesysServiceImpl implements GenesysService {
public List<Object[]> statisticsTaxonomyByInstitute(FaoInstitute institute) {
return accessionRepository.statisticsTaxonomyInInstitute(institute);
}
@Override
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);
}
@Override
public Page<Accession> listAccessions(Pageable pageable) {
return accessionRepository.findAll(pageable);
}
@Override
public Page<Accession> listAccessionsByCrop(Crop crop, Pageable pageable) {
return accessionRepository.findByTaxonomy(cropTaxonomyRepository.findTaxonomiesByCrop(crop), pageable);
......
......@@ -28,6 +28,7 @@ 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.context.annotation.Scope;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
......@@ -38,9 +39,13 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
@Scope("request")
@RequestMapping("/acn")
public class AccessionController extends BaseController {
@Autowired
private SelectionBean selectionBean;
@Autowired
private InstituteService instituteService;
......@@ -62,11 +67,14 @@ public class AccessionController extends BaseController {
model.addAttribute("accessionExchange", genesysService.listAccessionExchange(accession));
model.addAttribute("accessionCollect", genesysService.listAccessionCollect(accession));
model.addAttribute("accessionBreeding", genesysService.listAccessionBreeding(accession));
model.addAttribute("accessionEnvironment", genesysService.listAccessionEnvironment(accession));
model.addAttribute("metadatas", genesysService.listMetadata(accession));
model.addAttribute("methods", genesysService.listMethods(accession));
model.addAttribute("methodValues", genesysService.getAccessionTraitValues(accession));
model.addAttribute("selection", selectionBean);
return "/accession/details";
}
......@@ -104,6 +112,7 @@ public class AccessionController extends BaseController {
Page<Accession> accessions = genesysService.listAccessions(new PageRequest(page - 1, 50, new Sort("accessionName")));
_logger.info("Got: " + accessions);
model.addAttribute("accessions", accessions);
model.addAttribute("selection", selectionBean);
return "/accession/data";
}
......@@ -134,6 +143,7 @@ public class AccessionController extends BaseController {
Page<Accession> accessions = genesysService.listAccessionsByTaxonomy(taxonomy, new PageRequest(page - 1, 50, new Sort("accessionName")));
_logger.info("Got: " + accessions);
model.addAttribute("accessions", accessions);
model.addAttribute("selection", selectionBean);
return "/accession/data";
}
......
......@@ -45,6 +45,10 @@ public class SelectionBean {
accessionIds.clear();
}
public boolean containsId(long id) {
return accessionIds.contains(id);
}
public boolean contains(Accession accession) {
return accessionIds.contains(accession.getId());
}
......@@ -52,4 +56,8 @@ public class SelectionBean {
public Set<Long> copy() {
return new HashSet<>(accessionIds);
}
public int size() {
return accessionIds.size();
}
}
......@@ -14,7 +14,6 @@
* limitations under the License.
**/
package org.crophub.rest.servlet.controller;
import org.crophub.rest.common.model.genesys.Accession;
......@@ -23,12 +22,15 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
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;
@Controller
@Scope("request")
......@@ -84,4 +86,29 @@ public class SelectionController extends BaseController {
return "redirect:/sel/";
}
@RequestMapping(value = "json", method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE })
@ResponseBody
public SelectionJsonResponse jsonOp(@RequestBody SelectionJsonAction action) {
_logger.info("Selection action " + action.action + ": " + action.id);
SelectionJsonResponse resp=new SelectionJsonResponse();
if ("add".equals(action.action)) {
selectionBean.add(action.id);
resp.included=true;
} else {
selectionBean.remove(action.id);
resp.included=false;
}
resp.count=selectionBean.size();
return resp;
}
public static class SelectionJsonAction {
public long id;
public String action;
}
public static class SelectionJsonResponse {
public int count;
public boolean included;
}
}
......@@ -140,7 +140,16 @@ accession.inSvalbard=Svalbardized
accession.inTrust.true=This accession is under Article 15 of the International Treaty on Plant Genetic Resources for Food and Agriculture.
accession.mlsStatus.true=This accession is in the Multilateral System of ITPGRFA.
accession.inSvalbard.true=Super-safety duplicated in Svalbard Seed Vault.
accession.altitude=Altitude
accession.geolocation=Geolocation (lat, long)
accession.breederCode=Breeder Code
accession.pedigree=Pedigree
accession.collecting.site=Collecting site
accession.collecting.institute=Collecting institute
accession.collecting.number=Collecting number
accession.collecting.date=Collecting date
accession.donor.institute=Donor institute
accession.donor.accessionNumber=Donor accession ID
accession.page.profile.title=Accession profile: {0}
accession.page.resolve.title=Multiple accessions found
......
......@@ -28,7 +28,7 @@ db.showSql=true
c3p0.acquireIncrement=1
c3p0.minPoolSize=5
c3p0.maxPoolSize=40
c3p0.maxPoolSize=20
c3p0.maxIdleTime=30
lucene.indexDir=./lucene/
......
......@@ -13,8 +13,8 @@
<link type="text/css" href="/html/css/bootstrap.css" rel="stylesheet" />
<link type="text/css" href="/html/css/custom.css" rel="stylesheet" />
<!--
<script type="text/javascript" src="/html/js/jquery.min.js"></script>
<!--
<script type="text/javascript" src="/html/js/modernizr-2.6.2.min.js"></script>
<script type="text/javascript" src="/html/js/plugins.js"></script>
<script type="text/javascript" src="/html/js/jquery.validate.js"></script>
......@@ -25,13 +25,15 @@
<link type="text/css" href="/html/css/jquery.dataTables.css" rel="stylesheet" />
-->
<%--Fallback for older browsers--%>
<script type="text/javascript" src="/html/js/json2.js"></script>
<!--
<script type="text/javascript" src="/html/js/json2.js"></script>
<script type="text/javascript" src="/html/js/globalize.js"></script>
<script type="text/javascript" src="/html/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/html/js/jquery.dataTables.js"></script>
<script type="text/javascript" src="/html/js/handlebars.js"></script> -->
<!-- <script type="text/javascript" src="/html/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/html/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/html/js/crophub.js"></script>
<!--
--><!-- <script type="text/javascript" src="/html/js/main.js"></script>
-->
<sitemesh:write property="head" />
......@@ -51,7 +53,7 @@
<div class="navbar pull-right">
<div class="nav-collapse">
<ul class="nav">
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" title="<spring:message code="sample.message.change.locale"/>"> <spring:message code="sample.message.current.locale" /> <b class="caret"></b>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown"> <spring:message code="sample.message.locale.${pageContext.response.locale}" /> <b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="?lang=en"><spring:message code="sample.message.locale.en" /></a></li>
......@@ -97,7 +99,7 @@
<li><a href="<c:url value="/data/" />"><spring:message code="menu.datasets" /></a></li>
<li><a href="<c:url value="/geo/" />"><spring:message code="menu.countries" /></a></li>
<li><a href="<c:url value="/wiews/active" />"><spring:message code="menu.institutes" /></a></li>
<li><a href="<c:url value="/sel/" />"><spring:message code="menu.my-list" /></a></li>
<li><a href="<c:url value="/sel/" />"><spring:message code="menu.my-list" /><div id="selcounter" /></a></li>
</ul>
</div>
......
......@@ -39,10 +39,13 @@
<a href="?page=${accessions.number + 2}">Next ⇉</a>
</div>
<table>
<table class="accessions">
<thead>
<tr>
<td class="idx-col"></td>
<c:if test="${selection ne null}">
<td />
</c:if>
<td><spring:message code="accession.accessionName" /></td>
<td><spring:message code="accession.origin" /></td>
<td><spring:message code="accession.taxonomy" /></td>
......@@ -52,8 +55,11 @@
</thead>
<tbody>
<c:forEach items="${accessions.content}" var="accession" varStatus="status">
<tr class="${status.count % 2 == 0 ? 'even' : 'odd'}">
<tr class="acn ${status.count % 2 == 0 ? 'even' : 'odd'}">
<td class="idx-col">${status.count + accessions.size * accessions.number}</td>
<c:if test="${selection ne null}">
<td><div class="sel ${selection.containsId(accession.id) ? 'picked' : ''}" x-aid="${accession.id}"></div></td>
</c:if>
<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><a href="<c:url value="/acn/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><c:out value="${accession.taxonomy.taxonName}" /></a></td>
......
......@@ -11,27 +11,33 @@
<c:out value="${accession.accessionName}" />
<small><c:out value="${accession.instituteCode}" /></small>
</h1>
<div class="page-header">
<a href="<c:url value="/sel/add/${accession.id}" />"><spring:message code="selection.add" arguments="${accession.accessionName}" /></a>
</div>
<c:if test="${accession.inTrust eq true}">
<div class="alert"><spring:message code="accession.inTrust.true" /></div>
<div class="alert">
<spring:message code="accession.inTrust.true" />
</div>
</c:if>
<c:if test="${accession.inSvalbard eq true}">
<div class="alert"><spring:message code="accession.inSvalbard.true" /></div>
<div class="alert">
<spring:message code="accession.inSvalbard.true" />
</div>
</c:if>
<c:if test="${accession.mlsStatus eq true}">
<div class="alert"><spring:message code="accession.mlsStatus.true" /></div>
<div class="alert">
<spring:message code="accession.mlsStatus.true" />
</div>
</c:if>
<table>
<tbody>
<tr>
<td><spring:message code="accession.holdingInstitute" /></td>
<td><a href="<c:url value="/wiews/${accession.instituteCode.toLowerCase()}" />"> <c:out value="${accession.institute.fullName}" />
......@@ -65,20 +71,73 @@
</tr>
<tr>
<td><spring:message code="taxonomy.taxonName" /></td>
<td><a href="<c:url value="/acn/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><c:out value="${accession.taxonomy.taxonName}" /></a>
<a href="<c:url value="/wiews/${accession.institute.code.toLowerCase()}/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><spring:message code="accession.taxonomy-at-institute" arguments="${accession.taxonomy.taxonName}|||${accession.institute.code}" argumentSeparator="|||" /></a>
</td>
<td><a href="<c:url value="/acn/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><c:out value="${accession.taxonomy.taxonName}" /></a> <br />
<a href="<c:url value="/wiews/${accession.institute.code.toLowerCase()}/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><spring:message code="accession.taxonomy-at-institute" arguments="${accession.taxonomy.taxonName}|||${accession.institute.code}" argumentSeparator="|||" /></a></td>
</tr>
<tr>
<td><spring:message code="accession.otherNames" /></td>
<td><c:out value="${accessionNames.accNames}" /><br /> <c:out value="${accessionNames.otherIds}" /></td>
</tr>
<c:if test="${accessionExchange ne null}">
<tr>
<td><spring:message code="accession.donor.institute" /></td>
<td>${accessionExchange.donorInstitute}</td>
</tr>
<tr>
<td><spring:message code="accession.donor.accessionNumber" /></td>
<td>${accessionExchange.accNumbDonor}</td>
</tr>
</c:if>
<c:if test="${accessionCollect ne null}">
<tr>
<td><spring:message code="accession.collecting.date" /></td>
<td>${accessionCollect.collectDate}</td>
</tr>
<tr>
<td><spring:message code="accession.collecting.number" /></td>
<td>${accessionCollect.collectorsNumb}</td>
</tr>
<tr>
<td><spring:message code="accession.collecting.institute" /></td>
<td>${accessionCollect.collectingInstitute}</td>
</tr>
<tr>
<td><spring:message code="accession.collecting.site" /></td>
<td>${accessionCollect.collectSite}</td>
</tr>
</c:if>
<c:if test="${accessionBreeding ne null}">
<tr>
<td><spring:message code="accession.breederCode" /></td>
<td>${accessionBreeding.breederCode}</td>
</tr>
<tr>
<td><spring:message code="accession.pedigree" /></td>
<td>${accessionBreeding.pedigree}</td>
</tr>
</c:if>
<c:if test="${accessionEnvironment ne null}">
<tr>
<td><spring:message code="accession.geolocation" /></td>
<td>${accessionEnvironment.latitude}, ${accessionEnvironment.longitude}</td>
</tr>
<tr>
<td><spring:message code="accession.altitude" /></td>
<td>${accessionEnvironment.altitude}<span class="uom">m</span></td>
</tr>
</c:if>
</tbody>
</table>
<c:if test="${methods.size() gt 0}">
<h2>
<spring:message code="accession.methods" />
......@@ -91,8 +150,7 @@
<td><c:forEach items="${methodValues[method.id]}" var="val">
<div>
<c:out value="${method.decode(val.value)}" />
<span class="uom"><c:out value="${method.unit}" /></span>
<sup><a href="#metadata-${val.experimentId}"><c:out value="${val.experimentId}" /></a></sup>
<span class="uom"><c:out value="${method.unit}" /></span> <sup><a href="#metadata-${val.experimentId}"><c:out value="${val.experimentId}" /></a></sup>
</div>
</c:forEach></td>
<td><c:out value="${method.method}" /></td>
......@@ -108,8 +166,7 @@
</h3>
<c:forEach items="${metadatas}" var="metadata" varStatus="status">
<div class="targeted" id="metadata-${metadata.id}">
<sup><c:out value="${metadata.id}" /></sup>
<a href="<c:url value="/data/view/${metadata.id}" />"><c:out value="${metadata.title}" /></a>
<sup><c:out value="${metadata.id}" /></sup> <a href="<c:url value="/data/view/${metadata.id}" />"><c:out value="${metadata.title}" /></a>
<c:out value="${metadata.institute}" />
</div>
<div>
......
......@@ -77,7 +77,7 @@
<error-code>404</error-code>
<location>/WEB-INF/jsp/404.jsp</location>
</error-page>
<session-config>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
......
......@@ -35,6 +35,8 @@
table {
width: 100%;
font-size: 12px;
border-spacing: 0 3px;
border-collapse: separate;
}
......@@ -65,10 +67,10 @@ td.idx-col {
}
tr.odd td {
/* background-color: #f8f7f5; */
background-color: #f8f7f5;
}
tr.even td {
/* background-color: #f3f2ee; */
background-color: #f3f2ee;
}
.activity-post {
......@@ -142,8 +144,8 @@ body {
}
.content-block *:FIRST-CHILD {
/* margin-top: 0;
padding-top: 0; */
margin-top: 0;
padding-top: 0;
}
#header {
......@@ -186,7 +188,7 @@ body {
border-top: solid 2px #909090;
background-color: #4d4c47;
margin: 4em 0 0 0;
color: White;
color: #9a9994;
font-size: 11px;
/* position: absolute;
bottom: 0; */
......@@ -223,4 +225,26 @@ ul.statistics .stats-number {
margin-left: 2em;
width: 4em;
float: right;
}
.acn .sel {
background-image: url("../images/sel-add2.png");
background-repeat: no-repeat;
background-position: 0 2px;
width: 14px;
height: 14px;
}
.acn .sel.picked {
background-image: url("../images/sel-remove2.png");
}
#selcounter {
float: right;
font-size: 70%;
font-weight: bold;
color: White;
position: relative;
right: -0.5em;
top: -0.6em;
}
\ No newline at end of file