Commit c619f269 authored by Matija Obreza's avatar Matija Obreza

SGSV import allowing for multiple deposits

parent 2b17d953
Genesys and Svalbard Global Seed Vault
======================================
September 2016: Documentation commit {buildNumber}
:revnumber: {projectVersion}
:doctype: book
:toc: left
:toclevels: 5
:icons: font
:numbered:
:source-highlighter: pygments
:pygments-css: class
:pygments-linenums-mode: table
Genesys periodically synchronizes data from the http://www.nordgen.org/sgsv/[Svalbard Global Seed Vault] (**SGSV**) to link Genesys accessions with accessions backed up at Svalbard.
== SGSV database
SGSV database is a publicly accessible resource available at http://www.nordgen.org/sgsv/.
=== Seed samples database
The information on samples stored in SGSV is provided in `CSV` format at accessible at http://www.nordgen.org/sgsv/download.php?file=/scope/sgsv/files/sgsv_templates.tab[Seed samples download] link.
[cols="1,4", options="header"]
.SGSV Seed samples CSV format
|===
|Column header|Description
|sgsv_id|ID of the seed sample record in SGSV database. Unique.
|institute_code|FAO WIEWS Institute code (`INSTCODE`)
|deposit_box_number|Deposit box number. Numeric.
|collection_name|Collection name
|accession_number|Accession Number (`ACCENUMB`)
|full_scientific_name|Full scientific name of the accession
|country_of_collection_or_source|MCPD `ORIGCTY`
|number_of_seeds|Number of seeds. Count.
|regeneration_month_and_year|Information about regeneration date of sample.
|other_accession_designations|MCPD `OTHERNUMB`
|provider_institute_code|...
|accession_url|URL to detailed accession information (`ACCEURL`)
|country_code|
|country_name|
|continent_name|
|seeds|
|genus|MCPD `GENUS`
|species_epithet|MCPD `SPECIES`
|species|
|taxon_name|
|date_of_deposit|Date of deposit
|date_of_dataset|Date of dataset
|sgsv_template_id|
|box_id|Box ID reference.
|sgsv_taxon_id|Reference to SGSV taxonomy table
|taxon_authority|MCPD `SPAUTHOR`
|infraspesific_epithet|MCPD `SUBTAXA`
|vernacular_name|Crop name (MCPD `CROPNAME`)
|itis_tsn|
|sgsv_genus_id|Reference to SGSV taxonomy table
|accession_name|Accession name (`ACCENAME`)
|===
== Linking SGSV records with Genesys
Genesys attempts to link records based on the institute code (`INSTCODE`) and
accession number (`ACCENUMB`). Genebanks **must** use their assigned `INSTCODE` and the correct `ACCENUMB` from their datasets when they publish data on SGSV and on Genesys in order to appropriately link the records.
== Multiple deposits
Genesys gracefully handles multiple deposits of seed to SGSV for a single accession. Information on all seed deposits is rendered on the accession details page.
package org.genesys2.server.model.elastic;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
......@@ -16,10 +17,11 @@ import org.genesys2.server.model.genesys.AccessionData;
import org.genesys2.server.model.genesys.AccessionExchange;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionRemark;
import org.genesys2.server.model.genesys.SvalbardData;
import org.genesys2.server.model.genesys.SvalbardDeposit;
import org.genesys2.server.model.impl.AccessionList;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.Organization;
import org.genesys2.server.service.IndexAliasConstants;
import org.genesys2.util.MCPDUtil;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Version;
......@@ -31,7 +33,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
/**
* <code>AccessionDetails</code> is used in Elasticsearch mapping
*/
@Document(indexName = "genesys", type = "mcpd", refreshInterval = "60s")
@Document(indexName = IndexAliasConstants.INDEX_PASSPORT, type = IndexAliasConstants.PASSPORT_TYPE, refreshInterval = "60s")
public class AccessionDetails {
private static final Logger LOG = Logger.getLogger(AccessionDetails.class);
......@@ -66,7 +68,8 @@ public class AccessionDetails {
private Taxonomy taxonomy;
@Field(type = FieldType.Nested)
private ArrayList<Alias> aliases;
private Svalbard sgsv;
@Field(type = FieldType.Nested)
private ArrayList<Svalbard> sgsvDeposits;
private boolean inSgsv;
@Field(type = FieldType.Nested, store = false)
private ArrayList<Remark> remarks;
......@@ -120,6 +123,7 @@ public class AccessionDetails {
ad.sampStat = accession.getSampleStatus();
ad.storage = new ArrayList<Integer>(accession.getStoRage());
ad.lists = new HashSet<String>();
ad.inSgsv = accession.getInSvalbard() != null && accession.getInSvalbard() == true ? true : false;
for (AccessionList al : accession.getAccessionId().getLists()) {
ad.lists.add(al.getUuid().toString());
}
......@@ -142,9 +146,11 @@ public class AccessionDetails {
}
}
public void svalbard(SvalbardData svalbardData) {
this.sgsv = Svalbard.from(svalbardData);
this.inSgsv = this.sgsv != null;
public void sgsvDeposits(Collection<SvalbardDeposit> deposits) {
if (deposits != null) {
this.sgsvDeposits = new ArrayList<>();
deposits.stream().forEach(deposit -> this.sgsvDeposits.add(Svalbard.from(deposit)));
}
}
public void remarks(List<AccessionRemark> listAccessionRemarks) {
......@@ -338,12 +344,12 @@ public class AccessionDetails {
this.aliases = aliases;
}
public Svalbard getSgsv() {
return sgsv;
public ArrayList<Svalbard> getSgsvDeposits() {
return sgsvDeposits;
}
public void setSgsv(Svalbard sgsv) {
this.sgsv = sgsv;
public void setSgsvDeposits(ArrayList<Svalbard> sgsvDeposits) {
this.sgsvDeposits = sgsvDeposits;
}
public ArrayList<Remark> getRemarks() {
......
package org.genesys2.server.model.elastic;
import org.genesys2.server.model.genesys.SvalbardData;
import java.util.Date;
import org.genesys2.server.model.genesys.SvalbardDeposit;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldIndex;
import org.springframework.data.elasticsearch.annotations.FieldType;
/**
* One SGSV deposit
*/
public class Svalbard {
private Float qty;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String boxNo;
@Field(index = FieldIndex.not_analyzed, type = FieldType.String)
private String depositDate;
@Field(index = FieldIndex.not_analyzed, type = FieldType.Date)
private Date depositDate;
public static Svalbard from(SvalbardData svalbardData) {
public static Svalbard from(SvalbardDeposit svalbardData) {
if (svalbardData == null)
return null;
Svalbard s = new Svalbard();
......@@ -39,11 +44,11 @@ public class Svalbard {
this.boxNo = boxNo;
}
public String getDepositDate() {
public Date getDepositDate() {
return depositDate;
}
public void setDepositDate(String depositDate) {
public void setDepositDate(Date depositDate) {
this.depositDate = depositDate;
}
......
/*
* Copyright 2016 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.model.genesys;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.Index;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.genesys2.server.model.impl.FaoInstitute;
import org.springframework.data.annotation.CreatedDate;
/**
* This is a copy of the SGVS seed samples record. An accession may be deposited to SGSV several times.
*/
@Entity
@Table(name = "sgsvdeposit", indexes = { @Index(name = "IX_sgsvAID3", unique = false, columnList = "instId,genus,accenumb") })
public class SvalbardDeposit implements AccessionRelated, java.io.Serializable {
private static final long serialVersionUID = -5015395025122055617L;
@Id
@Column(name = "id")
// SGSV record ID. This is not auto-generated as we mirror SGSV data
private Long id;
@ManyToOne(optional = true, cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "providerId")
private FaoInstitute provider;
@ManyToOne(optional = false, cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "instId")
private FaoInstitute institute;
@Column(name = "accenumb", nullable = false, length = 50)
private String acceNumb;
@Column(length = 50)
private String genus;
// Genesys accession reference
@ManyToOne(optional = true, cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(name = "acceId")
private AccessionId accession;
private Float quantity;
@Temporal(TemporalType.DATE)
private Date depositDate;
@Column(length = 20)
private String boxNo;
@Column(name = "regen", length = 50)
private String regenerationInformation;
@CreatedDate
@Column(name = "createdDate")
private Date createdDate;
public String getAcceNumb() {
return acceNumb;
}
@Override
public AccessionId getAccession() {
return accession;
}
public String getBoxNo() {
return boxNo;
}
public String getBoxNumber() {
return boxNo;
}
public Long getId() {
return id;
}
public Float getQuantity() {
return quantity;
}
public void setAcceNumb(String acceNumb) {
this.acceNumb = acceNumb;
}
public void setAccession(AccessionId accession) {
this.accession = accession;
}
public void setBoxNo(String boxNo) {
this.boxNo = boxNo;
}
public void setBoxNumber(String boxNo) {
this.boxNo = boxNo;
}
public void setId(Long id) {
this.id = id;
}
public void setQuantity(Float quantity) {
this.quantity = quantity;
}
public String getGenus() {
return genus;
}
public void setGenus(String genus) {
this.genus = genus;
}
public Date getCreatedDate() {
return createdDate;
}
protected void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public FaoInstitute getProvider() {
return provider;
}
public void setProvider(FaoInstitute provider) {
this.provider = provider;
}
public FaoInstitute getInstitute() {
return institute;
}
public void setInstitute(FaoInstitute institute) {
this.institute = institute;
}
public Date getDepositDate() {
return depositDate;
}
public void setDepositDate(Date depositDate) {
this.depositDate = depositDate;
}
public String getRegenerationInformation() {
return regenerationInformation;
}
public void setRegenerationInformation(String regenerationInformation) {
this.regenerationInformation = regenerationInformation;
}
}
......@@ -88,7 +88,7 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Query("select a from Accession a where a.institute.code = ?1 and a.accessionName = ?2")
Accession findByInstituteCodeAndAccessionName(String instCode, String accessionName);
@Query("select a from Accession a where a.accessionName=?2 and (a.institute.code=?1 or a.institute.codeSGSV=?1) and a.taxonomy.genus=?3")
@Query("select distinct a from Accession a where a.accessionName=?2 and (a.institute.code=?1 or a.institute.codeSGSV=?1) and a.taxonomy.genus=?3")
Accession findOneSGSV(String instCode, String acceNumb, String genus);
@Query("select a from Accession a where a.institute.code=:instCode and a.accessionName=:acceNumb and a.taxonomy.genus=:genus")
......@@ -100,10 +100,6 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Query("select a.id from Accession a where a.id in ( ?1 ) and a.historic = false and (a.availability is null or a.availability = true) and a.institute.allowMaterialRequests = true")
Set<Long> filterAvailableForDistribution(Set<Long> accessionIds);
@Modifying
@Query("update Accession a set a.inSvalbard = true where a in ?1")
void setInSvalbard(List<Accession> matching);
@Query("select distinct a.institute from Accession a where a.id in ( ?1 )")
List<FaoInstitute> findDistinctInstitutesFor(Set<Long> accessionIds);
......@@ -126,4 +122,8 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
Stream<Accession> streamAll();
public long countByHistoric(boolean historic);
@Query(nativeQuery=true, value="update accession a inner join sgsvdeposit sd on sd.acceId=a.id set a.inSGSV=true where sd.id in (?1)")
@Modifying
public void setInSvalbard(List<Long> sgsvId);
}
......@@ -20,18 +20,52 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.genesys2.server.model.genesys.SvalbardData;
import org.genesys2.server.model.genesys.AccessionId;
import org.genesys2.server.model.genesys.SvalbardDeposit;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
public interface SvalbardRepository extends JpaRepository<SvalbardData, Long> {
public interface SvalbardRepository extends JpaRepository<SvalbardDeposit, Long> {
List<SvalbardDeposit> findByAccession(AccessionId accession);
@Query("from SvalbardDeposit sd where sd.accession.id in (?1)")
List<SvalbardDeposit> findAllFor(Collection<Long> accessionIds);
@Query("delete from SvalbardDeposit sd where sd.id in (?1)")
@Modifying
void deleteById(Set<Long> collect);
/*
* Based on: select sd.id, sd.accenumb svacce,a.accenumb acce, sd.genus svgenus, t.genus, sd.instId svinst,
* a.instituteId inst from sgsvdeposit sv left join accession a on a.instituteId=sd.instId and
* a.accenumb=sd.accenumb inner join taxonomy2 t on t.id=a.taxonomyId2 and t.genus=sd.genus limit 10
*/
@Query(nativeQuery = true, value = "update sgsvdeposit sd inner join accession a on a.instituteId=sd.instId and a.accenumb=sd.accenumb inner join taxonomy2 t on t.id=a.taxonomyId2 and t.genus=sd.genus set sd.acceId=a.id where sd.id in (?1)")
@Modifying
@Query("delete from SvalbardData sd where sd.id in ?1")
void deleteForAccessions(Set<Long> accessionIds);
int linkDirectly(List<Long> sgsvIds);
@Query("from SvalbardData sd where sd.id in ?1")
List<SvalbardData> findAllFor(Collection<Long> accessionIds);
/*
* Based on:
*
* select sd.*, i.code, ii.code, a.accenumb, t.genus from sgsvdeposit sd inner join faoinstitute i on i.id=sd.instId
* inner join accession a on a.accenumb=sd.accenumb inner join faoinstitute ii on ii.codeSGSV=i.code inner join
* taxonomy2 t on t.id=a.taxonomyId2 and t.genus=sd.genus limit 10;
*/
@Query(nativeQuery = true, value = "update sgsvdeposit sd inner join faoinstitute i on i.id=sd.instId inner join accession a on a.accenumb=sd.accenumb inner join faoinstitute ii on ii.codeSGSV=i.code inner join taxonomy2 t on t.id=a.taxonomyId2 and t.genus=sd.genus set sd.acceId=a.id where sd.id in (?1)")
@Modifying
int linkInDirectly(List<Long> sgsvIds);
/*
* Link accessions to SGSV data by their alternate names.
*
* select sd.accenumb svnumb, a.acceNumb, aa.name alias, i.code svinst, aa.usedBy instcode, sd.genus svgenus,
* t.genus from sgsvdeposit sd inner join faoinstitute i on i.id=sd.instId inner join accessionalias aa on
* aa.name=sd.accenumb and (aa.usedBy=i.code or aa.usedBy=i.codeSGSV) inner join accession a on a.id=aa.accessionId
* inner join taxonomy2 t on t.id=a.taxonomyId2 and t.genus=sd.genus limit 100;
*/
@Query(nativeQuery = true, value = "update sgsvdeposit sd inner join faoinstitute i on i.id=sd.instId inner join accessionalias aa on aa.name=sd.accenumb and (aa.usedBy=i.code or aa.usedBy=i.codeSGSV) inner join accession a on a.id=aa.accessionId inner join taxonomy2 t on t.id=a.taxonomyId2 and t.genus=sd.genus set sd.acceId=a.id where sd.id in (?1)")
@Modifying
int linkByAlternativeName(List<Long> sgsvIds);
}
......@@ -42,7 +42,7 @@ import org.genesys2.server.model.genesys.Method;
import org.genesys2.server.model.genesys.PDCI;
import org.genesys2.server.model.genesys.PDCIStatistics;
import org.genesys2.server.model.genesys.PhenoStatistics;
import org.genesys2.server.model.genesys.SvalbardData;
import org.genesys2.server.model.genesys.SvalbardDeposit;
import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.impl.AccessionIdentifier3;
import org.genesys2.server.model.impl.Country;
......@@ -110,8 +110,6 @@ public interface GenesysService {
Page<Accession> listAccessions(Collection<Long> accessionIds, Pageable pageable);
List<Accession> listAccessionsSGSV(List<? extends AccessionIdentifier3> accns);
Accession getAccession(AccessionIdentifier3 aid3) throws NonUniqueAccessionException;
Accession getAccession(String instCode, String acceNumb, String genus) throws NonUniqueAccessionException;
......@@ -135,8 +133,6 @@ public interface GenesysService {
List<Accession> saveAccessions(FaoInstitute institute, List<Accession> matching);
List<SvalbardData> saveSvalbards(List<SvalbardData> svalbards);
long countAvailableForDistribution(Set<Long> accessionIds);
Set<Long> filterAvailableForDistribution(Set<Long> accessionIds);
......@@ -147,7 +143,7 @@ public interface GenesysService {
void updateAccessionCount(FaoInstitute institute);
SvalbardData getSvalbardData(AccessionId accession);
List<SvalbardDeposit> getSvalbardData(AccessionId accession);
List<AccessionCollect> saveCollecting(List<AccessionCollect> all);
......@@ -175,8 +171,6 @@ public interface GenesysService {
List<AccessionHistoric> removeAccessions(FaoInstitute institute, List<Accession> toDelete);
void setInSvalbard(List<Accession> matching);
void addAccessions(List<Accession> accessions);
long countAll();
......@@ -239,7 +233,7 @@ public interface GenesysService {
public List<AccessionAlias> names = null;
public AccessionExchange exch = null;
public List<AccessionRemark> remarks = null;
public SvalbardData svalbard = null;
public List<SvalbardDeposit> sgsvDeposits = null;
}
List<AllStuff> loadAllStuff(Collection<Long> accessionIds);
......@@ -266,5 +260,6 @@ public interface GenesysService {
void regenerateAccessionSequentialNumber();
List<SvalbardDeposit> saveSvalbards(List<SvalbardDeposit> svalbards);
}
......@@ -321,7 +321,9 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
}
if (ids.isEmpty()) {
LOG.info("Skipping empty updateAll.");
if (LOG.isTraceEnabled()) {
LOG.trace("Skipping empty updateAll.");
}
return;
}
......
......@@ -32,6 +32,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -64,7 +65,7 @@ import org.genesys2.server.model.genesys.PDCI;
import org.genesys2.server.model.genesys.PDCIStatistics;
import org.genesys2.server.model.genesys.PhenoStatistics;
import org.genesys2.server.model.genesys.SelfCopy;
import org.genesys2.server.model.genesys.SvalbardData;
import org.genesys2.server.model.genesys.SvalbardDeposit;
import org.genesys2.server.model.genesys.Taxonomy2;
import org.genesys2.server.model.genesys.TraitCode;
import org.genesys2.server.model.impl.AccessionIdentifier3;
......@@ -117,6 +118,8 @@ import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.acls.domain.BasePermission;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.opencsv.CSVWriter;
......@@ -269,52 +272,6 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return accessionRepository.findById(accessionIds, pageable);
}
@Override
public List<Accession> listAccessionsSGSV(List<? extends AccessionIdentifier3> accns) {
final List<Accession> result = new ArrayList<Accession>(accns.size());
for (final AccessionIdentifier3 aid3 : accns) {
Accession accn = null;
try {
accn = accessionRepository.findOneSGSV(aid3.getHoldingInstitute(), aid3.getAccessionName(), aid3.getGenus());
} catch (IncorrectResultSizeDataAccessException e) {
LOG.warn("Duplicate entry for " + aid3);
}
if (accn != null) {
result.add(accn);
} else {
try {
Accession accnByAlias = accessionAliasRepository.findAccession(aid3.getHoldingInstitute(), aid3.getAccessionName(), AccessionAlias.AliasType.OTHERNUMB.getId());
if (accnByAlias != null) {
LOG.info("Found accession by alias " + accnByAlias);
// Genus must match
if (StringUtils.equalsIgnoreCase(aid3.getGenus(), accnByAlias.getTaxonomy().getGenus()))
result.add(accnByAlias);
else {
LOG.info("... but genus doesn't match");
result.add(null);
}
} else {
result.add(null);
if (LOG.isDebugEnabled()) {
// Only log full miss
LOG.debug("No accession " + aid3);
}
}
} catch (IncorrectResultSizeDataAccessException e) {
LOG.warn("Multple accessions with alias " + aid3);
result.add(null);
}
}
}
return result;
}
@Override
public Accession getAccession(AccessionIdentifier3 aid3) throws NonUniqueAccessionException {
try {
......@@ -393,7 +350,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
ad.collect(all.collect);
ad.breeding(all.bred);
ad.geo(all.geo);
ad.svalbard(all.svalbard);
ad.sgsvDeposits(all.sgsvDeposits);
ad.remarks(all.remarks);
// ad.traits(listMethods(accession),
// getAccessionTraitValues(accession));
......@@ -448,11 +405,11 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
}
@Override
public SvalbardData getSvalbardData(AccessionId accession) {
public List<SvalbardDeposit> getSvalbardData(AccessionId accession) {
if (accession == null) {
return null;
}
return svalbardRepository.findOne(accession.getId());
return svalbardRepository.findByAccession(accession);
}
@Override
......@@ -499,7 +456,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
all.geo = listAccessionGeo(accession.getAccessionId());
all.names = listAccessionAliases(accession.getAccessionId());
all.remarks = listAccessionRemarks(accession.getAccessionId());
all.svalbard = getSvalbardData(accession.getAccessionId());
all.sgsvDeposits = getSvalbardData(accession.getAccessionId());
return all;
}
......@@ -522,8 +479,9 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
a.getAccessionId().getLists().size();
// Don't use a#getStorage()
a.getStoRage().size();
all.names = new ArrayList<AccessionAlias>();
all.remarks = new ArrayList<AccessionRemark>();
all.names = new ArrayList<>();
all.remarks = new ArrayList<>();
all.sgsvDeposits = new ArrayList<>();
}
for (AccessionCollect c : accessionCollectRepository.findAllFor(accessionIds)) {
......@@ -546,9 +504,9 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
all.exch = e;
}
for (SvalbardData e : svalbardRepository.findAllFor(accessionIds)) {
AllStuff all = map.get(e.getId());
all.svalbard = e;
for (SvalbardDeposit e : svalbardRepository.findAllFor(accessionIds)) {
AllStuff all = map.get(e.getAccession().getId());
all.sgsvDeposits.add(e);
}
for (AccessionAlias aa : accessionAliasRepository.findAllFor(accessionIds)) {
......@@ -735,15 +693,6 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
instituteRepository.save(institute);
}
@Override
@Transactional(readOnly = false)
@CacheEvict(value = "statistics", allEntries = true)
public void setInSvalbard(List<Accession> matching) {
if (matching.size() > 0) {
accessionRepository.setInSvalbard(matching);
}
}
/**
* @deprecated Should be removed
*/
......@@ -836,14 +785,68 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return deleted;
}
/**
* Update {@link SvalbardDeposit} data and link with Genesys accessions. The primary key for {@link SvalbardDeposit}
* is the <code>sgsv_id</code> as provided by NordGen.
*
* Any existing SGSV records are first deleted. Inserted and linked with accessions in this method.
*
* @param svalbardDeposits