use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class DOIResolverImplTest method extractDOI.
@Test
public void extractDOI() throws IOException, MalformedDOIException {
String response = IOUtils.toString(getClass().getResourceAsStream("crossRefReply.json"), StandardCharsets.UTF_8);
DOI doi = new DOIResolverImpl().extractDOI(response);
assertThat(doi.toString(), is("10.1002/(sici)1098-2345(1997)42:1<1::aid-ajp1>3.0.co;2-0"));
}
use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class DatasetImplTest method doiScrubbing.
@Test
public void doiScrubbing() throws IOException {
Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
dataset.setConfig(new ObjectMapper().readTree("{\"doi\": \"doi:http://dx.doi.org/10.2980/1195-6860(2006)13[23:TDOFUB]2.0.CO;2\" }"));
assertThat(dataset.getDOI(), is(new DOI("2980", "1195-6860(2006)13[23:TDOFUB]2.0.CO;2")));
}
use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class NodeFactoryWithDatasetContextTest method createStudy.
@Test
public void createStudy() {
NodeFactory factory = Mockito.mock(NodeFactory.class);
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"), inStream -> inStream);
NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
StudyImpl study = new StudyImpl("some title", new DOI("123", "abc"), "some citation");
study.setExternalId("some:id");
factoryWithDS.createStudy(study);
ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
verify(factory).createStudy(argument.capture());
assertEquals("some title", argument.getValue().getTitle());
assertEquals("some citation", argument.getValue().getCitation());
assertEquals("10.123/abc", argument.getValue().getDOI().toString());
assertEquals("some:id", argument.getValue().getExternalId());
}
use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class NodeFactoryNeo4j method createDatasetNode.
Node createDatasetNode(Dataset dataset) {
Node datasetNode = createDatasetNode();
datasetNode.setProperty(DatasetConstant.NAMESPACE, dataset.getNamespace());
URI archiveURI = dataset.getArchiveURI();
if (archiveURI != null) {
String archiveURIString = archiveURI.toString();
datasetNode.setProperty(DatasetConstant.ARCHIVE_URI, archiveURIString);
createExternalIdRelationIfExists(datasetNode, archiveURIString, RelTypes.HAS_EXTERNAL_ID);
}
URI configURI = dataset.getConfigURI();
if (configURI != null) {
datasetNode.setProperty(DatasetConstant.CONFIG_URI, configURI.toString());
}
JsonNode config = dataset.getConfig();
if (config != null) {
try {
datasetNode.setProperty(DatasetConstant.CONFIG, new ObjectMapper().writeValueAsString(config));
} catch (IOException e) {
LOG.warn("failed to serialize dataset config");
}
}
datasetNode.setProperty(StudyConstant.FORMAT, dataset.getFormat());
DOI doi = dataset.getDOI();
if (doi != null) {
String doiString = doi.toString();
datasetNode.setProperty(StudyConstant.DOI, doiString);
createExternalIdRelationIfExists(datasetNode, doiString, RelTypes.HAS_DOI);
}
datasetNode.setProperty(DatasetConstant.CITATION, StringUtils.defaultIfBlank(dataset.getCitation(), "no citation"));
datasetNode.setProperty(DatasetConstant.SHOULD_RESOLVE_REFERENCES, dataset.getOrDefault(DatasetConstant.SHOULD_RESOLVE_REFERENCES, "true"));
datasetNode.setProperty(DatasetConstant.LAST_SEEN_AT, dataset.getOrDefault(DatasetConstant.LAST_SEEN_AT, Long.toString(System.currentTimeMillis())));
indexDatasetNode(dataset, datasetNode);
return datasetNode;
}
use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.
the class DatasetImporterForStrona method importStudy.
@Override
public void importStudy() throws StudyImporterException {
LabeledCSVParser dataParser;
try {
dataParser = getParserFactory().createParser(RESOURCE_PATH, CharsetConstant.UTF8);
} catch (IOException e) {
throw new StudyImporterException("failed to read resource [" + RESOURCE_PATH + "]", e);
}
try {
Study study = getNodeFactory().getOrCreateStudy(new StudyImpl("strona2013", new DOI("1890", "12-1419.1"), SOURCE));
while (dataParser.getLine() != null) {
if (importFilter.shouldImportRecord((long) dataParser.getLastLineNumber())) {
try {
String parasiteName = StringUtils.trim(dataParser.getValueByLabel("P_SP"));
String hostName = StringUtils.trim(dataParser.getValueByLabel("H_SP"));
if (areNamesAvailable(parasiteName, hostName)) {
Specimen parasite = getNodeFactory().createSpecimen(study, new TaxonImpl(parasiteName, null));
Specimen host = getNodeFactory().createSpecimen(study, new TaxonImpl(hostName, null));
parasite.interactsWith(host, InteractType.PARASITE_OF);
}
} catch (NodeFactoryException | NumberFormatException e) {
throw new StudyImporterException("failed to import line [" + (dataParser.lastLineNumber() + 1) + "]", e);
}
}
}
} catch (IOException | NodeFactoryException e) {
throw new StudyImporterException("problem importing [" + RESOURCE_PATH + "]", e);
}
}
Aggregations