Search in sources :

Example 1 with Description

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();
}
Also used : DelimitedLineTokenizer(org.springframework.batch.item.file.transform.DelimitedLineTokenizer) TaxonService(org.powo.api.TaxonService) Description(org.powo.model.Description) ConversionService(org.springframework.core.convert.ConversionService) FieldSetMapper(org.powo.job.dwc.description.FieldSetMapper) DefaultLineMapper(org.springframework.batch.item.file.mapping.DefaultLineMapper) Before(org.junit.Before)

Example 2 with Description

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"));
}
Also used : Descriptions(org.powo.portal.view.Descriptions) Description(org.powo.model.Description) Organisation(org.powo.model.registry.Organisation) DescriptionsBySource(org.powo.portal.view.Descriptions.DescriptionsBySource) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with Description

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));
        }
    }
}
Also used : Descriptions(org.powo.portal.view.Descriptions) Description(org.powo.model.Description) Taxon(org.powo.model.Taxon) DescriptionsBySource(org.powo.portal.view.Descriptions.DescriptionsBySource) Test(org.junit.Test)

Example 4 with Description

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("}");
    }
}
Also used : DescriptionsByType(org.powo.portal.view.Descriptions.DescriptionsByType) Description(org.powo.model.Description) DescriptionsBySource(org.powo.portal.view.Descriptions.DescriptionsBySource)

Example 5 with Description

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);
}
Also used : Descriptions(org.powo.portal.view.Descriptions) Description(org.powo.model.Description) Test(org.junit.Test)

Aggregations

Description (org.powo.model.Description)16 Test (org.junit.Test)8 Taxon (org.powo.model.Taxon)6 Descriptions (org.powo.portal.view.Descriptions)4 DescriptionsBySource (org.powo.portal.view.Descriptions.DescriptionsBySource)4 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)2 Reference (org.powo.model.Reference)2 Organisation (org.powo.model.registry.Organisation)2 Bibliography (org.powo.portal.view.Bibliography)2 ImmutableList (com.google.common.collect.ImmutableList)1 EnumMap (java.util.EnumMap)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 SolrInputDocument (org.apache.solr.common.SolrInputDocument)1 TaxonService (org.powo.api.TaxonService)1 FieldSetMapper (org.powo.job.dwc.description.FieldSetMapper)1 Image (org.powo.model.Image)1 DescriptionType (org.powo.model.constants.DescriptionType)1