Commit 5c94f58d authored by Matija Obreza's avatar Matija Obreza

CV: Removed AccessionSource.SourceType enum

parent 2b3ff1ae
......@@ -40,18 +40,6 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
public class AccessionSource extends CooperatorOwnedModel implements Copyable<AccessionSource> {
private static final long serialVersionUID = 8820879032034410951L;
/**
* ACCESSION_SOURCE_TYPE code_group
*/
public static enum SourceType {
/** "COLLECTED" Collection source event */
COLLECTED,
/** "DEVELOPED" Developer source event */
DEVELOPED,
/** "DONATED" Donor source event */
DONATED,
}
/**
* ACCESSION_SOURCE_HABITAT_TYPE code_group
*/
......@@ -147,7 +135,7 @@ public class AccessionSource extends CooperatorOwnedModel implements Copyable<Ac
@Basic
@Column(name = "source_type_code", nullable = false, length = 20)
@CodeValueField("ACCESSION_SOURCE_TYPE")
@CodeValueField(CommunityCodeValues.ACCESSION_SOURCE_TYPE)
private String sourceTypeCode;
@Basic
......
......@@ -37,6 +37,7 @@ import org.gringlobal.model.TaxonomyCropMap;
import org.gringlobal.model.TaxonomyFamily;
import org.gringlobal.model.TaxonomyGenus;
import org.gringlobal.model.TaxonomySpecies;
import org.gringlobal.model.community.CommunityCodeValues;
import org.gringlobal.persistence.AccessionRepository;
import org.gringlobal.persistence.GeographyRepository;
import org.gringlobal.persistence.SiteRepository;
......@@ -398,10 +399,10 @@ public class GenesysDownloader implements InitializingBean {
if (donorWiews != null || donorName != null) {
sources = getOrCreateAccessionSources(a);
AccessionSource donorSource = sources.stream().filter((source) -> source.getSourceTypeCode() == AccessionSource.SourceType.DONATED.name()).findFirst().orElse(null);
AccessionSource donorSource = sources.stream().filter((source) -> source.getSourceTypeCode() == CommunityCodeValues.ACCESSION_SOURCE_TYPE_DONATED.value).findFirst().orElse(null);
if (donorSource == null) {
donorSource = new AccessionSource();
donorSource.setSourceTypeCode(AccessionSource.SourceType.DONATED.name());
donorSource.setSourceTypeCode(CommunityCodeValues.ACCESSION_SOURCE_TYPE_DONATED.value);
donorSource.setAccession(a);
sources.add(donorSource);
}
......@@ -419,10 +420,10 @@ public class GenesysDownloader implements InitializingBean {
ObjectNode nodeGeo = acce.hasNonNull("geo") ? (ObjectNode) acce.get("geo") : null;
if (origCty != null || nodeGeo != null || nodeCollecting != null) {
sources = getOrCreateAccessionSources(a);
AccessionSource collectingSource = sources.stream().filter((source) -> source.getSourceTypeCode() == AccessionSource.SourceType.COLLECTED.name()).findFirst().orElse(null);
AccessionSource collectingSource = sources.stream().filter((source) -> source.getSourceTypeCode() == CommunityCodeValues.ACCESSION_SOURCE_TYPE_COLLECTED.value).findFirst().orElse(null);
if (collectingSource == null) {
collectingSource = new AccessionSource();
collectingSource.setSourceTypeCode(AccessionSource.SourceType.COLLECTED.name());
collectingSource.setSourceTypeCode(CommunityCodeValues.ACCESSION_SOURCE_TYPE_COLLECTED.value);
collectingSource.setAccession(a);
sources.add(collectingSource);
}
......
......@@ -179,12 +179,12 @@ public abstract class AbstractServicesTest extends AbstractServiceTest {
}
protected AccessionSource addAccessionSourceToDB(Accession accession) {
return addAccessionSourceToDB(accession, AccessionSource.SourceType.COLLECTED);
return addAccessionSourceToDB(accession, CommunityCodeValues.ACCESSION_SOURCE_TYPE_COLLECTED.value);
}
protected AccessionSource addAccessionSourceToDB(Accession accession, AccessionSource.SourceType type) {
protected AccessionSource addAccessionSourceToDB(Accession accession, String sourceTypeCode) {
AccessionSource source = new AccessionSource();
source.setSourceTypeCode(type.name());
source.setSourceTypeCode(sourceTypeCode);
source.setAccession(accession);
return accessionSourceRepository.save(source);
......
......@@ -26,6 +26,7 @@ import org.apache.commons.lang3.RandomUtils;
import org.gringlobal.api.InvalidApiUsageException;
import org.gringlobal.custom.elasticsearch.SearchException;
import org.gringlobal.model.*;
import org.gringlobal.model.community.CommunityCodeValues;
import org.gringlobal.persistence.AccessionInvGroupMapRepository;
import org.gringlobal.persistence.AccessionInvGroupRepository;
import org.gringlobal.service.AccessionInvGroupService;
......@@ -137,7 +138,7 @@ public class AccessionServiceTest extends AbstractServicesTest {
// create AccessionSource
AccessionSource source = new AccessionSource();
source.setSourceTypeCode(AccessionSource.SourceType.COLLECTED.name());
source.setSourceTypeCode(CommunityCodeValues.ACCESSION_SOURCE_TYPE_COLLECTED.value);
source.setAccession(accession);
// add AccessionSource to accession
......@@ -162,7 +163,7 @@ public class AccessionServiceTest extends AbstractServicesTest {
// create AccessionSource
AccessionSource source = new AccessionSource();
source.setSourceTypeCode(AccessionSource.SourceType.COLLECTED.name());
source.setSourceTypeCode(CommunityCodeValues.ACCESSION_SOURCE_TYPE_COLLECTED.value);
source.setAccession(a);
// add AccessionSource to accession
......
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