Commit c0d96a96 authored by Matija Obreza's avatar Matija Obreza
Browse files

/archive controller

parent 47f4ef38
......@@ -22,6 +22,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.genesys2.server.model.elastic.AccessionDetails;
import org.genesys2.server.model.genesys.Accession;
......@@ -219,5 +220,6 @@ public interface GenesysService {
int assignMissingUuid(int count);
AccessionHistoric getHistoricAccession(UUID uuid);
}
......@@ -1515,7 +1515,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
public int assignMissingUuid(int count) {
List<AccessionId> accessionIds = accessionIdRepository.findMissingUuid(new PageRequest(0, count));
for (AccessionId accessionId : accessionIds) {
if (accessionId.getUuid()==null) {
if (accessionId.getUuid() == null) {
accessionId.setUuid(UUID.randomUUID());
}
}
......@@ -1524,4 +1524,12 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return accessionIds.size();
}
@Override
public AccessionHistoric getHistoricAccession(UUID uuid) {
AccessionHistoric ah = accessionHistoricRepository.findOneByUuid(uuid);
if (ah != null) {
ah.getStoRage().size();
}
return ah;
}
}
......@@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RequestParam;
@RequestMapping("/acn")
public class AccessionController extends BaseController {
private static final UUID WORLDCLIM_DATASET_UUID = UUID.fromString("BC84433B-A626-4BDF-97D3-DB36D79499C6");
public static final UUID WORLDCLIM_DATASET_UUID = UUID.fromString("BC84433B-A626-4BDF-97D3-DB36D79499C6");
@Autowired
private InstituteService instituteService;
......
/**
* Copyright 2015 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.genesys2.server.servlet.controller;
import java.util.UUID;
import org.genesys2.server.model.dataset.DS;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionHistoric;
import org.genesys2.server.service.CropService;
import org.genesys2.server.service.DSService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.TaxonomyService;
import org.genesys2.server.service.TraitService;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
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.RequestMethod;
@Controller
@RequestMapping("/archive")
public class ArchiveController extends BaseController {
@Autowired
private GenesysService genesysService;
@Autowired
private TraitService traitService;
@Autowired
private TaxonomyService taxonomyService;
@Autowired
private CropService cropService;
@Autowired
private DSService dsService;
@RequestMapping(value = "/{uuid:.{36}}", method = RequestMethod.GET)
public String view(ModelMap model, @PathVariable(value = "uuid") UUID uuid) {
_logger.debug("Viewing archive ACN " + uuid);
fillModel(model, uuid);
return "/accession/details";
}
@RequestMapping(value = "/{uuid:.{36}}", method = RequestMethod.GET, headers = "accept=text/turtle", produces = "text/turtle")
public String viewTurtle(ModelMap model, @PathVariable(value = "uuid") UUID uuid) {
_logger.debug("Viewing archive ACN " + uuid);
fillModel(model, uuid);
return "/accession/details-turtle";
}
private void fillModel(ModelMap model, UUID uuid) {
final AccessionHistoric accession = genesysService.getHistoricAccession(uuid);
if (accession == null) {
throw new ResourceNotFoundException();
}
model.addAttribute("accession", accession);
model.addAttribute("accessionNames", genesysService.listAccessionNames(accession.getAccessionId()));
model.addAttribute("accessionAliases", genesysService.listAccessionAliases(accession.getAccessionId()));
model.addAttribute("accessionExchange", genesysService.listAccessionExchange(accession.getAccessionId()));
model.addAttribute("accessionCollect", genesysService.listAccessionCollect(accession.getAccessionId()));
model.addAttribute("accessionBreeding", genesysService.listAccessionBreeding(accession.getAccessionId()));
AccessionGeo accessionGeo = genesysService.listAccessionGeo(accession.getAccessionId());
model.addAttribute("accessionGeo", accessionGeo);
model.addAttribute("svalbardData", genesysService.getSvalbardData(accession.getAccessionId()));
model.addAttribute("accessionRemarks", genesysService.listAccessionRemarks(accession.getAccessionId()));
model.addAttribute("metadatas", genesysService.listMetadata(accession.getAccessionId()));
model.addAttribute("methods", traitService.listMethods(accession.getAccessionId()));
model.addAttribute("methodValues", genesysService.getAccessionTraitValues(accession.getAccessionId()));
model.addAttribute("crops", cropService.getCrops(accession.getTaxonomy()));
// Worldclim data
if (accessionGeo != null && accessionGeo.getTileIndex() != null) {
DS worldClimDataset = dsService.loadDatasetByUuid(AccessionController.WORLDCLIM_DATASET_UUID);
if (worldClimDataset != null) {
model.addAttribute("worldclimJson", dsService.jsonForTile(worldClimDataset, accessionGeo.getTileIndex()));
}
}
}
}
......@@ -79,7 +79,7 @@ public class ResolverController {
}
if (resolved instanceof AccessionHistoric) {
return "redirect:/history/acn/id/" + resolved.getUuid();
return "redirect:/archive/" + resolved.getUuid();
}
throw new ResourceNotFoundException("We don't have an object with UUID " + uuid);
......
......@@ -4,46 +4,51 @@
<html>
<head>
<title><spring:message code="accession.page.profile.title" arguments="${accession.accessionName}" argumentSeparator="|" /></title>
<title><spring:message code="accession.page.profile.title" arguments="${accession.accessionName}"
argumentSeparator="|"
/></title>
</head>
<body typeof="germplasm:GermplasmAccession">
<h1>
<span property="dwc:catalogNumber"><c:out value="${accession.accessionName}" /></span>
<small property="dwc:institutionCode" datatype="germplasmType:wiewsInstituteID"><c:out value="${accession.instituteCode}" /></small>
</h1>
<div class="main-col-header acn">
<div class="sel" x-aid="${accession.id}">
<a class="add" href=""><spring:message code="selection.add" arguments="${accession.accessionName}" /></a> <a class="remove" href=""><spring:message code="selection.remove"
arguments="${accession.accessionName}" /></a>
</div>
</div>
<c:if test="${accession.inTrust eq true}">
<div class="alert alert-info">
<spring:message code="accession.inTrust.true" />
</div>
</c:if>
<c:if test="${accession.inSvalbard eq true}">
<div class="alert alert-info">
<spring:message code="accession.inSvalbard.true" />
</div>
</c:if>
<c:if test="${accession.mlsStatus eq true}">
<div class="alert alert-info">
<spring:message code="accession.mlsStatus.true" />
</div>
</c:if>
<c:if test="${accession.historic eq true}">
<div class="alert alert-warning">
<spring:message code="accession.this-is-a-historic-entry" />
</div>
</c:if>
<%--
<h1>
<span property="dwc:catalogNumber"><c:out value="${accession.accessionName}" /></span> <small
property="dwc:institutionCode" datatype="germplasmType:wiewsInstituteID"
><c:out value="${accession.instituteCode}" /></small>
</h1>
<div class="main-col-header acn">
<div class="sel" x-aid="${accession.id}">
<a class="add" href=""><spring:message code="selection.add" arguments="${accession.accessionName}" /></a> <a
class="remove" href=""
><spring:message code="selection.remove" arguments="${accession.accessionName}" /></a>
</div>
</div>
<c:if test="${accession.historic eq true or accession.getClass().simpleName eq 'AccessionHistoric'}">
<div class="alert alert-warning">
<spring:message code="accession.this-is-a-historic-entry" />
</div>
</c:if>
<c:if test="${accession.inTrust eq true}">
<div class="alert alert-info">
<spring:message code="accession.inTrust.true" />
</div>
</c:if>
<c:if test="${accession.inSvalbard eq true}">
<div class="alert alert-info">
<spring:message code="accession.inSvalbard.true" />
</div>
</c:if>
<c:if test="${accession.mlsStatus eq true}">
<div class="alert alert-info">
<spring:message code="accession.mlsStatus.true" />
</div>
</c:if>
<%--
<c:if test="${accession.availability eq false}">
<div class="alert alert-warning">
<spring:message code="accession.not-available-for-distribution" />
......@@ -55,8 +60,8 @@
<spring:message code="accession.available-for-distribution" />
</div>
</c:if>
--%>
<%--
--%>
<%--
<div itemscope itemtype="http://data-vocabulary.org/Breadcrumb">
<a href="<c:url value="/wiews/${accession.institute.code}" />" itemprop="url">
<span itemprop="title" dir="ltr">${accession.institute.fullName}</span>
......@@ -79,311 +84,458 @@
</div>
--%>
<div class="pseudo-right-col col-md-3">
<c:if test="${accessionGeo.latitude ne null and accessionGeo.longitude ne null}">
<div class="crop-location" itemscope itemtype="http://schema.org/GeoCoordinates">
<h3><spring:message code="accession.collecting.site" /></h3>
<div id="map" class="map-container"></div>
<table class="map-data">
<tr>
<td><spring:message code="filter.geo.latitude" />:</td>
<td><c:out value="${accessionGeo.latitude}" /></td>
</tr><tr>
<td><spring:message code="filter.geo.longitude" />:</td>
<td><c:out value="${accessionGeo.longitude}" /></td>
</tr><tr>
<td><spring:message code="accession.elevation" />:</td>
<td><c:out value="${accessionGeo.elevation}" /></td>
</tr>
</table>
</div>
</c:if>
</div>
<div class="crop-details">
<div class="row">
<div class="col-xs-4"><spring:message code="accession.holdingInstitute" /></div>
<div class="col-xs-8"><a property="dwc:institutionCode" href="<c:url value="/wiews/${accession.instituteCode}" />"> <c:out value="${accession.institute.fullName}" />
</a></div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.holdingCountry" /></div>
<div class="col-xs-8"><a href="<c:url value="/geo/${accession.institute.country.code3}" />"><c:out value="${accession.institute.country.getName(pageContext.response.locale)}" /></a></div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.accessionName" /></div>
<div class="col-xs-8"><c:out value="${accession.accessionName}" /></div>
</div>
<c:if test="${crops ne null}">
<div class="row">
<div class="col-xs-4"><spring:message code="accession.crop" /></div>
<div class="col-xs-8"><c:forEach items="${crops}" var="crop">
<a href="<c:url value="/c/${crop.shortName}" />"><c:out value="${crop.getName(pageContext.response.locale)}" /></a>
</c:forEach></div>
</div>
</c:if>
<c:if test="${accession.countryOfOrigin ne null}">
<div class="row">
<div class="col-xs-4"><spring:message code="accession.origin" /></div>
<div class="col-xs-8"><img src="<c:url value="${cdnFlagsUrl}" />/${accession.origin.toUpperCase()}.png" /> <a href="<c:url value="/geo/${accession.origin}" />"> <c:out value="${accession.countryOfOrigin.getName(pageContext.response.locale)}" />
</a></div>
</div>
</c:if>
<div class="row">
<div class="col-xs-4"><spring:message code="taxonomy.genus" /></div>
<div class="col-xs-8" property="dwc:genus"><a href="<c:url value="/acn/t/${accession.taxonomy.genus}" />"><span dir="ltr" class="sci-name" ><c:out value="${accession.taxonomy.genus}" /></span></a></div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="taxonomy.species" /></div>
<div class="col-xs-8"><a href="<c:url value="/acn/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><span class="sci-name" dir="ltr"><c:out value="${accession.taxonomy.genus} ${accession.taxonomy.species}" /></span></a>
<br />
<a href="<c:url value="/wiews/${accession.institute.code}/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><spring:message code="accession.taxonomy-at-institute" arguments="${accession.taxonomy.genus} ${accession.taxonomy.species}|||${accession.institute.code}" argumentSeparator="|||" /></a>
</div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="taxonomy.taxonName" /></div>
<div class="col-xs-8"><span dir="ltr" class="sci-name" ><c:out value="${accession.taxonomy.taxonName}" /></span></div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.sampleStatus" /></div>
<div class="col-xs-8" property="germplasm:biologicalStatus"><spring:message code="accession.sampleStatus.${accession.sampleStatus}" /></div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.storage" /></div>
<div class="col-xs-8">
<c:forEach items="${accession.stoRage}" var="storage">
<div><spring:message code="accession.storage.${storage}" /></div>
</c:forEach>
</div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.availability" /></div>
<div class="col-xs-8"><spring:message code="accession.availability.${accession.availability}" /></div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.otherNames" /></div>
<div class="col-xs-8">
<c:forEach items="${accessionAliases}" var="accessionAlias">
<div>
<c:out value="${accessionAlias.name}" />
<c:if test="${accessionAlias.instCode != ''}">
<a href="<c:url value="/wiews/${accessionAlias.instCode}" />">
${accessionAlias.instCode}
</a>
</c:if>
<c:if test="${accessionAlias.usedBy != ''}">
<div class="pseudo-right-col col-md-3">
<c:if test="${accessionGeo.latitude ne null and accessionGeo.longitude ne null}">
<div class="crop-location" itemscope itemtype="http://schema.org/GeoCoordinates">
<h3>
<spring:message code="accession.collecting.site" />
</h3>
<div id="map" class="map-container"></div>
<table class="map-data">
<tr>
<td><spring:message code="filter.geo.latitude" />:</td>
<td><c:out value="${accessionGeo.latitude}" /></td>
</tr>
<tr>
<td><spring:message code="filter.geo.longitude" />:</td>
<td><c:out value="${accessionGeo.longitude}" /></td>
</tr>
<tr>
<td><spring:message code="accession.elevation" />:</td>
<td><c:out value="${accessionGeo.elevation}" /></td>
</tr>
</table>
</div>
</c:if>
</div>
<div class="crop-details">
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.holdingInstitute" />
</div>
<div class="col-xs-8">
<a property="dwc:institutionCode" href="<c:url value="/wiews/${accession.instituteCode}" />"> <c:out
value="${accession.institute.fullName}"
/>
</a>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.holdingCountry" />
</div>
<div class="col-xs-8">
<a href="<c:url value="/geo/${accession.institute.country.code3}" />"><c:out
value="${accession.institute.country.getName(pageContext.response.locale)}"
/></a>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.accessionName" />
</div>
<div class="col-xs-8">
<c:out value="${accession.accessionName}" />
</div>
</div>
<c:if test="${crops ne null}">
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.crop" />
</div>
<div class="col-xs-8">
<c:forEach items="${crops}" var="crop">
<a href="<c:url value="/c/${crop.shortName}" />"><c:out
value="${crop.getName(pageContext.response.locale)}"
/></a>
</c:forEach>
</div>
</div>
</c:if>
<c:if test="${accession.countryOfOrigin ne null}">
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.origin" />
</div>
<div class="col-xs-8">
<img src="<c:url value="${cdnFlagsUrl}" />/${accession.origin.toUpperCase()}.png" /> <a
href="<c:url value="/geo/${accession.origin}" />"
> <c:out value="${accession.countryOfOrigin.getName(pageContext.response.locale)}" />
</a>
</div>
</div>
</c:if>
<div class="row">
<div class="col-xs-4">
<spring:message code="taxonomy.genus" />
</div>
<div class="col-xs-8" property="dwc:genus">
<a href="<c:url value="/acn/t/${accession.taxonomy.genus}" />"><span dir="ltr" class="sci-name"><c:out
value="${accession.taxonomy.genus}"
/></span></a>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="taxonomy.species" />
</div>
<div class="col-xs-8">
<a href="<c:url value="/acn/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><span
class="sci-name" dir="ltr"
><c:out value="${accession.taxonomy.genus} ${accession.taxonomy.species}" /></span></a> <br /> <a
href="<c:url value="/wiews/${accession.institute.code}/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"
><spring:message code="accession.taxonomy-at-institute"
arguments="${accession.taxonomy.genus} ${accession.taxonomy.species}|||${accession.institute.code}"
argumentSeparator="|||"
/></a>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="taxonomy.taxonName" />
</div>
<div class="col-xs-8">
<span dir="ltr" class="sci-name"><c:out value="${accession.taxonomy.taxonName}" /></span>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.sampleStatus" />
</div>
<div class="col-xs-8" property="germplasm:biologicalStatus">
<spring:message code="accession.sampleStatus.${accession.sampleStatus}" />
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.storage" />
</div>
<div class="col-xs-8">
<c:forEach items="${accession.stoRage}" var="storage">
<div>
<spring:message code="accession.storage.${storage}" />
</div>
</c:forEach>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.availability" />
</div>
<div class="col-xs-8">
<spring:message code="accession.availability.${accession.availability}" />
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.otherNames" />
</div>
<div class="col-xs-8">
<c:forEach items="${accessionAliases}" var="accessionAlias">
<div>
<c:out value="${accessionAlias.name}" />
<c:if test="${accessionAlias.instCode != ''}">
<a href="<c:url value="/wiews/${accessionAlias.instCode}" />"> ${accessionAlias.instCode} </a>
</c:if>
<c:if test="${accessionAlias.usedBy != ''}">
${accessionAlias.usedBy}
</c:if>
<c:if test="${accessionAlias.lang != ''}">
<c:out value="${accessionAlias.lang}" />
</c:if>
<spring:message code="accession.aliasType.${accessionAlias.aliasType}" />
</div>
</c:forEach>
</div>
</div>
<div class="row">
<div class="col-xs-4"><spring:message code="accession.duplSite" /></div>
<div class="col-xs-8"><c:forEach items="${accession.duplSite.split('[;,]')}" var="duplSite">
<div><spring:message code="${duplSite}" /></div>
</c:forEach></div>
</div>
<c:if test="${accessionExchange ne null}">
<div class="row">
<div class="col-xs-4"><spring:message code="accession.donor.institute" /></div>
<div class="col-xs-8">
<c:if test="${accessionExchange.donorInstitute eq null}">
<c:if test="${accessionAlias.lang != ''}">
<c:out value="${accessionAlias.lang}" />
</c:if>
<spring:message code="accession.aliasType.${accessionAlias.aliasType}" />
</div>
</c:forEach>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.duplSite" />
</div>
<div class="col-xs-8">
<c:forEach items="${accession.duplSite.split('[;,]')}" var="duplSite">
<div>
<spring:message code="${duplSite}" />
</div>
</c:forEach>
</div>
</div>
<c:if test="${accessionExchange ne null}">
<div class="row">
<div class="col-xs-4">
<spring:message code="accession.donor.institute" />
</div>
<div class="col-xs-8">
<c:if test="${accessionExchange.donorInstitute eq null}">
${accessionExchange.donorName}
</c:if>