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; ...@@ -32,7 +32,7 @@ import org.genesys2.server.model.BusinessModel;
*/ */
@Entity @Entity
@Table(name = "accessionbreeding") @Table(name = "accessionbreeding")
public class AllAcqBreeding extends BusinessModel{ public class AccessionBreeding extends BusinessModel{
@Version @Version
private long version = 0; private long version = 0;
...@@ -48,7 +48,7 @@ public class AllAcqBreeding extends BusinessModel{ ...@@ -48,7 +48,7 @@ public class AllAcqBreeding extends BusinessModel{
@Lob @Lob
private String pedigree; private String pedigree;
public AllAcqBreeding() { public AccessionBreeding() {
} }
public long getVersion() { public long getVersion() {
......
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
package org.genesys2.server.persistence.domain; package org.genesys2.server.persistence.domain;
import org.genesys2.server.model.genesys.Accession; 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; 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; ...@@ -27,7 +27,7 @@ import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionAlias; import org.genesys2.server.model.genesys.AccessionAlias;
import org.genesys2.server.model.genesys.AccessionGeo; import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AllAccnames; 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.AccessionCollect;
import org.genesys2.server.model.genesys.AllAcqExchange; import org.genesys2.server.model.genesys.AllAcqExchange;
import org.genesys2.server.model.genesys.ExperimentTrait; import org.genesys2.server.model.genesys.ExperimentTrait;
...@@ -67,7 +67,7 @@ public interface GenesysService { ...@@ -67,7 +67,7 @@ public interface GenesysService {
AccessionCollect listAccessionCollect(Accession accession); AccessionCollect listAccessionCollect(Accession accession);
AllAcqBreeding listAccessionBreeding(Accession accession); AccessionBreeding listAccessionBreeding(Accession accession);
AccessionGeo listAccessionGeo(Accession accession); AccessionGeo listAccessionGeo(Accession accession);
...@@ -132,8 +132,8 @@ public interface GenesysService { ...@@ -132,8 +132,8 @@ public interface GenesysService {
SvalbardData getSvalbardData(Accession accession); SvalbardData getSvalbardData(Accession accession);
void saveCollecting(List<AccessionCollect> all); void saveCollecting(List<AccessionCollect> all);
void saveGeo(List<AccessionGeo> all); void saveGeo(List<AccessionGeo> all);
void saveBreeding(List<AccessionBreeding> all);
void refreshMetadataMethods(); void refreshMetadataMethods();
...@@ -145,4 +145,5 @@ public interface GenesysService { ...@@ -145,4 +145,5 @@ public interface GenesysService {
void removeAliases(List<AccessionAlias> aliases); void removeAliases(List<AccessionAlias> aliases);
} }
...@@ -30,6 +30,7 @@ import org.genesys2.server.model.genesys.Accession; ...@@ -30,6 +30,7 @@ import org.genesys2.server.model.genesys.Accession;
import org.genesys2.server.model.genesys.AccessionAlias; import org.genesys2.server.model.genesys.AccessionAlias;
import org.genesys2.server.model.genesys.AccessionGeo; import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionCollect; 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.Taxonomy;
import org.genesys2.server.model.genesys.AccessionAlias.AliasType; import org.genesys2.server.model.genesys.AccessionAlias.AliasType;
import org.genesys2.server.model.impl.Country; import org.genesys2.server.model.impl.Country;
...@@ -80,6 +81,7 @@ public class BatchRESTServiceImpl implements BatchRESTService { ...@@ -80,6 +81,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
List<Accession> toSave = new ArrayList<Accession>(); List<Accession> toSave = new ArrayList<Accession>();
List<AccessionCollect> toSaveColl = new ArrayList<AccessionCollect>(); List<AccessionCollect> toSaveColl = new ArrayList<AccessionCollect>();
List<AccessionGeo> toSaveGeo = new ArrayList<AccessionGeo>(); List<AccessionGeo> toSaveGeo = new ArrayList<AccessionGeo>();
List<AccessionBreeding> toSaveBreed = new ArrayList<AccessionBreeding>();
for (AccessionJson dataJson : batch.keySet()) { for (AccessionJson dataJson : batch.keySet()) {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
...@@ -127,7 +129,7 @@ public class BatchRESTServiceImpl implements BatchRESTService { ...@@ -127,7 +129,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
updated = true; updated = true;
} }
} }
/* Allow updating Genus */ /* Allow updating Genus */
value = accnJson.get("newGenus"); value = accnJson.get("newGenus");
if (value != null) { if (value != null) {
...@@ -306,6 +308,23 @@ public class BatchRESTServiceImpl implements BatchRESTService { ...@@ -306,6 +308,23 @@ public class BatchRESTServiceImpl implements BatchRESTService {
toSaveGeo.add(accnGeo); 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) { if (updated) {
toSave.add(accession); toSave.add(accession);
} }
...@@ -325,7 +344,11 @@ public class BatchRESTServiceImpl implements BatchRESTService { ...@@ -325,7 +344,11 @@ public class BatchRESTServiceImpl implements BatchRESTService {
genesysService.saveGeo(toSaveGeo); 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 @Override
......
...@@ -39,7 +39,7 @@ import org.genesys2.server.model.genesys.AccessionAlias; ...@@ -39,7 +39,7 @@ import org.genesys2.server.model.genesys.AccessionAlias;
import org.genesys2.server.model.genesys.AccessionGeo; import org.genesys2.server.model.genesys.AccessionGeo;
import org.genesys2.server.model.genesys.AccessionTrait; import org.genesys2.server.model.genesys.AccessionTrait;
import org.genesys2.server.model.genesys.AllAccnames; 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.AccessionCollect;
import org.genesys2.server.model.genesys.AllAcqExchange; import org.genesys2.server.model.genesys.AllAcqExchange;
import org.genesys2.server.model.genesys.ExperimentAccessionTrait; import org.genesys2.server.model.genesys.ExperimentAccessionTrait;
...@@ -225,7 +225,7 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset ...@@ -225,7 +225,7 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
} }
@Override @Override
public AllAcqBreeding listAccessionBreeding(Accession accession) { public AccessionBreeding listAccessionBreeding(Accession accession) {
if (accession == null || accession.getId() == null) if (accession == null || accession.getId() == null)
return null; return null;
return accessionBreedingRepository.findByAccession(accession); return accessionBreedingRepository.findByAccession(accession);
...@@ -470,6 +470,12 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset ...@@ -470,6 +470,12 @@ public class GenesysServiceImpl implements GenesysService, TraitService, Dataset
public void saveGeo(List<AccessionGeo> all) { public void saveGeo(List<AccessionGeo> all) {
accessionGeoRepository.save(all); accessionGeoRepository.save(all);
} }
@Override
@Transactional(readOnly = false)
public void saveBreeding(List<AccessionBreeding> all) {
accessionBreedingRepository.save(all);
}
@Override @Override
public long countAvailable(Set<Long> accessionIds) { public long countAvailable(Set<Long> accessionIds) {
......
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