Skip to content
Snippets Groups Projects
Commit 2a64d0aa authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#663 - migrator: removed unnecessary autowire calls

parent 16d2b2b8
No related branches found
No related tags found
No related merge requests found
Showing
with 13 additions and 23 deletions
......@@ -21,6 +21,8 @@ import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
@Configuration
@EnableBatchProcessing
public class BatchConfiguration
......@@ -28,26 +30,19 @@ public class BatchConfiguration
final JobBuilderFactory jobBuilderFactory;
final StepBuilderFactory stepBuilderFactory;
final ImageReader imageReader;
final ImageProcessor imageProcessor;
final DestinationImageRepository destinationImageRepository;
final DataSource primaryDataSource;
final CategoryReader categoryReader;
final CategoryProcessor categoryProcessor;
final DestinationImageRepository destinationImageRepository;
final DestinationCategoryRepository destinationCategoryRepository;
public BatchConfiguration(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory, ImageReader imageReader, ImageProcessor imageProcessor, DestinationImageRepository destinationImageRepository, CategoryReader categoryReader, CategoryProcessor categoryProcessor, DestinationCategoryRepository destinationCategoryRepository)
public BatchConfiguration(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory, DataSource primaryDataSource, DestinationImageRepository destinationImageRepository, DestinationCategoryRepository destinationCategoryRepository)
{
this.jobBuilderFactory = jobBuilderFactory;
this.stepBuilderFactory = stepBuilderFactory;
this.primaryDataSource = primaryDataSource;
this.imageReader = imageReader;
this.imageProcessor = imageProcessor;
this.destinationImageRepository = destinationImageRepository;
this.categoryReader = categoryReader;
this.destinationCategoryRepository = destinationCategoryRepository;
this.categoryProcessor = categoryProcessor;
}
@Bean
......@@ -66,8 +61,8 @@ public class BatchConfiguration
{
return stepBuilderFactory.get("Migrate images")
.<DestinationImage, DestinationImage>chunk(1)
.reader(imageReader)
.processor(imageProcessor)
.reader(new ImageReader(primaryDataSource))
.processor(new ImageProcessor())
.writer(new GenericWriter<>(destinationImageRepository))
.listener(new GenericChunkListener("image"))
.listener(new GenericStepListener("images"))
......@@ -79,8 +74,8 @@ public class BatchConfiguration
{
return stepBuilderFactory.get("Migrate categories")
.<DestinationCategory, DestinationCategory>chunk(1)
.reader(categoryReader)
.processor(categoryProcessor)
.reader(new CategoryReader(primaryDataSource))
.processor(new CategoryProcessor())
.writer(new GenericWriter<>(destinationCategoryRepository))
.listener(new GenericChunkListener("category"))
.listener(new GenericStepListener("categories"))
......
......@@ -19,6 +19,7 @@ public class DestinationCategory
public DestinationCategory()
{
// empty
}
public Integer getID()
......
......@@ -21,6 +21,7 @@ public class DestinationImage
public DestinationImage()
{
// empty
}
public Integer getID()
......
......@@ -4,9 +4,7 @@ import de.deadlocker8.budgetmaster.databasemigrator.destination.category.Destina
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.stereotype.Component;
@Component
public class CategoryProcessor implements ItemProcessor<DestinationCategory, DestinationCategory>
{
private static final Logger LOGGER = LoggerFactory.getLogger(CategoryProcessor.class);
......
......@@ -3,13 +3,11 @@ package de.deadlocker8.budgetmaster.databasemigrator.steps.category;
import de.deadlocker8.budgetmaster.databasemigrator.destination.category.DestinationCategory;
import de.deadlocker8.budgetmaster.databasemigrator.steps.BaseReader;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
@Component
public class CategoryReader extends BaseReader<DestinationCategory>
{
private static class DatabaseColumns
......
......@@ -4,9 +4,8 @@ import de.deadlocker8.budgetmaster.databasemigrator.destination.image.Destinatio
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.stereotype.Component;
@Component
public class ImageProcessor implements ItemProcessor<DestinationImage, DestinationImage>
{
private static final Logger LOGGER = LoggerFactory.getLogger(ImageProcessor.class);
......
......@@ -3,13 +3,11 @@ package de.deadlocker8.budgetmaster.databasemigrator.steps.image;
import de.deadlocker8.budgetmaster.databasemigrator.destination.image.DestinationImage;
import de.deadlocker8.budgetmaster.databasemigrator.steps.BaseReader;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.sql.ResultSet;
import java.sql.SQLException;
@Component
public class ImageReader extends BaseReader<DestinationImage>
{
private static class DatabaseColumns
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment