Commit 2b3ff1ae authored by Matija Obreza's avatar Matija Obreza

Annotated fields with CodeValueField

- Added community code values
parent 9a73bc16
......@@ -19,6 +19,7 @@ import javax.persistence.*;
import org.genesys.blocks.model.Copyable;
import org.gringlobal.component.elastic.ElasticTrigger;
import org.gringlobal.custom.validation.javax.CodeValueField;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonProperty;
......@@ -46,6 +47,7 @@ public class AccessionInvName extends CooperatorOwnedModel implements ElasticTri
@Basic
@Column(name = "category_code", nullable = false, length = 20)
@CodeValueField("ACCESSION_NAME_TYPE")
private String categoryCode;
@Basic
......
......@@ -22,6 +22,8 @@ import java.util.List;
import javax.persistence.*;
import org.genesys.blocks.model.Copyable;
import org.gringlobal.custom.validation.javax.CodeValueField;
import org.gringlobal.model.community.CommunityCodeValues;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnore;
......@@ -145,10 +147,12 @@ public class AccessionSource extends CooperatorOwnedModel implements Copyable<Ac
@Basic
@Column(name = "source_type_code", nullable = false, length = 20)
@CodeValueField("ACCESSION_SOURCE_TYPE")
private String sourceTypeCode;
@Basic
@Column(name = "acquisition_source_code", length = 20)
@CodeValueField("ACCESSION_SOURCE_HABITAT_TYPE")
private String acquisitionSource;
@Basic
......@@ -158,6 +162,7 @@ public class AccessionSource extends CooperatorOwnedModel implements Copyable<Ac
@Basic
@Column(name = "collected_form_code", length = 20)
@CodeValueField(CommunityCodeValues.GERMPLASM_FORM)
private String collectedFormCode;
@Basic
......@@ -194,6 +199,7 @@ public class AccessionSource extends CooperatorOwnedModel implements Copyable<Ac
@Basic
@Column(name = "georeference_protocol_code", length = 20)
@CodeValueField("GEOREFERENCE_PROTOCOL")
private String georeferenceProtocolCode;
@Basic
......@@ -229,6 +235,7 @@ public class AccessionSource extends CooperatorOwnedModel implements Copyable<Ac
@Basic
@Column(name = "source_date_code", length = 20)
@CodeValueField(CommunityCodeValues.DATE_FORMAT)
private String sourceDateCode;
@Basic
......@@ -236,6 +243,7 @@ public class AccessionSource extends CooperatorOwnedModel implements Copyable<Ac
@Basic
@Column(name = "unit_quantity_collected_code", length = 20)
@CodeValueField(CommunityCodeValues.UNIT_OF_QUANTITY)
private String unitQuantityCollectedCode;
@JsonIgnore
......
......@@ -34,6 +34,20 @@ public abstract class CommunityCodeValues {
public static final String UNIT_OF_QUANTITY = "UNIT_OF_QUANTITY";
public static final CodeValueDef UNIT_OF_QUANTITY_SEED;
public static final String ACCESSION_SOURCE_TYPE = "ACCESSION_SOURCE_TYPE";
public static final CodeValueDef ACCESSION_SOURCE_TYPE_COLLECTED;
public static final CodeValueDef ACCESSION_SOURCE_TYPE_DEVELOPED;
public static final CodeValueDef ACCESSION_SOURCE_TYPE_DONATED;
public static final String ACCESSION_NAME_TYPE = "ACCESSION_NAME_TYPE";
public static final CodeValueDef ACCESSION_NAME_TYPE_COLLECTOR;
public static final CodeValueDef ACCESSION_NAME_TYPE_CULTIVAR;
public static final CodeValueDef ACCESSION_NAME_TYPE_DONOR;
public static final CodeValueDef ACCESSION_NAME_TYPE_DEVELOPER;
public static final String ACCESSION_RESTRICTION_TYPE = "ACCESSION_RESTRICTION_TYPE";
public static final CodeValueDef ACCESSION_RESTRICTION_TYPE_SMTA;
public static final String INVENTORY_AVAILABILITY_STATUS = "INVENTORY_AVAILABILITY_STATUS";
public static final CodeValueDef INVENTORY_AVAILABILITY_LOWINVENTORY;
......@@ -67,6 +81,20 @@ public abstract class CommunityCodeValues {
// Date formats
DATE_FORMAT_DATETIME = new CodeValueDef(DATE_FORMAT, "yyyy-MM-dd HH:mm", "Date and time", "yyyy-MM-dd HH:mm");
DATE_FORMAT_DATE = new CodeValueDef(DATE_FORMAT, "yyyy-MM-dd", "Date", "yyyy-MM-dd");
// Accession source type
ACCESSION_SOURCE_TYPE_COLLECTED = new CodeValueDef(ACCESSION_SOURCE_TYPE, "COLLECTED", "Collection source event", null);
ACCESSION_SOURCE_TYPE_DEVELOPED = new CodeValueDef(ACCESSION_SOURCE_TYPE, "DEVELOPED", "Developer source event", null);
ACCESSION_SOURCE_TYPE_DONATED = new CodeValueDef(ACCESSION_SOURCE_TYPE, "DONATED", "Donor source event", null);
// Accession name types
ACCESSION_NAME_TYPE_COLLECTOR = new CodeValueDef(ACCESSION_NAME_TYPE, "COLLECTOR", "Collector identifier", null);
ACCESSION_NAME_TYPE_CULTIVAR = new CodeValueDef(ACCESSION_NAME_TYPE, "CULTIVAR", "Cultivar name", null);
ACCESSION_NAME_TYPE_DONOR = new CodeValueDef(ACCESSION_NAME_TYPE, "DONOR", "Donor identifier", null);
ACCESSION_NAME_TYPE_DEVELOPER = new CodeValueDef(ACCESSION_NAME_TYPE, "DEVELOPER", "Developer identifier", null);
// Accession IPR types
ACCESSION_RESTRICTION_TYPE_SMTA = new CodeValueDef(ACCESSION_RESTRICTION_TYPE, "MTA-SMTA", "FAO Standard Material Transfer Agreement", null);
// Inventory availability
INVENTORY_AVAILABILITY_LOWINVENTORY = new CodeValueDef(INVENTORY_AVAILABILITY_STATUS, "LOW", "Low inventory", null);
......
......@@ -211,7 +211,7 @@ public abstract class AbstractServicesTest extends AbstractServiceTest {
protected AccessionIpr addAccessionIprToDB(Accession accession) {
AccessionIpr ipr = new AccessionIpr();
ipr.setAccession(accession);
ipr.setTypeCode("TypeCode");
ipr.setTypeCode(CommunityCodeValues.ACCESSION_RESTRICTION_TYPE_SMTA.value);
return accessionIprRepository.save(ipr);
}
......@@ -297,7 +297,7 @@ public abstract class AbstractServicesTest extends AbstractServiceTest {
AccessionInvName invName = new AccessionInvName();
invName.setPlantName(plantName);
invName.setIsWebVisible(TRUE);
invName.setCategoryCode("Category code");
invName.setCategoryCode(CommunityCodeValues.ACCESSION_NAME_TYPE_DEVELOPER.value);
invName.setInventory(inventory);
return accessionInvNameRepository.save(invName);
......
......@@ -308,7 +308,7 @@ public class AccessionServiceTest extends AbstractServicesTest {
acquisitionBatch.inventoryNumberPart1 = "INTRO";
acquisitionBatch.siteId = 1;
acquisitionBatch.inventoryMaintenancePolicyId = maintPolicy.getId();
acquisitionBatch.availabilityStatusCode = "AVAIL";
acquisitionBatch.availabilityStatusCode = CommunityCodeValues.INVENTORY_AVAILABILITY_AVAILABLE.value;
acquisitionBatch.accessions = new ArrayList<>();
for (int i = 0; i < 10; i++) {
......@@ -319,11 +319,11 @@ public class AccessionServiceTest extends AbstractServicesTest {
accession.setTaxonomySpecies(new TaxonomySpecies(taxonomySpecies.getId()));
List<AccessionInvName> names = Lists.newArrayList(new AccessionInvName(), new AccessionInvName(), new AccessionInvName());
names.get(0).setCategoryCode("DEVELOPER");
names.get(0).setCategoryCode(CommunityCodeValues.ACCESSION_NAME_TYPE_DEVELOPER.value);
names.get(0).setPlantName("Developed " + (i+1));
names.get(1).setCategoryCode("COLLECTOR");
names.get(1).setCategoryCode(CommunityCodeValues.ACCESSION_NAME_TYPE_COLLECTOR.value);
names.get(1).setPlantName("COLL " + (RandomUtils.nextInt(100, 99999)));
names.get(2).setCategoryCode("DONOR");
names.get(2).setCategoryCode(CommunityCodeValues.ACCESSION_NAME_TYPE_DONOR.value);
names.get(2).setPlantName("TZm-" + (RandomUtils.nextInt(100, 99999)));
accession.setNames(names);
......@@ -332,7 +332,7 @@ public class AccessionServiceTest extends AbstractServicesTest {
acquisitionBatch.sources = new ArrayList<>();
AccessionSource source = new AccessionSource();
source.setSourceTypeCode("DONATED");
source.setSourceTypeCode(CommunityCodeValues.ACCESSION_SOURCE_TYPE_DONATED.value);
source.setSourceDate(new Date());
source.setSourceDateCode("YYYY-MM-DD");
List<Cooperator> cooperators = Lists.newArrayList(new Cooperator(1l), new Cooperator(2l));
......@@ -341,7 +341,7 @@ public class AccessionServiceTest extends AbstractServicesTest {
// Source 2
source = new AccessionSource();
source.setSourceTypeCode("DEVELOPED");
source.setSourceTypeCode(CommunityCodeValues.ACCESSION_SOURCE_TYPE_DEVELOPED.value);
source.setSourceDate(new Date());
source.setSourceDateCode("YYYY-MM-DD");
cooperators = Lists.newArrayList(new Cooperator(3l));
......
......@@ -33,6 +33,7 @@ log4j.category.org.gringlobal=info
#log4j.category.org.gringlobal.spring=trace
log4j.category.org.gringlobal.custom.elasticsearch=warn
log4j.category.org.gringlobal.service.impl.ElasticsearchServiceImpl=warn
log4j.category.org.gringlobal.service.impl.CodeValueServiceImpl=warn
log4j.category.org.springframework.web.client=trace
log4j.category.org.elasticsearch.client=error
......
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