@@ -0,0 +1,3412 @@
+package br.edu.utfpr.recominer;%0D%0A%0D%0Aimport br.edu.utfpr.recominer.model.Configuration;%0D%0Aimport br.edu.utfpr.recominer.repository.ConfigurationRepository;%0D%0Aimport java.util.List;%0D%0Aimport javax.batch.operations.JobRestartException;%0D%0Aimport javax.inject.Inject;%0D%0Aimport org.slf4j.Logger;%0D%0Aimport org.slf4j.LoggerFactory;%0D%0Aimport org.springframework.batch.core.ExitStatus;%0D%0Aimport org.springframework.batch.core.Job;%0D%0Aimport org.springframework.batch.core.JobExecution;%0D%0Aimport org.springframework.batch.core.JobParameter;%0D%0Aimport org.springframework.batch.core.JobParametersBuilder;%0D%0Aimport org.springframework.batch.core.JobParametersInvalidException;%0D%0Aimport org.springframework.batch.core.launch.JobLauncher;%0D%0Aimport org.springframework.batch.core.repository.JobExecutionAlreadyRunningException;%0D%0Aimport org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException;%0D%0Aimport org.springframework.boot.CommandLineRunner;%0D%0Aimport org.springframework.context.annotation.Profile;%0D%0Aimport org.springframework.stereotype.Component;%0D%0A%0D%0A/**%0D%0A *%0D%0A * @author Rodrigo T. Kuroda %3Crodrigokuroda at alunos.utfpr.edu.br%3E%0D%0A */%0D%0A@Component%0D%0A@Profile(value = %22prod%22)%0D%0Apublic class CommandLineApplication implements CommandLineRunner %7B%0D%0A    private static final Logger LOG = LoggerFactory.getLogger(CommandLineApplication.class);%0D%0A%0D%0A    @Inject%0D%0A    private ConfigurationRepository configurationRepository;%0D%0A    %0D%0A    @Inject%0D%0A    private JobLauncher jobLauncher;%0D%0A%0D%0A    @Inject%0D%0A    private Job extractorJob;%0D%0A%0D%0A    @Override%0D%0A    public void run(String... params) throws Exception %7B%0D%0A        LOG.info(%22Starting Recominer Extractor...%22);%0D%0A        final JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();%0D%0A        jobParametersBuilder.addLong(%22run.id%22, System.currentTimeMillis());%0D%0A%0D%0A        // getting configurable parameters from database%0D%0A        final List%3CConfiguration%3E configurations = configurationRepository.findAll();%0D%0A        for (Configuration configuration : configurations) %7B%0D%0A            jobParametersBuilder.addParameter(configuration.getKey(), new JobParameter(configuration.getValue()));%0D%0A        %7D%0D%0A        %0D%0A        for (String param : params) %7B%0D%0A            String%5B%5D keyValue = param.split(%22=%22);%0D%0A            jobParametersBuilder.addParameter(keyValue%5B0%5D, new JobParameter(keyValue%5B1%5D));%0D%0A        %7D%0D%0A%0D%0A        // execute only if has no job in execution%0D%0A        try %7B%0D%0A            JobExecution jobExecution = jobLauncher.run(extractorJob, jobParametersBuilder.toJobParameters());%0D%0A            final ExitStatus exitStatus = jobExecution.getExitStatus();%0D%0A%0D%0A            LOG.info(%22Job completed with exit status %7B%7D: %7B%7D%22, exitStatus.getExitCode(), exitStatus.getExitDescription());%0D%0A        %7D catch (JobInstanceAlreadyCompleteException ex) %7B%0D%0A            // there are no job in execution or executed.%0D%0A            LOG.warn(%22The job has been run before with the same parameters and completed successfully.%22, ex);%0D%0A        %7D catch (JobRestartException ex) %7B%0D%0A            LOG.error(%22The job has been run before and circumstances that preclude a restart.%22, ex);%0D%0A        %7D catch (JobParametersInvalidException ex) %7B%0D%0A            LOG.error(%22The parameters are not valid for this job.%22, ex);%0D%0A        %7D catch (JobExecutionAlreadyRunningException ex) %7B%0D%0A            LOG.error(%22The JobInstance identified by the properties already has an execution running.%22, ex);%0D%0A        %7D%0D%0A    %7D%0D%0A%7D%0D%0A

Revert delete.