diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/DataInjectionCommandLineRunner.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/DataInjectionCommandLineRunner.java
index b88edfd6..11b98b29 100644
--- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/DataInjectionCommandLineRunner.java
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/DataInjectionCommandLineRunner.java
@@ -37,12 +37,10 @@
import org.eclipse.tractusx.puris.backend.stock.domain.model.*;
import org.eclipse.tractusx.puris.backend.stock.domain.model.measurement.MeasurementUnit;
import org.eclipse.tractusx.puris.backend.stock.logic.adapter.ProductStockSammMapper;
+import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.ItemUnitEnumeration;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.LocationIdTypeEnum;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.ProductStockSammDto;
-import org.eclipse.tractusx.puris.backend.stock.logic.service.MaterialStockService;
-import org.eclipse.tractusx.puris.backend.stock.logic.service.PartnerProductStockService;
-import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockRequestService;
-import org.eclipse.tractusx.puris.backend.stock.logic.service.ProductStockService;
+import org.eclipse.tractusx.puris.backend.stock.logic.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@@ -70,6 +68,11 @@ public class DataInjectionCommandLineRunner implements CommandLineRunner {
@Autowired
private ProductStockService productStockService;
+ @Autowired
+ private MaterialItemStockService materialItemStockService;
+ @Autowired
+ private ReportedMaterialItemStockService reportedMaterialItemStockService;
+
@Autowired
private PartnerProductStockService partnerProductStockService;
@@ -113,7 +116,7 @@ public void run(String... args) throws Exception {
*/
private void createOwnPartnerEntity() {
Partner mySelf;
- if(variablesService.getOwnDefaultBpns()!= null && variablesService.getOwnDefaultBpns().length()!=0) {
+ if (variablesService.getOwnDefaultBpns() != null && variablesService.getOwnDefaultBpns().length() != 0) {
mySelf = new Partner(variablesService.getOwnName(),
variablesService.getEdcProtocolUrl(),
variablesService.getOwnBpnl(),
@@ -135,7 +138,7 @@ private void createOwnPartnerEntity() {
}
mySelf = partnerService.create(mySelf);
log.info("Successfully created own Partner Entity: " + (partnerService.findByBpnl(mySelf.getBpnl()) != null));
- if(mySelf != null) {
+ if (mySelf != null) {
log.info(mySelf.toString());
}
}
@@ -219,6 +222,34 @@ private void setupCustomerRole() throws JsonProcessingException {
log.info("SAMM-DTO:\n" + objectMapper.writeValueAsString(productStockSammDto));
log.info("Own Street and Number: " + variablesService.getOwnDefaultStreetAndNumber());
+ Partner mySelf = partnerService.getOwnPartnerEntity();
+ var builder = MaterialItemStock.builder();
+ var materialItemStock = builder.partner(supplierPartner)
+ .material(semiconductorMaterial)
+ .lastUpdatedOnDateTime(new Date())
+ .locationBpna(mySelf.getSites().first().getAddresses().first().getBpna())
+ .locationBpns(mySelf.getSites().first().getBpns())
+ .measurementUnit(ItemUnitEnumeration.UNIT_PIECE)
+ .quantity(20)
+ .build();
+ var createdMaterialItemStock = materialItemStockService.create(materialItemStock);
+ log.info("Created MaterialItemStock: \n" + createdMaterialItemStock.toString());
+
+ var builder2 = ReportedMaterialItemStock.builder();
+ var reportedMaterialItemStock =
+ builder2
+ .material(semiconductorMaterial)
+ .partner(supplierPartner)
+ .lastUpdatedOnDateTime(new Date())
+ .locationBpns(supplierPartner.getSites().first().getBpns())
+ .locationBpna(supplierPartner.getSites().first().getAddresses().first().getBpna())
+ .measurementUnit(ItemUnitEnumeration.UNIT_PIECE)
+ .quantity(50)
+ .build();
+
+ var createdReportedMaterialItemStock = reportedMaterialItemStockService.create(reportedMaterialItemStock);
+ log.info("Created ReportedMaterialItemStock: \n" + createdReportedMaterialItemStock);
+
}
/**
@@ -266,7 +297,6 @@ private void setupSupplierRole() {
"bpnl: %s", foundProductStocks));
}
-
/**
* creates a new customer Partner entity, stores it to
* the database and returns this entity.
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/domain/model/Address.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/domain/model/Address.java
index 51285148..35b0a217 100644
--- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/domain/model/Address.java
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/domain/model/Address.java
@@ -41,10 +41,11 @@
@ToString
public class Address implements Comparable
{
+ public static final String BPNA_REGEX = "^BPNA[0-9a-zA-Z]{12}$";
/**
* The BPNA of this Address.
*/
- @Pattern(regexp = "^BPNA[0-9a-zA-Z]{12}$")
+ @Pattern(regexp = BPNA_REGEX)
private String bpna;
/**
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/domain/model/Site.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/domain/model/Site.java
index 8227fffd..a54f39a3 100644
--- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/domain/model/Site.java
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/domain/model/Site.java
@@ -45,13 +45,13 @@
@Setter
@ToString
public class Site implements Comparable {
-
+ public static final String BPNS_REGEX = "^BPNS[0-9a-zA-Z]{12}$";
@Id
@NotNull
/**
* The BPNS of this Site.
*/
- @Pattern(regexp = "^BPNS[0-9a-zA-Z]{12}$")
+ @Pattern(regexp = BPNS_REGEX)
private String bpns;
/**
* A human-readable, distinctive name of this site.
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ItemStock.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ItemStock.java
new file mode 100644
index 00000000..e699fb6f
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ItemStock.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.model;
+
+import jakarta.persistence.*;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Pattern;
+import lombok.*;
+import lombok.experimental.SuperBuilder;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Address;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Site;
+import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.ItemUnitEnumeration;
+
+import java.util.Date;
+import java.util.UUID;
+
+@NoArgsConstructor
+@AllArgsConstructor
+@Getter
+@Setter
+@SuperBuilder
+@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
+@Entity
+@ToString
+public abstract class ItemStock {
+
+ static final String ORDER_ID_REGEX = "^[a-zA-Z0-9\\-\\.]{1,255}$";
+
+ @Id
+ @GeneratedValue
+ protected UUID uuid;
+
+ @ManyToOne()
+ @JoinColumn(name = "partner_uuid")
+ @ToString.Exclude
+ @NotNull
+ protected Partner partner;
+ @ManyToOne()
+ @JoinColumn(name = "material_ownMaterialNumber")
+ @ToString.Exclude
+ @NotNull
+ protected Material material;
+
+ protected double quantity;
+ @NotNull
+ protected ItemUnitEnumeration measurementUnit;
+ @NotNull
+ @Pattern(regexp = Address.BPNA_REGEX)
+ protected String locationBpna;
+ @NotNull
+ @Pattern(regexp = Site.BPNS_REGEX)
+ protected String locationBpns;
+ @NotNull
+ protected Date lastUpdatedOnDateTime;
+
+ protected boolean isBlocked;
+ @Pattern(regexp = ORDER_ID_REGEX)
+ protected String supplierOrderId;
+ @Pattern(regexp = ORDER_ID_REGEX)
+ protected String customerOrderId;
+ @Pattern(regexp = ORDER_ID_REGEX)
+ protected String customerOrderPositionId;
+
+ @ToString.Include
+ private String material_ownMaterialNumber(){
+ return material.getOwnMaterialNumber();
+ }
+
+ @ToString.Include
+ private String partner_partnerBpnl(){
+ return partner.getBpnl();
+ }
+
+}
+
+
+
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/MaterialItemStock.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/MaterialItemStock.java
new file mode 100644
index 00000000..79df5fca
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/MaterialItemStock.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.model;
+
+import jakarta.persistence.Entity;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+
+@Entity
+@SuperBuilder
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class MaterialItemStock extends ItemStock {
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ProductItemStock.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ProductItemStock.java
new file mode 100644
index 00000000..e13474cc
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ProductItemStock.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.model;
+
+import jakarta.persistence.Entity;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+
+@Entity
+@SuperBuilder
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class ProductItemStock extends ItemStock {
+
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ReportedMaterialItemStock.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ReportedMaterialItemStock.java
new file mode 100644
index 00000000..76e21b51
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ReportedMaterialItemStock.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.model;
+
+import jakarta.persistence.Entity;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+
+@Entity
+@SuperBuilder
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class ReportedMaterialItemStock extends ItemStock {
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ReportedProductItemStock.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ReportedProductItemStock.java
new file mode 100644
index 00000000..ab3ce4bb
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/model/ReportedProductItemStock.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.model;
+
+import jakarta.persistence.Entity;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+import lombok.experimental.SuperBuilder;
+
+@Entity
+@SuperBuilder
+@NoArgsConstructor
+@ToString(callSuper = true)
+public class ReportedProductItemStock extends ItemStock {
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/MaterialItemStockRepository.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/MaterialItemStockRepository.java
new file mode 100644
index 00000000..7b6b79cb
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/MaterialItemStockRepository.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.repository;
+
+import org.eclipse.tractusx.puris.backend.stock.domain.model.MaterialItemStock;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.UUID;
+@Repository
+public interface MaterialItemStockRepository extends JpaRepository {
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ProductItemStockRepository.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ProductItemStockRepository.java
new file mode 100644
index 00000000..67036837
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ProductItemStockRepository.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.repository;
+
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductItemStock;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.UUID;
+@Repository
+public interface ProductItemStockRepository extends JpaRepository {
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ReportedMaterialItemStockRepository.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ReportedMaterialItemStockRepository.java
new file mode 100644
index 00000000..6b3de4cf
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ReportedMaterialItemStockRepository.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.repository;
+
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ReportedMaterialItemStock;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.UUID;
+@Repository
+public interface ReportedMaterialItemStockRepository extends JpaRepository {
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ReportedProductItemStockRepository.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ReportedProductItemStockRepository.java
new file mode 100644
index 00000000..c8d2be47
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/domain/repository/ReportedProductItemStockRepository.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.domain.repository;
+
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ReportedProductItemStock;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+import java.util.UUID;
+@Repository
+public interface ReportedProductItemStockRepository extends JpaRepository {
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapper.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapper.java
new file mode 100644
index 00000000..ad4828e6
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/adapter/ItemStockSammMapper.java
@@ -0,0 +1,277 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.logic.adapter;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialService;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.MaterialItemStock;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductItemStock;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ReportedMaterialItemStock;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ReportedProductItemStock;
+import org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm.*;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Service
+@Slf4j
+public class ItemStockSammMapper {
+
+ @Autowired
+ private MaterialService materialService;
+ @Autowired
+ private MaterialPartnerRelationService mprService;
+
+ public ItemStockSAMM toItemStockSAMM(MaterialItemStock materialItemStock) {
+ ItemStockSAMM samm = new ItemStockSAMM();
+ samm.setDirection(DirectionCharacteristic.INBOUND);
+ samm.setPositions(new ArrayList<>());
+ samm.setMaterialGlobalAssetId(materialItemStock.getMaterial().getMaterialNumberCx());
+ samm.setMaterialNumberCustomer(materialItemStock.getMaterial().getOwnMaterialNumber());
+ samm.setMaterialNumberSupplier(mprService.find(materialItemStock.getMaterial(),
+ materialItemStock.getPartner()).getPartnerMaterialNumber());
+ var posList = new ArrayList();
+ samm.setPositions(posList);
+ Position position = new Position();
+ if (materialItemStock.getCustomerOrderId() != null || materialItemStock.getCustomerOrderPositionId() != null
+ || materialItemStock.getSupplierOrderId() != null) {
+ OrderPositionReference opr = new OrderPositionReference(materialItemStock.getSupplierOrderId(),
+ materialItemStock.getCustomerOrderId(), materialItemStock.getCustomerOrderPositionId());
+ position.setOrderPositionReference(opr);
+ }
+ ItemQuantityEntity itemQuantityEntity = new ItemQuantityEntity(materialItemStock.getQuantity(),
+ materialItemStock.getMeasurementUnit());
+ AllocatedStock allocatedStock = new AllocatedStock(itemQuantityEntity, materialItemStock.getLocationBpns(),
+ materialItemStock.isBlocked(), materialItemStock.getLocationBpna());
+ var allocatedStocksList = new ArrayList();
+ allocatedStocksList.add(allocatedStock);
+ position.setAllocatedStocks(allocatedStocksList);
+ return samm;
+ }
+
+ public ItemStockSAMM toItemStockSamm(ProductItemStock productItemStock) {
+ ItemStockSAMM samm = new ItemStockSAMM();
+ samm.setDirection(DirectionCharacteristic.OUTBOUND);
+ samm.setPositions(new ArrayList<>());
+ samm.setMaterialGlobalAssetId(productItemStock.getMaterial().getMaterialNumberCx());
+ samm.setMaterialNumberSupplier(productItemStock.getMaterial().getOwnMaterialNumber());
+ samm.setMaterialNumberCustomer(mprService.find(productItemStock.getMaterial(),
+ productItemStock.getPartner()).getPartnerMaterialNumber());
+ var posList = new ArrayList();
+ samm.setPositions(posList);
+ Position position = new Position();
+ if (productItemStock.getCustomerOrderId() != null || productItemStock.getCustomerOrderPositionId() != null
+ || productItemStock.getSupplierOrderId() != null) {
+ OrderPositionReference opr = new OrderPositionReference(productItemStock.getSupplierOrderId(),
+ productItemStock.getCustomerOrderId(), productItemStock.getCustomerOrderPositionId());
+ position.setOrderPositionReference(opr);
+ }
+ ItemQuantityEntity itemQuantityEntity = new ItemQuantityEntity(productItemStock.getQuantity(),
+ productItemStock.getMeasurementUnit());
+ AllocatedStock allocatedStock = new AllocatedStock(itemQuantityEntity, productItemStock.getLocationBpns(),
+ productItemStock.isBlocked(), productItemStock.getLocationBpna());
+ var allocatedStocksList = new ArrayList();
+ allocatedStocksList.add(allocatedStock);
+ position.setAllocatedStocks(allocatedStocksList);
+ return samm;
+ }
+
+ public List sammToReportedProductItemStock(ItemStockSAMM samm, Partner partner) {
+ String matNbrCustomer = samm.getMaterialNumberCustomer();
+ String matNbrSupplier = samm.getMaterialNumberSupplier(); // should be ownMaterialNumber
+ String matNbrCatenaX = samm.getMaterialGlobalAssetId();
+ ArrayList outputList = new ArrayList<>();
+ if(samm.getDirection() != DirectionCharacteristic.INBOUND) {
+ log.warn("Direction should be INBOUND, aborting");
+ return outputList;
+ }
+ Material material = null;
+ // Use CatenaXNbr
+ if (matNbrCatenaX != null) {
+ material = materialService.findByMaterialNumberCx(matNbrCatenaX);
+ if (material != null) {
+ if (!material.getOwnMaterialNumber().equals(matNbrSupplier)) {
+ log.warn("Mismatch between CatenaX Number " + matNbrCatenaX + " and ownMaterialNumber " + matNbrSupplier);
+ }
+ var mpr = mprService.find(material, partner);
+ if (mpr == null) {
+ log.warn("Missing MaterialPartnerRelation for " + material.getOwnMaterialNumber() + " and Partner " + partner.getBpnl());
+ } else {
+ if (!mpr.getPartnerMaterialNumber().equals(matNbrCustomer)) {
+ log.warn("Mismatch for MaterialNumberCustomer " + matNbrCustomer + " and " + material.getOwnMaterialNumber());
+ }
+ }
+ }
+ }
+ // Use MatNbrCustomer
+ if (material == null && matNbrCustomer != null) {
+ var list = mprService.findAllByPartnerMaterialNumber(matNbrCustomer).stream().filter(m -> {
+ var mpr = mprService.find(m, partner);
+ return mpr != null && mpr.isPartnerBuysMaterial();
+ }).toList();
+ if (!list.isEmpty()) {
+ material = list.get(0);
+ if (list.size() > 1) {
+ log.warn("CustomerMaterialNumber " + matNbrCustomer + " is ambiguous, arbitrarily choosing " + material.getOwnMaterialNumber());
+ }
+ }
+ }
+ // Use MatNbrSupplier
+ if (material == null && matNbrSupplier != null) {
+ material = materialService.findByOwnMaterialNumber(matNbrSupplier);
+ if (matNbrCatenaX != null) {
+ log.warn("Unknown CatenaXNumber for Material " + material.getOwnMaterialNumber());
+ }
+ var mpr = mprService.find(material, partner);
+ if (mpr != null) {
+ if (!mpr.getPartnerMaterialNumber().equals(matNbrCustomer)) {
+ log.warn("Unknown MaterialNumberCustomer " + matNbrCustomer + " for Material " + material.getOwnMaterialNumber());
+ }
+ }
+ }
+ if (material == null) {
+ log.warn("Could not identify material with CatenaXNbr " + matNbrCatenaX + " ,CustomerMaterialNbr " + matNbrCustomer + " and SupplierMaterialNbr " + matNbrSupplier);
+ return outputList;
+ }
+ for (var position : samm.getPositions()) {
+ Date lastUpdated = position.getLastUpdatedOnDateTime();
+ String supplierOrderId = null, customerOrderPositionId = null, customerOrderId = null;
+ if (position.getOrderPositionReference() != null) {
+ supplierOrderId = position.getOrderPositionReference().getSupplierOrderId();
+ customerOrderId = position.getOrderPositionReference().getCustomerOrderId();
+ customerOrderPositionId = position.getOrderPositionReference().getCustomerOrderPositionId();
+ }
+ for (var allocatedStock : position.getAllocatedStocks()) {
+ var builder = ReportedProductItemStock.builder();
+ var itemStock = builder
+ .partner(partner)
+ .material(material)
+ .isBlocked(allocatedStock.getIsBlocked())
+ .locationBpna(allocatedStock.getStockLocationBPNA())
+ .locationBpns(allocatedStock.getStockLocationBPNS())
+ .lastUpdatedOnDateTime(lastUpdated)
+ .customerOrderId(customerOrderId)
+ .supplierOrderId(supplierOrderId)
+ .customerOrderPositionId(customerOrderPositionId)
+ .measurementUnit(allocatedStock.getQuantityOnAllocatedStock().getUnit())
+ .quantity(allocatedStock.getQuantityOnAllocatedStock().getValue())
+ .build();
+ outputList.add(itemStock);
+ }
+ }
+ return outputList;
+ }
+
+ public List sammToReportedMaterialItemStock(ItemStockSAMM samm, Partner partner) {
+ String matNbrCustomer = samm.getMaterialNumberCustomer(); // should be ownMaterialNumber
+ String matNbrSupplier = samm.getMaterialNumberSupplier();
+ String matNbrCatenaX = samm.getMaterialGlobalAssetId();
+ ArrayList outputList = new ArrayList<>();
+ if(samm.getDirection() != DirectionCharacteristic.OUTBOUND) {
+ log.warn("Direction should be OUTBOUND, aborting");
+ return outputList;
+ }
+ Material material = null;
+ // Use MatNbrCatenaX
+ if (matNbrCatenaX != null) {
+ material = materialService.findByMaterialNumberCx(matNbrCatenaX);
+ if (material != null) {
+ if (!material.getOwnMaterialNumber().equals(matNbrCustomer)) {
+ log.warn("Mismatch between CatenaX Number " + matNbrCatenaX + " and ownMaterialNumber " + matNbrCustomer);
+ }
+ var mpr = mprService.find(material, partner);
+ if (mpr == null) {
+ log.warn("Missing MaterialPartnerRelation for " + material.getOwnMaterialNumber() + " and Partner " + partner.getBpnl());
+ } else {
+ if (!mpr.getPartnerMaterialNumber().equals(matNbrSupplier)) {
+ log.warn("Mismatch for MaterialNumberSupplier " + matNbrSupplier + " and " + material.getOwnMaterialNumber());
+ }
+ }
+ }
+ }
+ // Use MatNbrCustomer
+ if (material == null && matNbrCustomer != null) {
+ material = materialService.findByOwnMaterialNumber(matNbrCustomer);
+ if (matNbrCatenaX != null) {
+ log.warn("Unknown CatenaXNumber for Material " + material.getOwnMaterialNumber());
+ }
+ var mpr = mprService.find(material, partner);
+ if (mpr != null) {
+ if (!mpr.getPartnerMaterialNumber().equals(matNbrSupplier)) {
+ log.warn("Unknown MaterialNumberSupplier " + matNbrSupplier + " for Material " + material.getOwnMaterialNumber());
+ }
+ }
+ }
+ //Use MatNbrSupplier
+ if (material == null && matNbrSupplier != null) {
+ var list = mprService.findAllByPartnerMaterialNumber(matNbrSupplier)
+ .stream()
+ .filter(m -> {
+ var mpr = mprService.find(m, partner);
+ return mpr != null && mpr.isPartnerSuppliesMaterial();
+ })
+ .toList();
+ if (!list.isEmpty()) {
+ material = list.get(0);
+ if (list.size() > 1) {
+ log.warn("SupplierMaterialNumber " + matNbrSupplier + " is ambiguous, arbitrarily choosing " + material.getOwnMaterialNumber());
+ }
+ }
+ }
+ if (material == null) {
+ log.warn("Could not identify material with CatenaXNbr " + matNbrCatenaX + " ,CustomerMaterialNbr " + matNbrCustomer + " and SupplierMaterialNbr " + matNbrSupplier);
+ return outputList;
+ }
+ for (var position : samm.getPositions()) {
+ Date lastUpdated = position.getLastUpdatedOnDateTime();
+ String supplierOrderId = null, customerOrderPositionId = null, customerOrderId = null;
+ if (position.getOrderPositionReference() != null) {
+ supplierOrderId = position.getOrderPositionReference().getSupplierOrderId();
+ customerOrderId = position.getOrderPositionReference().getCustomerOrderId();
+ customerOrderPositionId = position.getOrderPositionReference().getCustomerOrderPositionId();
+ }
+ for (var allocatedStock : position.getAllocatedStocks()) {
+ var builder = ReportedMaterialItemStock.builder();
+ var itemStock = builder
+ .partner(partner)
+ .material(material)
+ .isBlocked(allocatedStock.getIsBlocked())
+ .locationBpna(allocatedStock.getStockLocationBPNA())
+ .locationBpns(allocatedStock.getStockLocationBPNS())
+ .lastUpdatedOnDateTime(lastUpdated)
+ .customerOrderId(customerOrderId)
+ .supplierOrderId(supplierOrderId)
+ .customerOrderPositionId(customerOrderPositionId)
+ .measurementUnit(allocatedStock.getQuantityOnAllocatedStock().getUnit())
+ .quantity(allocatedStock.getQuantityOnAllocatedStock().getValue())
+ .build();
+ outputList.add(itemStock);
+ }
+ }
+ return outputList;
+ }
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/AllocatedStock.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/AllocatedStock.java
new file mode 100644
index 00000000..83789396
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/AllocatedStock.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Pattern;
+import lombok.Getter;
+import lombok.Setter;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Address;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Site;
+
+import java.util.Objects;
+
+/**
+ * Generated class for Stock Allocated to a Partner. This is the quantity of
+ * items on stock at a location. A stock can either be - from a certain supplier
+ * and ready to be consumed by a customer or - from a supplier and ready to be
+ * shipped to a certain customer.
+ *
+ * In case of stocks "from a supplier ready to be shipped to a certain
+ * customer", the stock may refer to an order position of a customer. This stock
+ * consists only of the good-finished items.
+ */
+@Getter
+@Setter
+public class AllocatedStock {
+
+ @NotNull
+ private ItemQuantityEntity quantityOnAllocatedStock;
+
+ @NotNull
+ @Pattern(regexp = Site.BPNS_REGEX)
+ private String stockLocationBPNS;
+
+ @NotNull
+ private Boolean isBlocked;
+
+ @NotNull
+ @Pattern(regexp = Address.BPNA_REGEX)
+ private String stockLocationBPNA;
+
+ @JsonCreator
+ public AllocatedStock(@JsonProperty(value = "quantityOnAllocatedStock") ItemQuantityEntity quantityOnAllocatedStock,
+ @JsonProperty(value = "stockLocationBPNS") String stockLocationBPNS,
+ @JsonProperty(value = "isBlocked") Boolean isBlocked,
+ @JsonProperty(value = "stockLocationBPNA") String stockLocationBPNA) {
+ this.quantityOnAllocatedStock = quantityOnAllocatedStock;
+ this.stockLocationBPNS = stockLocationBPNS;
+ this.isBlocked = isBlocked;
+ this.stockLocationBPNA = stockLocationBPNA;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final AllocatedStock that = (AllocatedStock) o;
+ return Objects.equals(quantityOnAllocatedStock, that.quantityOnAllocatedStock)
+ && Objects.equals(stockLocationBPNS, that.stockLocationBPNS)
+ && Objects.equals(isBlocked, that.isBlocked)
+ && Objects.equals(stockLocationBPNA, that.stockLocationBPNA);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(quantityOnAllocatedStock, stockLocationBPNS, isBlocked, stockLocationBPNA);
+ }
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/DirectionCharacteristic.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/DirectionCharacteristic.java
new file mode 100644
index 00000000..b3770a83
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/DirectionCharacteristic.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm;
+
+/**
+ * Generated class {@link DirectionCharacteristic}.
+ */
+
+public enum DirectionCharacteristic {
+ INBOUND, OUTBOUND;
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemQuantityEntity.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemQuantityEntity.java
new file mode 100644
index 00000000..54747708
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemQuantityEntity.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm;
+
+import jakarta.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.util.Objects;
+
+/**
+ * Generated class for Item Quantity Entity. Entity for common measurements of
+ * an item (mass, count, linear, area, volume, misc) with an unit and a value.
+ */
+@Getter
+@Setter
+@AllArgsConstructor
+@NoArgsConstructor
+public class ItemQuantityEntity {
+
+ @NotNull
+ private Double value;
+
+ @NotNull
+ private ItemUnitEnumeration unit;
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final ItemQuantityEntity that = (ItemQuantityEntity) o;
+ return Objects.equals(value, that.value) && Objects.equals(unit, that.unit);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(value, unit);
+ }
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemStockSAMM.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemStockSAMM.java
new file mode 100644
index 00000000..92a6f1c8
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemStockSAMM.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Pattern;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Semi-Generated class for Stock of Items. This aspect represents the latest
+ * quantities of a partner's items that are on stock. The stock represent the
+ * build-to-order (BTO) stocks already available.
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+public class ItemStockSAMM {
+
+ @NotNull
+ private List positions;
+
+ @NotNull
+ private String materialNumberCustomer;
+
+ @Pattern(regexp = "(^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)|(^urn:uuid:[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$)")
+ private String materialGlobalAssetId;
+
+ private String materialNumberSupplier;
+
+ @NotNull
+ private DirectionCharacteristic direction;
+
+ @JsonCreator
+ public ItemStockSAMM(@JsonProperty(value = "positions") List positions,
+ @JsonProperty(value = "materialNumberCustomer") String materialNumberCustomer,
+ @JsonProperty(value = "materialGlobalAssetId") String materialGlobalAssetId,
+ @JsonProperty(value = "materialNumberSupplier") String materialNumberSupplier,
+ @JsonProperty(value = "direction") DirectionCharacteristic direction) {
+ this.positions = positions;
+ this.materialNumberCustomer = materialNumberCustomer;
+ this.materialGlobalAssetId = materialGlobalAssetId;
+ this.materialNumberSupplier = materialNumberSupplier;
+ this.direction = direction;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final ItemStockSAMM that = (ItemStockSAMM) o;
+ return Objects.equals(positions, that.positions)
+ && Objects.equals(materialNumberCustomer, that.materialNumberCustomer)
+ && Objects.equals(materialGlobalAssetId, that.materialGlobalAssetId)
+ && Objects.equals(materialNumberSupplier, that.materialNumberSupplier)
+ && Objects.equals(direction, that.direction);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(positions, materialNumberCustomer, materialGlobalAssetId, materialNumberSupplier,
+ direction);
+ }
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemUnitEnumeration.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemUnitEnumeration.java
new file mode 100644
index 00000000..3e36a2ac
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/ItemUnitEnumeration.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm;
+
+import com.fasterxml.jackson.annotation.JsonValue;
+
+/**
+ * Generated class {@link ItemUnitEnumeration}.
+ */
+public enum ItemUnitEnumeration {
+ UNIT_PIECE("unit:piece"),
+ UNIT_SET("unit:set"),
+ UNIT_PAIR("unit:pair"),
+ UNIT_PAGE("unit:page"),
+ UNIT_CYCLE("unit:cycle"),
+ UNIT_KILOWATT_HOUR("unit:kilowattHour"),
+ UNIT_GRAM("unit:gram"),
+ UNIT_KILOGRAM("unit:kilogram"),
+ UNIT_TONNE_METRIC_TON("unit:tonneMetricTon"),
+ UNIT_TON_US_OR_SHORT_TON_UKORUS("unit:tonUsOrShortTonUkorus"),
+ UNIT_OUNCE_AVOIRDUPOIS("unit:ounceAvoirdupois"),
+ UNIT_POUND("unit:pound"),
+ UNIT_METRE("unit:metre"),
+ UNIT_CENTIMETRE("unit:centimetre"),
+ UNIT_KILOMETRE("unit:kilometre"),
+ UNIT_INCH("unit:inch"),
+ UNIT_FOOT("unit:foot"),
+ UNIT_YARD("unit:yard"),
+ UNIT_SQUARE_CENTIMETRE("unit:squareCentimetre"),
+ UNIT_SQUARE_METRE("unit:squareMetre"),
+ UNIT_SQUARE_INCH("unit:squareInch"),
+ UNIT_SQUARE_FOOT("unit:squareFoot"),
+ UNIT_SQUARE_YARD("unit:squareYard"),
+ UNIT_CUBIC_CENTIMETRE("unit:cubicCentimetre"),
+ UNIT_CUBIC_METRE("unit:cubicMetre"),
+ UNIT_CUBIC_INCH("unit:cubicInch"),
+ UNIT_CUBIC_FOOT("unit:cubicFoot"),
+ UNIT_CUBIC_YARD("unit:cubicYard"),
+ UNIT_LITRE("unit:litre"),
+ UNIT_MILLILITRE("unit:millilitre"),
+ UNIT_HECTOLITRE("unit:hectolitre"),
+ UNIT_SECOND_UNIT_OF_TIME("unit:secondUnitOfTime"),
+ UNIT_MINUTE_UNIT_OF_TIME("unit:minuteUnitOfTime"),
+ UNIT_HOUR_UNIT_OF_TIME("unit:hourUnitOfTime"),
+ UNIT_DAY("unit:day");
+
+ private String value;
+
+ ItemUnitEnumeration(String value) {
+ this.value = value;
+ }
+
+ @JsonValue
+ public String getValue() {
+ return value;
+ }
+
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/OrderPositionReference.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/OrderPositionReference.java
new file mode 100644
index 00000000..d5ce9774
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/OrderPositionReference.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Objects;
+
+/**
+ * Generated class for Reference to Order Position. Encapsulates the references
+ * to identify a position within an order.
+ */
+
+@Getter
+@Setter
+public class OrderPositionReference {
+
+ private String supplierOrderId;
+
+ @NotNull
+ private String customerOrderId;
+
+ @NotNull
+ private String customerOrderPositionId;
+
+ @JsonCreator
+ public OrderPositionReference(@JsonProperty(value = "supplierOrderId") String supplierOrderId,
+ @JsonProperty(value = "customerOrderId") String customerOrderId,
+ @JsonProperty(value = "customerOrderPositionId") String customerOrderPositionId) {
+ this.supplierOrderId = supplierOrderId;
+ this.customerOrderId = customerOrderId;
+ this.customerOrderPositionId = customerOrderPositionId;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final OrderPositionReference that = (OrderPositionReference) o;
+ return Objects.equals(supplierOrderId, that.supplierOrderId)
+ && Objects.equals(customerOrderId, that.customerOrderId)
+ && Objects.equals(customerOrderPositionId, that.customerOrderPositionId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(supplierOrderId, customerOrderId, customerOrderPositionId);
+ }
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/Position.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/Position.java
new file mode 100644
index 00000000..4d4f0cd1
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/dto/itemstocksamm/Position.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.eclipse.tractusx.puris.backend.stock.logic.dto.itemstocksamm;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Generated class for Position. The Position can be located at several stocks.
+ * In case of a supplier's stock for a customer, a position may be either
+ * anonymous or reference a position within a customer order. In case of a
+ * customer's stock for a supplier, the order position reference MUST NOT be
+ * set.
+ */
+
+@Getter
+@Setter
+@NoArgsConstructor
+public class Position {
+ private OrderPositionReference orderPositionReference;
+
+ @NotNull
+ private Date lastUpdatedOnDateTime;
+
+ @NotNull
+ private List allocatedStocks;
+
+ @JsonCreator
+ public Position(
+ @JsonProperty(value = "orderPositionReference") OrderPositionReference orderPositionReference,
+ @JsonProperty(value = "lastUpdatedOnDateTime") Date lastUpdatedOnDateTime,
+ @JsonProperty(value = "allocatedStocks") List allocatedStocks) {
+ this.orderPositionReference = orderPositionReference;
+ this.lastUpdatedOnDateTime = lastUpdatedOnDateTime;
+ this.allocatedStocks = allocatedStocks;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ final Position that = (Position) o;
+ return Objects.equals(orderPositionReference, that.orderPositionReference)
+ && Objects.equals(lastUpdatedOnDateTime, that.lastUpdatedOnDateTime)
+ && Objects.equals(allocatedStocks, that.allocatedStocks);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(orderPositionReference, lastUpdatedOnDateTime, allocatedStocks);
+ }
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ItemStockService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ItemStockService.java
new file mode 100644
index 00000000..0666c19e
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ItemStockService.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package org.eclipse.tractusx.puris.backend.stock.logic.service;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.MaterialPartnerRelation;
+import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ItemStock;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import java.util.function.Function;
+
+
+@Slf4j
+
+public abstract class ItemStockService {
+
+ protected final PartnerService partnerService;
+
+ protected final MaterialPartnerRelationService mprService;
+
+ protected final JpaRepository repository;
+
+ protected final Function validator;
+
+ public ItemStockService(PartnerService partnerService, MaterialPartnerRelationService mprService, JpaRepository repository) {
+ this.partnerService = partnerService;
+ this.mprService = mprService;
+ this.repository = repository;
+ this.validator = this::validate;
+ }
+
+
+
+ public final T create(T itemStock) {
+ if(itemStock.getUuid() != null && repository.findById(itemStock.getUuid()).isPresent()) {
+ return null;
+ }
+ if(!validator.apply(itemStock)) {
+ return null;
+ }
+ return repository.save(itemStock);
+ }
+
+ public final T update(T itemStock) {
+ if(itemStock.getUuid() == null || repository.findById(itemStock.getUuid()).isEmpty()) {
+ return null;
+ }
+ return repository.save(itemStock);
+ }
+
+ public final T findById(UUID uuid) {
+ return repository.findById(uuid).orElse(null);
+ }
+
+ public final void delete(UUID uuid) {
+ repository.deleteById(uuid);
+ }
+
+ public final List findAll() {
+ return repository.findAll();
+ }
+
+ public abstract boolean validate(T itemStock);
+
+ protected boolean basicValidation(ItemStock itemStock) {
+ try {
+ Objects.requireNonNull(itemStock.getPartner(), "Missing Partner");
+ Objects.requireNonNull(itemStock.getMaterial(), "Missing Material");
+ Objects.requireNonNull(itemStock.getLocationBpna(), "Missing locationBpna");
+ Objects.requireNonNull(itemStock.getLocationBpns(), "Missing locationBpns");
+ Objects.requireNonNull(itemStock.getMeasurementUnit(), "Missing measurementUnit");
+ Objects.requireNonNull(itemStock.getLastUpdatedOnDateTime(), "Missing lastUpdatedOnTime");
+ } catch (Exception e) {
+ log.error("Basic Validation failed: " + itemStock + "\n" + e.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean validateLocalStock(ItemStock itemStock) {
+ return validateLocation(itemStock, partnerService.getOwnPartnerEntity());
+ }
+
+ protected boolean validateRemoteStock(ItemStock itemStock) {
+ return validateLocation(itemStock, itemStock.getPartner());
+ }
+
+ protected final boolean validateMaterialItemStock(ItemStock itemStock) {
+ try {
+ Partner partner = itemStock.getPartner();
+ Material material = itemStock.getMaterial();
+ MaterialPartnerRelation relation = mprService.find(material, partner);
+ Objects.requireNonNull(relation, "Missing MaterialPartnerRelation");
+ if(!material.isMaterialFlag()) {
+ throw new IllegalArgumentException("Material flag is missing");
+ }
+ if(!relation.isPartnerSuppliesMaterial()) {
+ throw new IllegalArgumentException("Partner does not supply material");
+ }
+ } catch (Exception e) {
+ log.error("MaterialItemStock Validation failed: " + itemStock + "\n" + e.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ protected final boolean validateProductItemStock(ItemStock itemStock) {
+ try {
+ Partner partner = itemStock.getPartner();
+ Material material = itemStock.getMaterial();
+ MaterialPartnerRelation relation = mprService.find(material, partner);
+ Objects.requireNonNull(relation, "Missing MaterialPartnerRelation");
+ if (!material.isProductFlag()) {
+ throw new IllegalArgumentException("Product flag is missing");
+ }
+ if (!relation.isPartnerBuysMaterial()) {
+ throw new IllegalArgumentException("Partner does not buy material");
+ }
+ } catch (Exception e) {
+ log.error("ProductItemStock Validation failed: " + itemStock + "\n" + e.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+ protected boolean validateLocation(ItemStock itemStock, Partner partner) {
+ try {
+ var stockSite = partner.getSites().stream()
+ .filter(site -> site.getBpns().equals(itemStock.getLocationBpns()))
+ .findFirst().orElse(null);
+ Objects.requireNonNull(stockSite, "Site not found");
+ var stockAddress = stockSite.getAddresses().stream()
+ .filter(addr -> addr.getBpna().equals(itemStock.getLocationBpna()))
+ .findFirst().orElse(null);
+ Objects.requireNonNull(stockAddress, "Address not found");
+ } catch (Exception e) {
+ log.error("Location Validation failed: " + itemStock + "\n" + e.getMessage());
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/MaterialItemStockService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/MaterialItemStockService.java
new file mode 100644
index 00000000..2f93e5a0
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/MaterialItemStockService.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.logic.service;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.MaterialItemStock;
+import org.eclipse.tractusx.puris.backend.stock.domain.repository.MaterialItemStockRepository;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class MaterialItemStockService extends ItemStockService {
+
+
+ public MaterialItemStockService(PartnerService partnerService, MaterialPartnerRelationService mprService,
+ MaterialItemStockRepository repository) {
+ super(partnerService, mprService, repository);
+ }
+
+ @Override
+ public boolean validate(MaterialItemStock materialItemStock) {
+ return basicValidation(materialItemStock) && validateLocalStock(materialItemStock)
+ && validateMaterialItemStock(materialItemStock);
+ }
+
+
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ProductItemStockService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ProductItemStockService.java
new file mode 100644
index 00000000..1008b05c
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ProductItemStockService.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.logic.service;
+
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductItemStock;
+import org.eclipse.tractusx.puris.backend.stock.domain.repository.ProductItemStockRepository;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class ProductItemStockService extends ItemStockService {
+
+
+ public ProductItemStockService(PartnerService partnerService, MaterialPartnerRelationService mprService,
+ ProductItemStockRepository repository) {
+ super(partnerService, mprService, repository);
+ }
+
+
+ public boolean validate(ProductItemStock productItemStock) {
+ return basicValidation(productItemStock) && validateLocalStock(productItemStock)
+ && validateProductItemStock(productItemStock);
+ }
+
+
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ReportedMaterialItemStockService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ReportedMaterialItemStockService.java
new file mode 100644
index 00000000..2c284aa1
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ReportedMaterialItemStockService.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.logic.service;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ReportedMaterialItemStock;
+import org.eclipse.tractusx.puris.backend.stock.domain.repository.ReportedMaterialItemStockRepository;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class ReportedMaterialItemStockService extends ItemStockService {
+
+
+ public ReportedMaterialItemStockService(PartnerService partnerService, MaterialPartnerRelationService mprService, ReportedMaterialItemStockRepository repository) {
+ super(partnerService, mprService, repository);
+ }
+
+ @Override
+ public boolean validate(ReportedMaterialItemStock itemStock) {
+ return basicValidation(itemStock) && validateMaterialItemStock(itemStock) && validateRemoteStock(itemStock);
+ }
+}
diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ReportedProductItemStockService.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ReportedProductItemStockService.java
new file mode 100644
index 00000000..4f954fe6
--- /dev/null
+++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/stock/logic/service/ReportedProductItemStockService.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2023 Volkswagen AG
+ * Copyright (c) 2023 Contributors to the Eclipse Foundation
+ *
+ * See the NOTICE file(s) distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Apache License, Version 2.0 which is available at
+ * https://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package org.eclipse.tractusx.puris.backend.stock.logic.service;
+
+import lombok.extern.slf4j.Slf4j;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.MaterialPartnerRelationService;
+import org.eclipse.tractusx.puris.backend.masterdata.logic.service.PartnerService;
+import org.eclipse.tractusx.puris.backend.stock.domain.model.ReportedProductItemStock;
+import org.eclipse.tractusx.puris.backend.stock.domain.repository.ReportedProductItemStockRepository;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class ReportedProductItemStockService extends ItemStockService {
+ public ReportedProductItemStockService(PartnerService partnerService, MaterialPartnerRelationService mprService,
+ ReportedProductItemStockRepository repository) {
+ super(partnerService, mprService, repository);
+ }
+
+
+ @Override
+ public boolean validate(ReportedProductItemStock itemStock) {
+ return basicValidation(itemStock) && validateProductItemStock(itemStock) && validateRemoteStock(itemStock);
+ }
+}