Commit 096c6cb1 authored by Igor Filippov (EPAM)'s avatar Igor Filippov (EPAM)
Browse files

refactoring ApiConfiguration

parent 0ef3cb16
Pipeline #26225 failed with stages
in 23 minutes and 18 seconds
......@@ -18,44 +18,34 @@
package org.opengroup.osdu.ingest.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opengroup.osdu.ingest.client.v3.WorkflowServiceClient;
import org.opengroup.osdu.ingest.model.property.DataTypeProperties;
import org.opengroup.osdu.ingest.model.property.WorkflowProperties;
import org.opengroup.osdu.ingest.provider.interfaces.IValidationService;
import org.opengroup.osdu.ingest.provider.interfaces.IWorkflowPayloadService;
import org.opengroup.osdu.ingest.provider.interfaces.v3.IWorkflowIntegrationService;
import org.opengroup.osdu.ingest.service.OsduSubmitServiceImpl;
import org.opengroup.osdu.ingest.service.SubmitServiceImpl;
import org.opengroup.osdu.ingest.service.WorkflowIntegrationServiceImpl;
import org.opengroup.osdu.ingest.service.WorkflowPayloadServiceImpl;
import org.opengroup.osdu.ingest.service.v3.OsduSubmitService;
import org.opengroup.osdu.ingest.service.v3.SubmitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.opengroup.osdu.ingest.service.v3.WorkflowIntegrationService;
import org.opengroup.osdu.ingest.validation.ValidationServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ApiConfiguration {
@Autowired
public ObjectMapper objectMapper;
@Autowired
public DataTypeProperties dataTypeProperties;
@Autowired
public WorkflowProperties workflowProperties;
@Autowired
public IWorkflowIntegrationService workflowIntegrationService;
@Autowired
public IWorkflowPayloadService workflowPayloadService;
@Autowired
public IValidationService validationService;
@Autowired
public WorkflowIntegrationServiceImpl workflowIntegrationServiceImpl;
@Bean(name = "submitService")
@ConditionalOnProperty(prefix = "project.service.api.v3",
name = "enable",
havingValue = "true")
public SubmitService submitService() {
public SubmitService submitService(
WorkflowIntegrationService workflowIntegrationService,
WorkflowPayloadServiceImpl workflowPayloadService,
ValidationServiceImpl validationService) {
return new SubmitService(workflowIntegrationService, workflowPayloadService, validationService);
}
......@@ -63,7 +53,10 @@ public class ApiConfiguration {
@ConditionalOnProperty(prefix = "project.service.api.v3",
name = "enable",
havingValue = "false")
public SubmitServiceImpl submitServiceImpl() {
public SubmitServiceImpl submitServiceImpl(
WorkflowIntegrationServiceImpl workflowIntegrationServiceImpl,
ValidationServiceImpl validationService,
WorkflowPayloadServiceImpl workflowPayloadService) {
return new SubmitServiceImpl(workflowIntegrationServiceImpl, validationService,
workflowPayloadService);
}
......@@ -72,7 +65,10 @@ public class ApiConfiguration {
@ConditionalOnProperty(prefix = "project.service.api.v3",
name = "enable",
havingValue = "true")
public OsduSubmitService osduSubmitService() {
public OsduSubmitService osduSubmitService(
WorkflowIntegrationService workflowIntegrationService,
ObjectMapper objectMapper,
WorkflowProperties workflowProperties) {
return new OsduSubmitService(workflowIntegrationService, objectMapper, workflowProperties);
}
......@@ -80,9 +76,40 @@ public class ApiConfiguration {
@ConditionalOnProperty(prefix = "project.service.api.v3",
name = "enable",
havingValue = "false")
public OsduSubmitServiceImpl osduSubmitServiceImpl() {
public OsduSubmitServiceImpl osduSubmitServiceImpl(
WorkflowIntegrationServiceImpl workflowIntegrationServiceImpl,
WorkflowPayloadServiceImpl workflowPayloadService,
ValidationServiceImpl validationService,
ObjectMapper objectMapper,
DataTypeProperties dataTypeProperties) {
return new OsduSubmitServiceImpl(workflowIntegrationServiceImpl, workflowPayloadService,
validationService,
objectMapper, dataTypeProperties);
}
@Bean
@ConfigurationProperties(prefix = "osdu.data-type")
public DataTypeProperties dataTypeProperties() {
return new DataTypeProperties();
}
@Bean
@ConfigurationProperties(prefix = "osdu.workflow-service")
public WorkflowProperties workflowProperties() {
return new WorkflowProperties();
}
@Bean
@ConfigurationProperties(prefix = "api.v2.submit.manifest")
public WorkflowPropertiesConfiguration workflowPropertiesConfiguration() {
return new WorkflowPropertiesConfiguration();
}
@Bean
public WorkflowIntegrationService workflowIntegrationService(
WorkflowServiceClient clientV3,
ObjectMapper objectMapper,
WorkflowPropertiesConfiguration workflowPropertiesConfiguration) {
return new WorkflowIntegrationService(clientV3, objectMapper, workflowPropertiesConfiguration);
}
}
......@@ -20,13 +20,8 @@ package org.opengroup.osdu.ingest.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "api.v2.submit.manifest")
public class WorkflowPropertiesConfiguration {
private String workflowName;
}
......@@ -16,23 +16,11 @@
package org.opengroup.osdu.ingest.model.property;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import lombok.Getter;
import lombok.Setter;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ConfigurationProperties(prefix = "osdu.data-type")
@Validated
@Component
@Getter
@Setter
public class DataTypeProperties {
String loadManifestType;
}
......@@ -17,27 +17,15 @@
package org.opengroup.osdu.ingest.model.property;
import javax.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import lombok.Getter;
import lombok.Setter;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ConfigurationProperties(prefix = "osdu.workflow-service")
@Validated
@Component
@Getter
@Setter
public class WorkflowProperties {
@NotBlank
String url;
@NotBlank
String appKey;
}
......@@ -41,7 +41,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
@RequiredArgsConstructor
public class WorkflowIntegrationService implements IWorkflowIntegrationService {
private final WorkflowServiceClient clientV3;
......
......@@ -43,14 +43,13 @@ class WorkflowPayloadServiceTest {
private static final String FILE_ID = "file-id";
private WorkflowProperties workflowProperties = WorkflowProperties.builder()
.appKey("test-app-key")
.build();
private WorkflowProperties workflowProperties = new WorkflowProperties();
private IWorkflowPayloadService workflowPayloadService;
@BeforeEach
void setUp() {
workflowProperties.setAppKey("test-app-key");
workflowPayloadService = new WorkflowPayloadServiceImpl(workflowProperties, new ObjectMapper());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment