Skip to content

Commit

Permalink
fix: cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Bailonis committed Aug 25, 2023
1 parent 425466f commit d8dbb46
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 117 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.*;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.CapacityGroupStatus;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.exceptions.BadRequestException;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.exceptions.NotFoundException;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.CustomerRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.MaterialDemandRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.WeekBasedCapacityGroupRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.CapacityGroupService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.WeekBasedCapacityGroupService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.UUIDUtil;
import org.springframework.stereotype.Service;
Expand All @@ -49,14 +46,8 @@ public class WeekBasedCapacityGroupServiceImpl implements WeekBasedCapacityGroup

private final WeekBasedCapacityGroupRepository weekBasedCapacityGroupRepository;


private final CustomerRepository customerRepository;

private final CapacityGroupService capacityGroupService;

private final MaterialDemandRepository materialDemandRepository;


@Override
public void createWeekBasedCapacityGroup(List<WeekBasedCapacityGroupRequest> weekBasedCapacityGroupRequestList) {
weekBasedCapacityGroupRequestList.forEach(
Expand Down Expand Up @@ -118,26 +109,21 @@ public void receiveWeekBasedCapacityGroup() {

@Override
public void sendWeekBasedCapacityGroup() {

Optional<CustomerEntity> supplierEntityOpt = customerRepository.findById(1l);

//TODO we still dont have defined the demand or the capacity structure yet, this is just an example of the flux
if (supplierEntityOpt.isPresent()) {
CustomerEntity supplierEntity = supplierEntityOpt.get();

//todo put this part of the code in the ConsumerHTTP class
RestTemplate restTemplate = new RestTemplate();
String fooResourceUrl = supplierEntity.getEdcUrl();

//TODO create the Actual Demand and send to the supplier
//ResponseEntity<String> response = restTemplate.getForEntity(fooResourceUrl, String.class);
}

List<CapacityGroupEntity> capacityGroupEntityList = capacityGroupService.getAllByStatus(
CapacityGroupStatus.READY_SYNCHRONIZE
);

capacityGroupEntityList.forEach(this::createWeekBasedCapacityGroupRequestFromEntity);
// Optional<CustomerEntity> supplierEntityOpt = customerRepository.findById(1l);
//
// //TODO we still dont have defined the demand or the capacity structure yet, this is just an example of the flux
// if (supplierEntityOpt.isPresent()) {
// //todo change this to company entity
// //CustomerEntity supplierEntity = supplierEntityOpt.get();
//
// //todo put this part of the code in the ConsumerHTTP class
// RestTemplate restTemplate = new RestTemplate();
//
// //String fooResourceUrl = supplierEntity.getEdcUrl();
//
// //TODO create the Actual Demand and send to the supplier
// ResponseEntity<String> response = restTemplate.getForEntity("", String.class);
// }
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.MaterialDemandEntity;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.WeekBasedMaterialDemandEntity;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.enums.MaterialDemandStatus;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.exceptions.BadRequestException;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.WeekBasedMaterialDemandRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.DemandService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.LinkDemandService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.WeekBasedMaterialService;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.utils.DataConverterUtil;
Expand All @@ -49,11 +47,8 @@ public class WeekBasedMaterialServiceImpl implements WeekBasedMaterialService {

private final WeekBasedMaterialDemandRepository weekBasedMaterialDemandRepository;


private final LinkDemandService linkDemandService;

private final DemandService demandService;

@Override
public void createWeekBasedMaterial(List<WeekBasedMaterialDemandRequestDto> weekBasedMaterialDemandRequestDtoList) {
weekBasedMaterialDemandRequestDtoList.forEach(
Expand All @@ -70,23 +65,16 @@ public void createWeekBasedMaterial(List<WeekBasedMaterialDemandRequestDto> week

@Override
public void sendWeekBasedMaterial() {

Optional<SupplierEntity> supplierEntityOpt = supplierRepository.findById(1l);

if (supplierEntityOpt.isPresent()) {
SupplierEntity supplierEntity = supplierEntityOpt.get();
RestTemplate restTemplate = new RestTemplate();
String fooResourceUrl = supplierEntity.getEdcUrl();
//TODO create the Actual Demand and send to the supplier
// ResponseEntity<String> response = restTemplate.getForEntity(fooResourceUrl, String.class);
}

List<MaterialDemandEntity> demandEntityList = demandService.getAllByStatus(
MaterialDemandStatus.READY_SYNCHRONIZE
);

demandEntityList.forEach(this::createWeekBasedMaterialRequestFromEntity);

// Optional<SupplierEntity> supplierEntityOpt = supplierRepository.findById(1l);
//
// if (supplierEntityOpt.isPresent()) {
// SupplierEntity supplierEntity = supplierEntityOpt.get();
// RestTemplate restTemplate = new RestTemplate();
// String fooResourceUrl = supplierEntity.getEdcUrl();
//
// //TODO create the Actual Demand and send to the supplier
// ResponseEntity<String> response = restTemplate.getForEntity(fooResourceUrl, String.class);
// }
}

@Override
Expand Down Expand Up @@ -159,7 +147,7 @@ private void validateFields(WeekBasedMaterialDemandRequestDto weekBasedMaterialD
weekBasedMaterialDemandRequestDto
.getDemandSeries()
.forEach(
demandWeekSeriesDto -> {
demandWeekSeriesDto ->
demandWeekSeriesDto
.getDemands()
.forEach(
Expand All @@ -168,8 +156,7 @@ private void validateFields(WeekBasedMaterialDemandRequestDto weekBasedMaterialD
throw new BadRequestException("not a valid date");
}
}
);
}
)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,4 @@

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

create table demand_category
(
id uuid DEFAULT uuid_generate_v4() primary key ,
demand_category_code varchar(400),
demand_category_name varchar(400)
);

create table unity_of_measure
(
id uuid constraint unity_of_measure_pk primary key,
code_value varchar(400) ,
display_value varchar(400)
);

create table company_base_data
(
id uuid constraint company_base_data_pk primary key,
bpn varchar(400),
company_name varchar(400),
street varchar(400),
number varchar(400),
zip_code varchar(400),
country varchar(400),
my_company varchar(400),
edc_url varchar(400)
);

create table material_demand
(
id uuid DEFAULT uuid_generate_v4() primary key,
material_description_customer varchar(400),
material_number_customer varchar(400),
material_number_supplier varchar(400),
changed_at timestamp,
customer_id uuid constraint customer_id references company_base_data(id),
supplier_id uuid constraint supplier_id references company_base_data(id),
unity_of_measure_id uuid constraint unity_of_measure_id references unity_of_measure(id)
);

create table demand_series
(
id uuid DEFAULT uuid_generate_v4() primary key,
material_demand_id uuid constraint material_demand_id references material_demand(id),
customer_location_id uuid constraint customer_location_id references company_base_data(id),
expected_supplier_location_id varchar(720),
demand_category_code_id uuid constraint demand_category_code_id references demand_category(id)
);

create table demand_series_values
(
id uuid DEFAULT uuid_generate_v4() primary key,
demand_series_id uuid constraint demand_series_id references demand_series(id),
calendar_week timestamp not null,
demand numeric

)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.DemandSeries;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.MaterialDemandEntity;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.entities.WeekBasedCapacityGroupEntity;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.CustomerRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.MaterialDemandRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.WeekBasedCapacityGroupRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.impl.WeekBasedCapacityGroupServiceImpl;
Expand All @@ -55,9 +54,6 @@ public class WeekBasedCapacityGroupServiceTest {
@Mock
private WeekBasedCapacityGroupRepository weekBasedCapacityGroupRepository;

@Mock
private CustomerRepository customerRepository;

@Mock
private CapacityGroupService capacityGroupService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import eclipse.tractusx.demand_capacity_mgmt_specification.model.DemandWeekSeriesDto;
import eclipse.tractusx.demand_capacity_mgmt_specification.model.WeekBasedMaterialDemandRequestDto;
import java.util.List;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.SupplierRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.repositories.WeekBasedMaterialDemandRepository;
import org.eclipse.tractusx.demandcapacitymgmt.demandcapacitymgmtbackend.services.impl.WeekBasedMaterialServiceImpl;
import org.junit.jupiter.api.Test;
Expand All @@ -27,9 +26,6 @@ public class WeekBasedMaterialServiceTest {
@Mock
private WeekBasedMaterialDemandRepository weekBasedMaterialDemandRepository;

@Mock
private SupplierRepository supplierRepository;

@Mock
private LinkDemandService linkDemandService;

Expand Down

0 comments on commit d8dbb46

Please sign in to comment.