Skip to content

Commit

Permalink
[MODEXPS-273] Remove @SuperBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Saba-Zedginidze-EPAM committed Dec 30, 2024
1 parent 78f5693 commit 2d8aeed
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;

import com.fasterxml.jackson.databind.ObjectMapper;

@Configuration
@Log4j2
@RequiredArgsConstructor
Expand All @@ -30,33 +32,33 @@ public class EdifactExportJobConfig {
private Job constructEdifactExportJob(JobBuilder jobBuilder,
EdiExportJobCompletionListener ediExportJobCompletionListener,
Step mapToFileStep,
Step saveToMinIOStep,
Step saveToFTPStep,
Step saveToMinIOStep,
Step createExportHistoryRecordsStep,
Map<Step, JobExecutionDecider> optionalStepDeciders) {
Map<String, JobExecutionDecider> optionalStepDeciders) {
return jobBuilder.incrementer(new RunIdIncrementer())
.listener(ediExportJobCompletionListener)
.start(mapToFileStep)
.next(saveToMinIOStep)
.next(optionalStepDeciders.get(saveToFTPStep))
.on(ExportStepDecision.PROCESS.getStatus()).to(saveToFTPStep)
.next(optionalStepDeciders.get(createExportHistoryRecordsStep))
.on(ExportStepDecision.PROCESS.getStatus()).to(createExportHistoryRecordsStep)
.next(optionalStepDeciders.get(saveToFTPStep.getName()))
.on(ExportStepDecision.PROCESS.getStatus()).to(saveToFTPStep)
.next(optionalStepDeciders.get(createExportHistoryRecordsStep.getName()))
.on(ExportStepDecision.PROCESS.getStatus()).to(createExportHistoryRecordsStep)
.end().build();
}

@Bean
public Job edifactOrdersExportJob(EdiExportJobCompletionListener ediExportJobCompletionListener, JobRepository jobRepository,
Step mapToEdifactOrdersStep, Step saveToFTPStep, Step saveToMinIOStep, Step createExportHistoryRecordsStep,
Map<Step, JobExecutionDecider> deciders) {
Map<String, JobExecutionDecider> deciders) {
return constructEdifactExportJob(new JobBuilder(ExportType.EDIFACT_ORDERS_EXPORT.getValue(), jobRepository),
ediExportJobCompletionListener, mapToEdifactOrdersStep, saveToFTPStep, saveToMinIOStep, createExportHistoryRecordsStep, deciders);
}

@Bean
public Job edifactClaimsExportJob(EdiExportJobCompletionListener ediExportJobCompletionListener, JobRepository jobRepository,
Step mapToEdifactClaimsStep, Step saveToFTPStep, Step saveToMinIOStep, Step createExportHistoryRecordsStep,
Map<Step, JobExecutionDecider> deciders) {
Map<String, JobExecutionDecider> deciders) {
return constructEdifactExportJob(new JobBuilder(ExportType.CLAIMS.getValue(), jobRepository),
ediExportJobCompletionListener, mapToEdifactClaimsStep, saveToFTPStep, saveToMinIOStep, createExportHistoryRecordsStep, deciders);
}
Expand Down Expand Up @@ -102,11 +104,10 @@ public Step createExportHistoryRecordsStep(ExportHistoryTasklet exportHistoryTas
}

@Bean
public Map<Step, JobExecutionDecider> optionalStepDeciders(Step saveToFTPStep, SaveToFileStorageTaskletDecider saveToFileStorageTaskletDecider,
Step createExportHistoryRecordsStep, ExportHistoryTaskletDecider exportHistoryTaskletDecider) {
public Map<String, JobExecutionDecider> optionalStepDeciders(Step saveToFTPStep, Step createExportHistoryRecordsStep, ObjectMapper objectMapper) {
return Map.of(
saveToFTPStep, saveToFileStorageTaskletDecider,
createExportHistoryRecordsStep, exportHistoryTaskletDecider
saveToFTPStep.getName(), new SaveToFileStorageTaskletDecider(objectMapper),
createExportHistoryRecordsStep.getName(), new ExportHistoryTaskletDecider(objectMapper)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.folio.dew.batch.ExecutionContextUtils;
import org.folio.dew.batch.acquisitions.edifact.services.OrganizationsService;
Expand All @@ -27,10 +29,9 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import lombok.experimental.SuperBuilder;
import lombok.extern.log4j.Log4j2;

@SuperBuilder
@RequiredArgsConstructor
@Component
@StepScope
@Log4j2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,31 @@

import org.apache.commons.collections4.CollectionUtils;
import org.folio.dew.batch.acquisitions.edifact.mapper.ExportResourceMapper;
import org.folio.dew.batch.acquisitions.edifact.services.OrdersService;
import org.folio.dew.batch.acquisitions.edifact.services.OrganizationsService;
import org.folio.dew.domain.dto.Piece;
import org.folio.dew.domain.dto.VendorEdiOrdersExportConfig;
import org.folio.dew.domain.dto.acquisitions.edifact.ExportHolder;
import org.folio.dew.error.NotFoundException;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.stereotype.Component;

import lombok.experimental.SuperBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;

@SuperBuilder
@Component
@StepScope
public class MapToEdifactClaimsTasklet extends MapToEdifactTasklet {

private final ExportResourceMapper edifactMapper;
private final ExportResourceMapper csvMapper;

public MapToEdifactClaimsTasklet(ObjectMapper ediObjectMapper, OrganizationsService organizationsService, OrdersService ordersService,
ExportResourceMapper edifactMapper, ExportResourceMapper csvMapper) {
super(ediObjectMapper, organizationsService, ordersService);
this.edifactMapper = edifactMapper;
this.csvMapper = csvMapper;
}

@Override
protected ExportResourceMapper getExportResourceMapper(VendorEdiOrdersExportConfig ediOrdersExportConfig) {
return switch (ediOrdersExportConfig.getFileFormat()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.folio.dew.batch.acquisitions.edifact.mapper.ExportResourceMapper;
import org.folio.dew.batch.acquisitions.edifact.services.OrdersService;
import org.folio.dew.batch.acquisitions.edifact.services.OrganizationsService;
import org.folio.dew.client.DataExportSpringClient;
import org.folio.dew.domain.dto.ExportConfigCollection;
import org.folio.dew.domain.dto.ExportType;
Expand All @@ -29,10 +31,10 @@
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.stereotype.Component;

import lombok.experimental.SuperBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.extern.log4j.Log4j2;

@SuperBuilder
@Component
@StepScope
@Log4j2
Expand All @@ -41,6 +43,13 @@ public class MapToEdifactOrdersTasklet extends MapToEdifactTasklet {
private final DataExportSpringClient dataExportSpringClient;
private final ExportResourceMapper edifactMapper;

public MapToEdifactOrdersTasklet(ObjectMapper ediObjectMapper, OrganizationsService organizationsService, OrdersService ordersService,
DataExportSpringClient dataExportSpringClient, ExportResourceMapper edifactMapper) {
super(ediObjectMapper, organizationsService, ordersService);
this.dataExportSpringClient = dataExportSpringClient;
this.edifactMapper = edifactMapper;
}

@Override
protected List<String> getExportConfigMissingFields(VendorEdiOrdersExportConfig ediOrdersExportConfig) {
List<String> missingFields = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import io.xlate.edi.stream.EDIStreamException;
import lombok.experimental.SuperBuilder;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;

@SuperBuilder
@RequiredArgsConstructor
@Log4j2
public abstract class MapToEdifactTasklet implements Tasklet {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.experimental.SuperBuilder;
import lombok.extern.log4j.Log4j2;

@SuperBuilder
@RequiredArgsConstructor
@Component
@StepScope
@Log4j2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.experimental.SuperBuilder;
import lombok.extern.log4j.Log4j2;

@SuperBuilder
@RequiredArgsConstructor
@Component
@StepScope
@Log4j2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
import org.folio.dew.domain.dto.VendorEdiOrdersExportConfig;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.stereotype.Component;

import lombok.experimental.SuperBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.extern.log4j.Log4j2;

@SuperBuilder
@Component
@StepScope
@Log4j2
public class ExportHistoryTaskletDecider extends ExportStepDecider {

public ExportHistoryTaskletDecider(ObjectMapper objectMapper) {
super(objectMapper);
}

@Override
public ExportStepDecision decide(VendorEdiOrdersExportConfig exportConfig, JobExecution jobExecution, StepExecution stepExecution) {
// Always execute if the integration type is not ORDERING, or execute for other integration types if the transmission method is FTP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.experimental.SuperBuilder;

@SuperBuilder
@RequiredArgsConstructor
public abstract class ExportStepDecider implements JobExecutionDecider {

private final ObjectMapper objectMapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
import org.folio.dew.domain.dto.VendorEdiOrdersExportConfig;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.configuration.annotation.StepScope;
import org.springframework.stereotype.Component;

import lombok.experimental.SuperBuilder;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.extern.log4j.Log4j2;

@SuperBuilder
@Component
@StepScope
@Log4j2
public class SaveToFileStorageTaskletDecider extends ExportStepDecider {

public SaveToFileStorageTaskletDecider(ObjectMapper objectMapper) {
super(objectMapper);
}

@Override
public ExportStepDecision decide(VendorEdiOrdersExportConfig exportConfig, JobExecution jobExecution, StepExecution stepExecution) {
// Always execute if the integration type is ORDERING, or other integration type if the transmission method is FTP
Expand Down

0 comments on commit 2d8aeed

Please sign in to comment.