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

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) {
......@@ -198,7 +198,7 @@ public class AccessionController {
* @param filter the filter
* @return the page
* @throws IOException
* @throws SearchException
* @throws SearchException
*/
@JsonView({ JsonViews.Root.class }) // same as getAccessionDetails so we get imageGallery!
@PostMapping(value = "/images", produces = { MediaType.APPLICATION_JSON_VALUE })
......@@ -271,7 +271,7 @@ public class AccessionController {
/**
* Gets accessions by list of uuid-s
*
*
* @param uuids accession identifi`ers to lookup in DB
* @return list of Accessions
*/
......
......@@ -159,6 +159,9 @@ public abstract class AccessionData extends AuditedVersionedModel implements IdU
@NotNull
@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
......@@ -293,7 +293,7 @@ public class AccessionServiceImpl implements AccessionService {
/**
* Converts list of accession IDs to respective accession UUIDs in batches of
* 100.
*
*
* @see org.genesys2.server.service.AccessionService#uuidsFromIds(java.util.List)
*/
@Override
......
......@@ -262,7 +262,7 @@ public class AccessionUploader implements InitializingBean {
/**
* Check incoming JSON and update values accordingly
*
*
* @param update JSON node
* @param updateA Received accession data
* @param accession Genesys accession data
......@@ -513,7 +513,7 @@ public class AccessionUploader implements InitializingBean {
updated.setSubtAuthor(null);
}
if (! updated.equalTo(taxonomy)) {
if (! updated.equalTo(taxonomy)) {
LOG.trace("Ensuring taxonomy {}", updated);
updated = taxonomyService.ensureTaxonomy(updated);
accession.setTaxonomy(updated);
......
......@@ -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