use of org.powo.model.convert.NomenclaturalStatusConverter in project powop by RBGKew.
the class TaxonParsingTest method setUp.
@Before
public final void setUp() throws Exception {
String[] names = new String[] { "http://rs.tdwg.org/dwc/terms/taxonID", "http://rs.tdwg.org/dwc/terms/scientificName", "http://rs.tdwg.org/dwc/terms/scientificNameID", "http://rs.tdwg.org/dwc/terms/scientificNameAuthorship", "http://rs.tdwg.org/dwc/terms/taxonRank", "http://rs.tdwg.org/dwc/terms/taxonomicStatus", "http://rs.tdwg.org/dwc/terms/parentNameUsageID", "http://rs.tdwg.org/dwc/terms/acceptedNameUsageID", "http://rs.tdwg.org/dwc/terms/genus", "http://rs.tdwg.org/dwc/terms/subgenus", "http://rs.tdwg.org/dwc/terms/specificEpithet", "http://rs.tdwg.org/dwc/terms/infraspecificEpithet", "http://purl.org/dc/elements/1.1/identifier", "http://purl.org/dc/elements/1.1/modified", "http://purl.org/dc/elements/1.1/source" };
DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
tokenizer.setDelimiter(DelimitedLineTokenizer.DELIMITER_TAB);
tokenizer.setNames(names);
taxonService = EasyMock.createMock(TaxonService.class);
@SuppressWarnings("rawtypes") Set<Converter> converters = new HashSet<>();
converters.add(new StringToIsoDateTimeConverter());
converters.add(new TaxonomicStatusConverter());
converters.add(new RankConverter());
converters.add(new NomenclaturalStatusConverter());
ConversionServiceFactoryBean factoryBean = new ConversionServiceFactoryBean();
factoryBean.setConverters(converters);
factoryBean.afterPropertiesSet();
ConversionService conversionService = factoryBean.getObject();
FieldSetMapper fieldSetMapper = new FieldSetMapper();
fieldSetMapper.setFieldNames(names);
fieldSetMapper.setDefaultValues(new HashMap<String, String>());
fieldSetMapper.setConversionService(conversionService);
DefaultLineMapper<Taxon> lineMapper = new DefaultLineMapper<Taxon>();
lineMapper.setFieldSetMapper(fieldSetMapper);
lineMapper.setLineTokenizer(tokenizer);
flatFileItemReader.setEncoding("UTF-8");
flatFileItemReader.setLinesToSkip(0);
flatFileItemReader.setResource(content);
flatFileItemReader.setLineMapper(lineMapper);
flatFileItemReader.afterPropertiesSet();
}
Aggregations