use of uk.ac.ebi.spot.goci.model.deposition.DepositionPublication in project goci by EBISPOT.
the class DepositionPublicationServiceImpl method retrievePublication.
@Override
public DepositionPublication retrievePublication(String id) {
log.info("Retrieving publication using id [{}]", id);
DepositionPublication publication = null;
Map<String, String> params = new HashMap<>();
params.put("pmID", id);
String url = depositionIngestUri + "/publications/{pmID}?pmid=true";
try {
String response = template.getForObject(url, String.class, params);
publication = template.getForObject(url, DepositionPublication.class, params);
} catch (HttpClientErrorException e) {
System.out.println(e.getMessage());
}
return publication;
}
use of uk.ac.ebi.spot.goci.model.deposition.DepositionPublication 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;
}
use of uk.ac.ebi.spot.goci.model.deposition.DepositionPublication in project goci by EBISPOT.
the class DepositionPublicationTest method testDepositionPublicationRead.
@Test
public void testDepositionPublicationRead() {
try {
Resource resource = new ClassPathResource("publication.json");
assertTrue(resource.exists());
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JodaModule());
DepositionPublication publication = objectMapper.readValue(resource.getFile(), DepositionPublication.class);
assertNotNull(publication);
assertNotNull(publication.getStatus());
assertNotNull(publication.getPublicationDate().year());
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of uk.ac.ebi.spot.goci.model.deposition.DepositionPublication in project goci by EBISPOT.
the class DepositionPublicationTest method testDepositionPublicationWrite.
@Test
public void testDepositionPublicationWrite() {
ObjectMapper objectMapper = new ObjectMapper();
try {
objectMapper.registerModule(new JodaModule());
DepositionPublication publication = new DepositionPublication();
publication.setPublicationDate(new LocalDate());
String json = objectMapper.writeValueAsString(publication);
assertNotNull(json);
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations