diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/domain/model/AssetType.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/domain/model/AssetType.java index 7fb93f01..d902b5b2 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/domain/model/AssetType.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/domain/model/AssetType.java @@ -27,7 +27,7 @@ public enum AssetType { DEMAND_SUBMODEL("urn:samm:io.catenax.short_term_material_demand:1.0.0#ShortTermMaterialDemand", "$value", "ShortTermMaterialDemand", "1.0"), DELIVERY_SUBMODEL("urn:samm:io.catenax.delivery_information:2.0.0#DeliveryInformation", "$value", "DeliveryInformation", "2.0"), NOTIFICATION("urn:samm:io.catenax.demand_and_capacity_notification:2.0.0#DemandAndCapacityNotification", "none", "none", "2.0"), - DAYS_OF_SUPPLY("urn:samm:io.catenax.days_of_supply:1.0.0#DaysOfSupply", "$value", "DaysOfSupply", "1.0"), + DAYS_OF_SUPPLY("urn:samm:io.catenax.days_of_supply:2.0.0#DaysOfSupply", "$value", "DaysOfSupply", "1.0"), PART_TYPE_INFORMATION_SUBMODEL("urn:samm:io.catenax.part_type_information:1.0.0#PartTypeInformation", "$value", "none", "1.0"); public final String URN_SEMANTIC_ID; diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java index 9d55a343..90315292 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/edc/logic/service/EdcAdapterService.java @@ -174,7 +174,7 @@ public boolean registerAssetsInitially() { variablesService.getNotificationApiAssetId(), variablesService.getNotificationEndpoint() ))); - log.info("Registration of Days of Supply 1.0.0 submodel successful {}", (assetRegistration = registerSubmodelAsset( + log.info("Registration of Days of Supply 2.0.0 submodel successful {}", (assetRegistration = registerSubmodelAsset( variablesService.getDaysOfSupplySubmodelApiAssetId(), variablesService.getDaysOfSupplySubmodelEndpoint(), AssetType.DAYS_OF_SUPPLY.URN_SEMANTIC_ID diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java index fb22d5a8..72eebb25 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/common/util/VariablesService.java @@ -143,12 +143,13 @@ public String getNotificationEndpoint() { */ private String notificationAssetId; - @Value("${puris.baseurl}" + "catena/days-of-supply/request") /** * The url under which this application's request endpoint can * be reached by external machines. */ - private String daysOfSupplySubmodelEndpoint; + public String getDaysOfSupplySubmodelEndpoint() { + return getPurisBaseUrl() + getContextPath() + "days-of-supply/request"; + } @Value("${puris.daysofsupplysubmodel.apiassetid}") /** diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java index e36363bc..7943770f 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java @@ -92,7 +92,7 @@ public class DemandController { @Operation(summary = "Get all own demands for the given Material", description = "Get all own demands for the given material number. Optionally the demanding site can be filtered by its bpns.") public List getAllDemands(@Parameter(description = "encoded in base64") String ownMaterialNumber, Optional site) { ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); - return ownDemandService.findAllByFilters(Optional.of(ownMaterialNumber), Optional.empty(), site, Optional.empty()) + return ownDemandService.findAllByFilters(Optional.of(ownMaterialNumber), Optional.empty(), site) .stream().map(this::convertToDto).collect(Collectors.toList()); } @@ -175,7 +175,7 @@ public List getAllDemandsForPartner(@Parameter(description = "encoded if (ownMaterialNumber != null) { ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); } - return reportedDemandService.findAllByFilters(Optional.of(ownMaterialNumber), bpnl, site, Optional.empty()) + return reportedDemandService.findAllByFilters(Optional.of(ownMaterialNumber), bpnl, site) .stream().map(this::convertToDto).collect(Collectors.toList()); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/DemandRequestApiService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/DemandRequestApiService.java index ecdbc932..f6d30a76 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/DemandRequestApiService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/DemandRequestApiService.java @@ -86,7 +86,7 @@ public ShortTermMaterialDemand handleDemandSubmodelRequest(String bpnl, String m return null; } - var currentDemands = ownDemandService.findAllByFilters(Optional.of(material.getOwnMaterialNumber()), Optional.of(partner.getBpnl()), Optional.empty(), Optional.empty()); + var currentDemands = ownDemandService.findAllByFilters(Optional.of(material.getOwnMaterialNumber()), Optional.of(partner.getBpnl()), Optional.empty()); return sammMapper.ownDemandToSamm(currentDemands, partner, material); } @@ -109,7 +109,7 @@ public void doReportedDemandRequest(Partner partner, Material material) { } } // delete older data: - var oldDemands = reportedDemandService.findAllByFilters(Optional.of(material.getOwnMaterialNumber()), Optional.of(partner.getBpnl()), Optional.empty(), Optional.empty()); + var oldDemands = reportedDemandService.findAllByFilters(Optional.of(material.getOwnMaterialNumber()), Optional.of(partner.getBpnl()), Optional.empty()); for (var oldDemand : oldDemands) { reportedDemandService.delete(oldDemand.getUuid()); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/DemandService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/DemandService.java index ffde7cdf..d4898292 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/DemandService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/DemandService.java @@ -70,8 +70,7 @@ public final List findAllByOwnMaterialNumber(String ownMaterialNumber) public final List findAllByFilters( Optional ownMaterialNumber, Optional bpnl, - Optional demandLocationBpns, - Optional day) { + Optional demandLocationBpns) { var stream = repository.findAll().stream(); if (ownMaterialNumber.isPresent()) { stream = stream.filter(demand -> demand.getMaterial().getOwnMaterialNumber().equals(ownMaterialNumber.get())); @@ -82,17 +81,6 @@ public final List findAllByFilters( if (demandLocationBpns.isPresent()) { stream = stream.filter(demand -> demand.getDemandLocationBpns().equals(demandLocationBpns.get())); } - if (day.isPresent()) { - LocalDate localDayDate = Instant.ofEpochMilli(day.get().getTime()) - .atOffset(ZoneOffset.UTC) - .toLocalDate(); - stream = stream.filter(demand -> { - LocalDate demandDayDate = Instant.ofEpochMilli(demand.getDay().getTime()) - .atOffset(ZoneOffset.UTC) - .toLocalDate(); - return demandDayDate.getDayOfMonth() == localDayDate.getDayOfMonth(); - }); - } return stream.toList(); } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/OwnDemandService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/OwnDemandService.java index 21ac1b62..1c645880 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/OwnDemandService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/demand/logic/services/OwnDemandService.java @@ -47,7 +47,7 @@ public OwnDemandService(OwnDemandRepository repository, PartnerService partnerSe public final List getQuantityForDays(String material, String partnerBpnl, String siteBpns, int numberOfDays) { List quantities = new ArrayList<>(); LocalDate localDate = LocalDate.now(); - List demands = findAllByFilters(Optional.of(material), Optional.of(partnerBpnl), Optional.of(siteBpns), Optional.empty()); + List demands = findAllByFilters(Optional.of(material), Optional.of(partnerBpnl), Optional.of(siteBpns)); for (int i = 0; i < numberOfDays; i++) { Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); LocalDate localDayDate = Instant.ofEpochMilli(date.getTime()).atOffset(ZoneOffset.UTC).toLocalDate(); diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/DaysOfSupplyRequestApiController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/DaysOfSupplyRequestApiController.java index 66eb0d8e..c66419e9 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/DaysOfSupplyRequestApiController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/DaysOfSupplyRequestApiController.java @@ -1,6 +1,6 @@ /* - * Copyright (c) 2023, 2024 Volkswagen AG - * Copyright (c) 2023, 2024 Contributors to the Eclipse Foundation + * Copyright (c) 2024 Volkswagen AG + * Copyright (c) 2024 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -38,7 +38,7 @@ @RequestMapping("days-of-supply") @Slf4j /** - * This class offers the endpoint for requesting the DaysOfSupply Submodel 1.0.0 + * This class offers the endpoint for requesting the DaysOfSupply Submodel 2.0.0 */ public class DaysOfSupplyRequestApiController { @@ -49,7 +49,7 @@ public class DaysOfSupplyRequestApiController { private final Pattern urnPattern = PatternStore.URN_OR_UUID_PATTERN; - @Operation(summary = "This endpoint receives the DaysOfSupply Submodel 1.0.0 requests") + @Operation(summary = "This endpoint receives the DaysOfSupply Submodel 2.0.0 requests") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Ok"), @ApiResponse(responseCode = "400", description = "Bad Request"), @@ -63,11 +63,11 @@ public ResponseEntity getDaysOfSupplyMapping( @PathVariable DirectionCharacteristic direction, @PathVariable String representation) { if (!bpnlPattern.matcher(bpnl).matches() || !urnPattern.matcher(materialnumbercx).matches()) { - log.warn("Rejecting request at DaysOfSupply Submodel request 1.0.0 endpoint"); + log.warn("Rejecting request at DaysOfSupply Submodel request 2.0.0 endpoint"); return ResponseEntity.badRequest().build(); } if (!"$value".equals(representation)) { - log.warn("Rejecting request at DaysOfSupply Submodel request 1.0.0 endpoint, missing '$value' in request"); + log.warn("Rejecting request at DaysOfSupply Submodel request 2.0.0 endpoint, missing '$value' in request"); if (!PatternStore.NON_EMPTY_NON_VERTICAL_WHITESPACE_PATTERN.matcher(representation).matches()) { representation = ""; } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/service/CustomerSupplyService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/service/CustomerSupplyService.java index 96214301..f6030e43 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/service/CustomerSupplyService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/service/CustomerSupplyService.java @@ -110,7 +110,11 @@ public boolean validate(ReportedCustomerSupply daysOfSupply) { daysOfSupply.getMaterial() != null && daysOfSupply.getDate() != null && daysOfSupply.getStockLocationBPNS() != null && + daysOfSupply.getStockLocationBPNA() != null && daysOfSupply.getPartner() != partnerService.getOwnPartnerEntity() && - daysOfSupply.getPartner().getSites().stream().anyMatch(site -> site.getBpns().equals(daysOfSupply.getStockLocationBPNS())); + daysOfSupply.getPartner().getSites().stream().anyMatch(site -> + site.getBpns().equals(daysOfSupply.getStockLocationBPNS()) && + site.getAddresses().stream().anyMatch(address -> address.getBpna().equals(daysOfSupply.getStockLocationBPNA())) + ); } } diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/service/SupplierSupplyService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/service/SupplierSupplyService.java index 956d8165..8deb0516 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/service/SupplierSupplyService.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/service/SupplierSupplyService.java @@ -111,7 +111,11 @@ public boolean validate(ReportedSupplierSupply daysOfSupply) { daysOfSupply.getMaterial() != null && daysOfSupply.getDate() != null && daysOfSupply.getStockLocationBPNS() != null && + daysOfSupply.getStockLocationBPNA() != null && daysOfSupply.getPartner() != partnerService.getOwnPartnerEntity() && - daysOfSupply.getPartner().getSites().stream().anyMatch(site -> site.getBpns().equals(daysOfSupply.getStockLocationBPNS())); + daysOfSupply.getPartner().getSites().stream().anyMatch(site -> + site.getBpns().equals(daysOfSupply.getStockLocationBPNS()) && + site.getAddresses().stream().anyMatch(address -> address.getBpna().equals(daysOfSupply.getStockLocationBPNA())) + ); } } diff --git a/charts/puris/Chart.yaml b/charts/puris/Chart.yaml index 76831671..6318dde7 100644 --- a/charts/puris/Chart.yaml +++ b/charts/puris/Chart.yaml @@ -35,7 +35,7 @@ dependencies: # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 2.8.0 +version: 2.7.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to