Commit 5fd3b72c authored by Matija Obreza's avatar Matija Obreza
Browse files

REST API updated for bredCode, ancest

parent 0eb2e7e5
......@@ -32,7 +32,7 @@ import org.genesys2.server.model.BusinessModel;
*/
@Entity
@Table(name = "accessionbreeding")
public class AllAcqBreeding extends BusinessModel{
public class AccessionBreeding extends BusinessModel{
@Version
private long version = 0;
......@@ -48,7 +48,7 @@ public class AllAcqBreeding extends BusinessModel{
@Lob
private String pedigree;
public AllAcqBreeding() {
public AccessionBreeding() {
}
public long getVersion() {
......
......@@ -17,11 +17,11 @@
package org.genesys2.server.persistence.domain;
import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AllAcqBreeding;
import org.genesys2.server.model.genesys.AccessionBreeding;
import org.springframework.data.jpa.repository.JpaRepository;
public interface AccessionBreedingRepository extends JpaRepository<AllAcqBreeding, Long> {
public interface AccessionBreedingRepository extends JpaRepository<AccessionBreeding, Long> {
AllAcqBreeding findByAccession(Accession accession);
AccessionBreeding findByAccession(Accession accession);
}
......@@ -27,7 +27,7 @@ import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionAlias;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AllAccnames;
import org.genesys2.server.model.genesys.AllAcqBreeding;
import org.genesys2.server.model.genesys.AccessionBreeding;
import org.genesys2.server.model.genesys.AccessionCollect;
import org.genesys2.server.model.genesys.AllAcqExchange;
import org.genesys2.server.model.genesys.ExperimentTrait;
......@@ -67,7 +67,7 @@ public interface GenesysService {
AccessionCollect listAccessionCollect(Accession accession);
AllAcqBreeding listAccessionBreeding(Accession accession);
AccessionBreeding listAccessionBreeding(Accession accession);
AccessionGeo listAccessionGeo(Accession accession);
......@@ -132,8 +132,8 @@ public interface GenesysService {
SvalbardData getSvalbardData(Accession accession);
void saveCollecting(List<AccessionCollect> all);
void saveGeo(List<AccessionGeo> all);
void saveBreeding(List<AccessionBreeding> all);
void refreshMetadataMethods();
......@@ -145,4 +145,5 @@ public interface GenesysService {
void removeAliases(List<AccessionAlias> aliases);
}
......@@ -30,6 +30,7 @@ import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionAlias;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionCollect;
import org.genesys2.server.model.genesys.AccessionBreeding;
import org.genesys2.server.model.genesys.Taxonomy;
import org.genesys2.server.model.genesys.AccessionAlias.AliasType;
import org.genesys2.server.model.impl.Country;
......@@ -80,6 +81,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
List<Accession> toSave = new ArrayList<Accession>();
List<AccessionCollect> toSaveColl = new ArrayList<AccessionCollect>();
List<AccessionGeo> toSaveGeo = new ArrayList<AccessionGeo>();
List<AccessionBreeding> toSaveBreed = new ArrayList<AccessionBreeding>();
for (AccessionJson dataJson : batch.keySet()) {
if (LOG.isDebugEnabled())
......@@ -306,6 +308,23 @@ public class BatchRESTServiceImpl implements BatchRESTService {
toSaveGeo.add(accnGeo);
}
if (accnJson.has("bredCode") || accnJson.has("ancest")) {
AccessionBreeding accnBred = genesysService.listAccessionBreeding(accession);
if (accnBred == null) {
accnBred = new AccessionBreeding();
accnBred.setAccession(accession);
}
value = accnJson.get("bredCode");
if (value != null) {
accnBred.setBreederCode(value.isTextual() ? value.asText() : null);
}
value = accnJson.get("ancest");
if (value != null) {
accnBred.setPedigree(value.isTextual() ? value.asText() : null);
}
toSaveBreed.add(accnBred);
}
if (updated) {
toSave.add(accession);
}
......@@ -325,7 +344,11 @@ public class BatchRESTServiceImpl implements BatchRESTService {
genesysService.saveGeo(toSaveGeo);
}
return toSave.size() > 0 || toSaveColl.size() > 0 || toSaveGeo.size() > 0;
if (toSaveBreed.size() > 0) {
genesysService.saveBreeding(toSaveBreed);
}
return toSave.size() > 0 || toSaveColl.size() > 0 || toSaveGeo.size() > 0 || toSaveBreed.size() > 0;
}
@Override
......
......@@ -39,7 +39,7 @@ import org.genesys2.server.model.genesys.AccessionAlias;
import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionTrait;
import org.genesys2.server.model.genesys.AllAccnames;
import org.genesys2.server.model.genesys.AllAcqBreeding;
import org.genesys2.server.model.genesys.AccessionBreeding;
import org.genesys2.server.model.genesys.AccessionCollect;
import org.genesys2.server.model.genesys.AllAcqExchange;
import org.genesys2.server.model.genesys.ExperimentAccessionTrait;
......@@ -225,7 +225,7 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
}
@Override
public AllAcqBreeding listAccessionBreeding(Accession accession) {
public AccessionBreeding listAccessionBreeding(Accession accession) {
if (accession == null || accession.getId() == null)
return null;
return accessionBreedingRepository.findByAccession(accession);
......@@ -471,6 +471,12 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
accessionGeoRepository.save(all);
}
@Override
@Transactional(readOnly = false)
public void saveBreeding(List<AccessionBreeding> all) {
accessionBreedingRepository.save(all);
}
@Override
public long countAvailable(Set<Long> accessionIds) {
if (accessionIds == null || accessionIds.size() == 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment