Commit 83fc688b authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza
Browse files

Add AEGIS status

added test
removed aegis from AccessionOpResponse

added aegis column to accession_historic table

fixed tests, added aegis to overview
parent 5f289395
......@@ -121,7 +121,7 @@ public class AccessionController {
private String[] cdnServers;
private final Set<String> terms = Sets.newHashSet("institute.code", "institute.country.code3", "cropName", "crop.shortName", "taxonomy.genus", "taxonomy.species",
"taxonomy.genusSpecies", "countryOfOrigin.code3", "sampStat", "available", "mlsStatus", "donorCode", "sgsv", "storage", "duplSite", "breederCode");
"taxonomy.genusSpecies", "countryOfOrigin.code3", "sampStat", "available", "mlsStatus", "donorCode", "sgsv", "storage", "duplSite", "breederCode", "aegis");
@GetMapping(value = "/id/{id}", produces = { MediaType.APPLICATION_JSON_VALUE })
public UUID uuidFromId(@PathVariable("id") final long id) {
......
......@@ -160,6 +160,9 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@Column(name = "historic", nullable = false)
private boolean historic = false;
@Column(name = "aegis")
private Boolean aegis = false;
@Column(name = "mlsStat")
private Boolean mlsStatus;
......@@ -500,6 +503,14 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
this.donorNumb = donorNumb;
}
public Boolean isAegis() {
return aegis;
}
public void setAegis(Boolean aegis) {
this.aegis = aegis;
}
@JsonGetter
public String getAccessionName() {
return this.accessionId.getAliases() != null && this.accessionId.getAliases().size() > 0
......
......@@ -52,6 +52,9 @@ public class AccessionFilter extends UuidModelFilter<AccessionFilter, Accession>
/** The historic. */
public Boolean historic;
/** The aegis. */
public Boolean aegis;
/** The mls status. */
public Boolean mlsStatus;
......@@ -168,6 +171,9 @@ public class AccessionFilter extends UuidModelFilter<AccessionFilter, Accession>
if (historic != null) {
and.and(accession.historic.eq(historic));
}
if (aegis != null) {
and.and(accession.aegis.eq(aegis));
}
if (cropName != null) {
and.and(cropName.buildQuery(accession.cropName));
}
......@@ -241,6 +247,9 @@ public class AccessionFilter extends UuidModelFilter<AccessionFilter, Accession>
if (historic != null) {
and.and(accession.historic.eq(historic));
}
if (aegis != null) {
and.and(accession.aegis.eq(aegis));
}
if (crop != null && !crop.isEmpty()) {
and.and(accession.crop.shortName.in(crop));
}
......
......@@ -83,7 +83,7 @@ public class AccessionServiceImpl implements AccessionService {
public static final Logger LOG = LoggerFactory.getLogger(AccessionServiceImpl.class);
private final Set<String> suggestions = Sets.newHashSet("crop.shortName", "institute.code", "taxonomy.genus", "taxonomy.genusSpecies", "taxonomy.species", "countryOfOrigin.code3", "historic", "sampStat", "available", "mlsStatus", "sgsv", "storage");
private final Set<String> suggestions = Sets.newHashSet("aegis", "crop.shortName", "institute.code", "taxonomy.genus", "taxonomy.genusSpecies", "taxonomy.species", "countryOfOrigin.code3", "historic", "sampStat", "available", "mlsStatus", "sgsv", "storage");
/** The accession repository. */
@Autowired
......
......@@ -5860,3 +5860,29 @@ databaseChangeLog:
type: boolean
defaultValue: false
tableName: request
- changeSet:
id: 1565780550908-1
author: vpavlov
comment: Add column `aegis` to Accession
changes:
- addColumn:
columns:
- column:
name: aegis
type: boolean
defaultValue: false
tableName: accession
- changeSet:
id: 1565780550908-2
author: vpavlov
comment: Add column `aegis` to AccessionHistoric
changes:
- addColumn:
columns:
- column:
name: aegis
type: boolean
defaultValue: false
tableName: accession_historic
......@@ -139,7 +139,7 @@ public class AccessionControllerTest extends AbstractApiTest {
@Test
public void createAccessionTest() throws Exception {
ObjectNode accessionJson = setUpAccession();
ObjectNode accessionJson = setUpAccession(true);
final String s = "[" + verboseMapper.writeValueAsString(accessionJson) + "]";
/*@formatter:off*/
......@@ -158,6 +158,7 @@ public class AccessionControllerTest extends AbstractApiTest {
/*@formatter:on*/
assertThat(accessionRepository.count(), is(1L));
assertThat(accessionRepository.findAll().get(0).isAegis(), is(true));
}
@Test
......@@ -211,6 +212,59 @@ public class AccessionControllerTest extends AbstractApiTest {
/*@formatter:on*/
}
@Test
public void aegisFilterTest() throws Exception {
Accession withAegis = addAccessionInDB(true);
Accession withoutAegis = addAccessionInDB(false);
Accession nullAegis = addAccessionInDB(null);
accessionRepository.save(withAegis);
accessionRepository.save(withoutAegis);
accessionRepository.save(nullAegis);
AccessionFilter filter = new AccessionFilter();
filter.aegis = true;
/*@formatter:off*/
mockMvc
.perform(post(AccessionUploadController.CONTROLLER_URL + "/list")
.contentType(MediaType.APPLICATION_JSON)
.content(verboseMapper.writeValueAsString(filter)))
// .andDo(MockMvcResultHandlers.print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.totalElements", is(1)))
.andExpect(jsonPath("$.content[0].aegis", is(true)))
.andExpect(jsonPath("$.content[0].uuid", is(withAegis.getUuid().toString())));
/*@formatter:on*/
filter.aegis = false;
mockMvc
.perform(post(AccessionUploadController.CONTROLLER_URL + "/list")
.contentType(MediaType.APPLICATION_JSON)
.content(verboseMapper.writeValueAsString(filter)))
// .andDo(MockMvcResultHandlers.print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.totalElements", is(1)))
.andExpect(jsonPath("$.content[0].aegis", is(false)))
.andExpect(jsonPath("$.content[0].uuid", is(withoutAegis.getUuid().toString())));
/*@formatter:on*/
filter.aegis = null;
filter.isNull().add("aegis");
mockMvc
.perform(post(AccessionUploadController.CONTROLLER_URL + "/list")
.contentType(MediaType.APPLICATION_JSON)
.content(verboseMapper.writeValueAsString(filter)))
// .andDo(MockMvcResultHandlers.print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$.totalElements", is(1)))
.andExpect(jsonPath("$.content[0].aegis", isEmptyOrNullString()))
.andExpect(jsonPath("$.content[0].uuid", is(nullAegis.getUuid().toString())));
/*@formatter:on*/
}
@Test
public void getAccessionsTest() throws Exception {
......@@ -562,13 +616,15 @@ public class AccessionControllerTest extends AbstractApiTest {
final List<Accession> accessions = new ArrayList<>(amount);
for (int i = 0; i < amount; i++) {
accessions.add(addAccessionInDB());
accessions.add(addAccessionInDB(false));
}
return accessionRepository.save(accessions);
}
private Accession addAccessionInDB() {
private Accession addAccessionInDB(Boolean aegis) {
Accession a = new Accession();
a.setAegis(aegis);
a.setAccessionId(new AccessionId());
a.setAccessionId(new AccessionId());
AccessionGeo accessionGeo = new AccessionGeo();
accessionGeo.setLongitude(75d);
......@@ -585,6 +641,17 @@ public class AccessionControllerTest extends AbstractApiTest {
private ObjectNode setUpAccession() {
ObjectNode accession = objectMapper.createObjectNode();
accession.put("instituteCode", institute.getCode());
accession.put("aegis", false);
accession.put("accessionNumber", "A" + acceNumb.incrementAndGet());
ObjectNode taxa = accession.putObject("taxonomy");
taxa.put("genus", "Manihot");
return accession;
}
private ObjectNode setUpAccession(Boolean aegis) {
ObjectNode accession = objectMapper.createObjectNode();
accession.put("instituteCode", institute.getCode());
accession.put("aegis", aegis);
accession.put("accessionNumber", "A" + acceNumb.incrementAndGet());
ObjectNode taxa = accession.putObject("taxonomy");
taxa.put("genus", "Manihot");
......
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