use of org.apache.commons.collections4.list.TreeList in project eol-globi-data by jhpoelen.
the class DatasetImporterForGlobalWebDbTest method parseMatrix.
@Test
public void parseMatrix() throws IOException, StudyImporterException {
List<Map<String, String>> interactions = new TreeList<>();
InteractionListener listener = interactions::add;
DatasetImporterForGlobalWebDb.parseDietMatrix(listener, aDietMatrix, "some source citation");
assertThat(interactions.size(), is(6));
Map<String, String> first = interactions.get(0);
assertThat(first.get(TaxonUtil.SOURCE_TAXON_NAME), is("Balanus balanoides"));
assertThat(first.get(TaxonUtil.TARGET_TAXON_NAME), is("detritus"));
assertThat(first.get(DatasetImporterForTSV.INTERACTION_TYPE_NAME), is("eats"));
assertThat(first.get(DatasetImporterForTSV.INTERACTION_TYPE_ID), is("http://purl.obolibrary.org/obo/RO_0002470"));
assertThat(first.get(DatasetImporterForTSV.HABITAT_NAME), is("Exposed rocky shore"));
assertThat(first.get(DatasetImporterForTSV.LOCALITY_NAME), is("New England, U.S.A."));
assertThat(first.get(DatasetImporterForTSV.REFERENCE_ID), is("df06df18abafa63a6f0473d6d0e6ce68"));
assertThat(first.get(DatasetImporterForTSV.REFERENCE_CITATION), is("B.A. Menge and J.P. Sutherland. Species Diversity Gradients: Synthesis of the Roles of Predation, Competition, and Temporal Heterogeneity. The American Naturalist, 110(973), pp. 351-369."));
assertThat(first.get(DatasetImporterForTSV.DATASET_CITATION), is("some source citation"));
Map<String, String> last = interactions.get(5);
assertThat(last.get(TaxonUtil.SOURCE_TAXON_NAME), is("Thais lapillus"));
assertThat(last.get(TaxonUtil.TARGET_TAXON_NAME), is("Mytilus edulis"));
assertThat(last.get(DatasetImporterForTSV.INTERACTION_TYPE_NAME), is("eats"));
assertThat(last.get(DatasetImporterForTSV.INTERACTION_TYPE_ID), is("http://purl.obolibrary.org/obo/RO_0002470"));
assertThat(last.get(DatasetImporterForTSV.HABITAT_NAME), is("Exposed rocky shore"));
assertThat(last.get(DatasetImporterForTSV.LOCALITY_NAME), is("New England, U.S.A."));
assertThat(last.get(DatasetImporterForTSV.REFERENCE_ID), is("df06df18abafa63a6f0473d6d0e6ce68"));
assertThat(last.get(DatasetImporterForTSV.REFERENCE_CITATION), is("B.A. Menge and J.P. Sutherland. Species Diversity Gradients: Synthesis of the Roles of Predation, Competition, and Temporal Heterogeneity. The American Naturalist, 110(973), pp. 351-369."));
assertThat(last.get(DatasetImporterForTSV.DATASET_CITATION), is("some source citation"));
}
use of org.apache.commons.collections4.list.TreeList in project eol-globi-data by jhpoelen.
the class DatasetRegistryZenodo method findZenodoGitHubArchives.
private static Map<String, List<Pair<Long, URI>>> findZenodoGitHubArchives(NodeList records) throws XPathExpressionException, MalformedURLException {
Map<String, List<Pair<Long, URI>>> namespace2ZenodoPubs = new TreeMap<>();
Long idMax = null;
for (int i = 0; i < records.getLength(); i++) {
Node item = records.item(i);
String fullId = (String) XmlUtil.applyXPath(item, "header/identifier", XPathConstants.STRING);
if (StringUtils.startsWith(fullId, PREFIX_ZENODO)) {
String idString = StringUtils.replace(fullId, PREFIX_ZENODO, "");
String relatedIdentifier = StringUtils.trim((String) XmlUtil.applyXPath(item, ".//*[local-name()='relatedIdentifier']", XPathConstants.STRING));
if (StringUtils.startsWith(relatedIdentifier, PREFIX_GITHUB_RELATION)) {
String replace = StringUtils.replace(StringUtils.trim(relatedIdentifier), PREFIX_GITHUB_RELATION, "");
String[] split = StringUtils.split(replace, "/");
Long id = NumberUtils.createLong(idString);
if (split.length > 3) {
String githubRepo = split[0] + "/" + split[1];
URI archiveURI = URI.create("https://zenodo.org/record/" + idString + "/files/" + githubRepo + "-" + split[3] + ".zip");
List<Pair<Long, URI>> versions = namespace2ZenodoPubs.getOrDefault(githubRepo, new TreeList<>());
namespace2ZenodoPubs.put(githubRepo, new TreeList<Pair<Long, URI>>(versions) {
{
add(Pair.of(id, archiveURI));
}
});
}
}
}
}
return namespace2ZenodoPubs;
}
Aggregations