use of org.powo.model.Description in project powop by RBGKew.
the class DescriptionParsingTest method setUp.
@Before
public final void setUp() throws Exception {
String[] names = new String[] { "http://rs.tdwg.org/dwc/terms/taxonID", "http://purl.org/dc/terms/created", "http://purl.org/dc/terms/modified", "http://purl.org/dc/terms/description", "http://purl.org/dc/terms/type", "http://purl.org/dc/terms/references", "http://purl.org/dc/terms/identifier" };
DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
tokenizer.setDelimiter(DelimitedLineTokenizer.DELIMITER_TAB);
tokenizer.setNames(names);
taxonService = createMock(TaxonService.class);
conversionService = createMock(ConversionService.class);
FieldSetMapper fieldSetMapper = new FieldSetMapper();
fieldSetMapper.setConversionService(conversionService);
fieldSetMapper.setFieldNames(names);
fieldSetMapper.setDefaultValues(new HashMap<String, String>());
fieldSetMapper.setTaxonService(taxonService);
DefaultLineMapper<Description> lineMapper = new DefaultLineMapper<Description>();
lineMapper.setFieldSetMapper(fieldSetMapper);
lineMapper.setLineTokenizer(tokenizer);
flatFileItemReader.setEncoding("UTF-8");
flatFileItemReader.setLinesToSkip(0);
flatFileItemReader.setResource(content);
flatFileItemReader.setLineMapper(lineMapper);
flatFileItemReader.afterPropertiesSet();
}
use of org.powo.model.Description in project powop by RBGKew.
the class DescriptionsTest method testBySource.
@Test
public void testBySource() {
Description d2 = new Description();
Description d3 = new Description();
Organisation o2 = new Organisation();
o2.setAbbreviation("FTEA");
o2.setTitle("Flora of Tropical East Africa");
d1.setType(DescriptionType.morphologyGeneralHabit);
d1.setId(1L);
d1.setDescription("Perenial herb");
d2.setType(DescriptionType.morphologyLeaf);
d2.setId(3L);
d2.setDescription("Basal leaves");
d2.setAuthority(o1);
d3.setType(DescriptionType.morphologyReproductiveFlower);
d3.setId(2L);
d3.setDescription("Large");
d3.setAuthority(o2);
taxon.setDescriptions(ImmutableSet.<Description>of(d1, d2, d3));
Descriptions ds = new Descriptions(taxon);
Collection<DescriptionsBySource> dbs = ds.getBySource();
assertEquals(2, dbs.size());
List<String> abbreviations = new ArrayList<>();
for (DescriptionsBySource d : dbs) {
abbreviations.add(d.source.getAbbreviation());
}
assertThat(abbreviations, containsInAnyOrder("FWTA", "FTEA"));
}
use of org.powo.model.Description in project powop by RBGKew.
the class DescriptionsTest method testSynonymDescriptions.
@Test
public void testSynonymDescriptions() {
Description d2 = new Description();
Taxon synonym = new Taxon();
synonym.setScientificName("Eucalypton");
synonym.setTaxonomicStatus(TaxonomicStatus.Synonym);
d1.setType(DescriptionType.morphologyGeneral);
d1.setDescription("accepted description");
d2.setAuthority(o1);
d2.setType(DescriptionType.morphologyGeneralHabit);
d2.setDescription("synonym description");
synonym.setDescriptions(ImmutableSet.<Description>of(d2));
taxon.setDescriptions(ImmutableSet.<Description>of(d1));
taxon.setSynonymNameUsages(ImmutableSet.<Taxon>of(synonym));
Descriptions ds = new Descriptions(taxon);
for (DescriptionsBySource dbs : ds.getBySource()) {
if (dbs.asTaxon.getScientificName().equals("Eucalypton")) {
assertEquals(d2, dbs.byType.get(0).descriptions.get(0));
} else {
assertEquals(d1, dbs.byType.get(0).descriptions.get(0));
}
}
}
use of org.powo.model.Description in project powop by RBGKew.
the class DescriptionsTest method print.
private void print(Descriptions descriptions) {
for (DescriptionsBySource dbs : descriptions.getBySource()) {
System.out.print("{" + dbs.source.getTitle() + " as " + dbs.asTaxon.getScientificName() + ": ");
for (DescriptionsByType dbt : dbs.byType) {
System.out.print(dbt.type + " [");
for (Description d : dbt.descriptions) {
System.out.print(d.getDescription() + " ");
}
System.out.print("] ");
}
System.out.println("}");
}
}
use of org.powo.model.Description in project powop by RBGKew.
the class DescriptionsTest method testDescriptionTypeFiltering.
@Test
public void testDescriptionTypeFiltering() {
Description d2 = new Description();
d1.setType(useAnimalFoodBees);
d1.setDescription("BEES!!!");
d2.setType(useMedicinesDigestiveSystemDisorders);
d2.setDescription("You have died of dysentery");
d2.setAuthority(o1);
taxon.setDescriptions(ImmutableSet.<Description>of(d1, d2));
Descriptions ds = new Descriptions(taxon, true);
}
Aggregations