@@ -0,0 +1,2852 @@
+package com.sedc.collectors.finam;%0A%0Aimport com.sedc.Region;%0Aimport com.sedc.collectors.finam.model.FinamApiRecord;%0Aimport org.apache.log4j.Logger;%0Aimport org.springframework.batch.core.Job;%0Aimport org.springframework.batch.core.JobExecution;%0Aimport org.springframework.batch.core.JobParameters;%0Aimport org.springframework.batch.core.configuration.annotation.JobBuilderFactory;%0Aimport org.springframework.batch.core.configuration.annotation.StepBuilderFactory;%0Aimport org.springframework.batch.core.launch.JobLauncher;%0Aimport org.springframework.batch.core.launch.support.RunIdIncrementer;%0Aimport org.springframework.batch.core.step.tasklet.TaskletStep;%0Aimport org.springframework.batch.item.file.FlatFileItemReader;%0Aimport org.springframework.batch.item.file.FlatFileItemWriter;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.core.io.UrlResource;%0A%0A/**%0A * Created by SuperOleg on 01.03.2017.%0A */%0Apublic class FinamApplication %7B%0A%0A    private static final Logger LOG = Logger.getLogger(FinamApplication.class);%0A%0A    @Autowired%0A    private JobLauncher jobLauncher;%0A    @Autowired%0A    private StepBuilderFactory stepBuilderFactory;%0A    @Autowired%0A    private JobBuilderFactory jobBuilderFactory;%0A    @Autowired%0A    private FlatFileItemReader reader;%0A    @Autowired%0A    private FinamApiProcessor processor;%0A    @Autowired%0A    private FlatFileItemWriter writer;%0A%0A    public static void main(String%5B%5D args) %7B%0A        if (args == null %7C%7C args.length != 2) %7B%0A            LOG.info(%22USAGE: %3Cperiod%3E %3Cregion%3E%22); //TODO: make usage%0A            return;%0A        %7D%0A%0A        try %7B%0A            new FinamApplication().run(args);%0A        %7D catch (Exception e) %7B%0A            LOG.error(e.getMessage(), e);%0A        %7D%0A    %7D%0A%0A    private void run(String%5B%5D args) throws Exception %7B%0A%0A%0A        FinamPeriod period = FinamPeriod.getInstance(args%5B0%5D);%0A        Region region = Region.valueOf(args%5B1%5D);%0A%0A        //TODO: make logic here, all below is just an example%0A        reader.setResource(new UrlResource(%22http://export.finam.ru/GAZP_170224_170301.txt?market=1&em=16842&code=GAZP&apply=0&df=24&mf=1&yf=2017&from=24.02.2017&dt=1&mt=2&yt=2017&to=01.03.2017&p=5&f=GAZP_170224_170301&e=.txt&cn=GAZP&dtf=1&tmf=1&MSOR=1&mstime=on&mstimever=1&sep=1&sep2=1&datf=1%22));%0A%0A        TaskletStep step = stepBuilderFactory.get(%22finamStep%22)%0A                .%3CFinamApiRecord, FinamApiRecord%3Echunk(1)%0A                .reader(reader)%0A                .processor(processor)%0A                .writer(writer)%0A                .build();%0A%0A        Job job = jobBuilderFactory.get(%22finamLoad%22)%0A                .incrementer(new RunIdIncrementer())%0A                .flow(step)%0A                .end()%0A                .build();%0A%0A        JobExecution execution = jobLauncher.run(job, new JobParameters());%0A        LOG.info(%22Exit Status : %22 + execution.getStatus());%0A    %7D%0A%7D%0A

add finam main class example