use of uk.ac.ebi.spot.goci.model.deposition.util.DepositionPublicationListWrapper in project goci by EBISPOT.
the class DepositionPublicationTest method testReadAllPublications.
@Test
public void testReadAllPublications() {
try {
Resource resource = new ClassPathResource("publications.json");
assertTrue(resource.exists());
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JodaModule());
DepositionPublicationListWrapper publication = objectMapper.readValue(resource.getFile(), DepositionPublicationListWrapper.class);
assertNotNull(publication);
assertNotNull(publication.getPublications().getPublications().get(0).getPublicationDate().year());
assertNotNull(publication.getPublications().getPublications().get(0).getStatus());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of uk.ac.ebi.spot.goci.model.deposition.util.DepositionPublicationListWrapper in project goci by EBISPOT.
the class DepositionPublicationServiceImpl method getAllBackendPublications.
@Override
public Map<String, DepositionPublication> getAllBackendPublications() {
log.info("Retrieving publications");
String url = depositionBackendUri + "/publications?page={page}&size=100";
Map<String, DepositionPublication> publicationMap = new HashMap<>();
try {
int i = 0;
Map<String, Integer> params = new HashMap<>();
params.put("page", i);
String response = template.getForObject(url, String.class, params);
DepositionPublicationListWrapper publications = template.getForObject(url, DepositionPublicationListWrapper.class, params);
while (i < publications.getPage().getTotalPages()) {
addPublications(publicationMap, publications);
params.put("page", ++i);
publications = template.getForObject(url, DepositionPublicationListWrapper.class, params);
}
} catch (HttpClientErrorException e) {
System.out.println(e.getMessage());
}
return publicationMap;
}
Aggregations