use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForByrnes method importLine.
private void importLine(LabeledCSVParser parser, Map<String, String> refMap) throws StudyImporterException {
Study localStudy = null;
try {
String refList = StringUtils.trim(parser.getValueByLabel("Reference"));
String[] refs;
if (StringUtils.isBlank(refList)) {
refs = new String[] { "Byrnes, J.E. et al., 2011. Climate-driven increases in storm frequency simplify kelp forest food webs. Global Change Biology, 17(8), pp.2513–2524. Available at: http://dx.doi.org/10.1111/j.1365-2486.2011.02409.x." };
} else {
refs = StringUtils.split(refList, ",");
}
for (String ref : refs) {
String singleShortRef = StringUtils.trim(ref);
String longRef = refMap.get(singleShortRef);
String citation = StringUtils.isBlank(longRef) ? singleShortRef : longRef;
localStudy = nodeFactory.getOrCreateStudy(new StudyImpl("BYRNES-" + StringUtils.abbreviate(citation, 32), SOURCE, null, citation));
String predatorName = parser.getValueByLabel("Predator");
if (StringUtils.isBlank(predatorName)) {
getLogger().warn(localStudy, "found empty predator name on line [" + parser.lastLineNumber() + "]");
} else {
addInteractionForPredator(parser, localStudy, predatorName);
}
}
} catch (NodeFactoryException e) {
throw new StudyImporterException("problem creating nodes at line [" + parser.lastLineNumber() + "]", e);
} catch (NumberFormatException e) {
String message = "skipping record, found malformed field at line [" + parser.lastLineNumber() + "]: ";
if (localStudy != null) {
getLogger().warn(localStudy, message + e.getMessage());
}
}
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForBarnes method importLine.
private void importLine(LabeledCSVParser parser, Map<String, String> refMap) throws StudyImporterException {
Study localStudy = null;
try {
String shortReference = StringUtils.trim(parser.getValueByLabel("Reference"));
if (!refMap.containsKey(shortReference)) {
throw new StudyImporterException("failed to find ref [" + shortReference + "] on line [" + parser.lastLineNumber() + "]");
}
String longReference = refMap.get(shortReference);
localStudy = nodeFactory.getOrCreateStudy(new StudyImpl("BARNES-" + shortReference, SOURCE, null, ExternalIdUtil.toCitation(null, longReference, null)));
String predatorName = parser.getValueByLabel("Predator");
if (StringUtils.isBlank(predatorName)) {
getLogger().warn(localStudy, "found empty predator name on line [" + parser.lastLineNumber() + "]");
} else {
addInteractionForPredator(parser, localStudy, predatorName);
}
} catch (NodeFactoryException e) {
throw new StudyImporterException("problem creating nodes at line [" + parser.lastLineNumber() + "]", e);
} catch (NumberFormatException e) {
String message = "skipping record, found malformed field at line [" + parser.lastLineNumber() + "]: ";
if (localStudy != null) {
getLogger().warn(localStudy, message + e.getMessage());
}
}
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForBioInfo method createStudy.
protected Study createStudy(String refId, String citation) throws NodeFactoryException {
String sourceCitation = "Food Webs and Species Interactions in the Biodiversity of UK and Ireland (Online). 2015. Data provided by Malcolm Storey. Also available from " + BIOINFO_URL + ".";
String bioInfoId = TaxonomyProvider.BIO_INFO + "ref:" + refId;
StudyImpl study1 = new StudyImpl(bioInfoId, sourceCitation, null, citation);
study1.setExternalId(ExternalIdUtil.urlForExternalId(bioInfoId));
return nodeFactory.getOrCreateStudy(study1);
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForBlewett method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String citation = "Blewett DA, Hensley RA, and Stevens PW, Feeding Habits of Common Snook, Centropomus Undecimalis, in Charlotte Harbor, Florida, Gulf and Caribbean Research Vol 18, 1–13, 2006. doi:10.18785/gcr.1801.01 ";
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("Blewett 2006", StudyImporterForGoMexSI2.GOMEXI_SOURCE_DESCRIPTION, null, citation));
try {
Map<String, Location> collectionLocationMap = new HashMap<>();
Map<String, Date> collectionTimeMap = new HashMap<String, Date>();
buildLocationTimeMaps(collectionLocationMap, collectionTimeMap, study);
parsePredatorPreyInteraction(study, collectionLocationMap, collectionTimeMap);
} catch (IOException e) {
throw new StudyImporterException("failed to read resource", e);
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to create taxon", e);
} catch (TermLookupServiceException e) {
throw new StudyImporterException("failed to map terms", e);
}
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryIT method createLogMessage.
@Test
public void createLogMessage() throws NodeFactoryException {
Study bla = nodeFactory.createStudy(new StudyImpl("bla", null, null, null));
bla.appendLogMessage("one two three", Level.INFO);
List<LogMessage> logMessages = bla.getLogMessages();
assertThat(logMessages.size(), is(1));
assertThat(logMessages.get(0).getMessage(), is("one two three"));
assertThat(logMessages.get(0).getLevel(), is("INFO"));
}
Aggregations