Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/improve samm mapping #52

2 changes: 1 addition & 1 deletion DEPENDENCIES_FRONTEND
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ npm/npmjs/-/flatted/3.2.6, ISC AND (ISC AND MIT), approved, #2430
npm/npmjs/-/fraction.js/4.2.0, MIT, approved, clearlydefined
npm/npmjs/-/fs.realpath/1.0.0, ISC, approved, clearlydefined
npm/npmjs/-/fsevents/2.3.2, MIT, approved, #2967
npm/npmjs/-/function-bind/1.1.1, MIT, approved, clearlydefined
npm/npmjs/-/function-bind/1.1.1, MIT, approved, #11063
npm/npmjs/-/functional-red-black-tree/1.0.1, MIT, approved, clearlydefined
npm/npmjs/-/glob-parent/5.1.2, ISC, approved, clearlydefined
npm/npmjs/-/glob-parent/6.0.2, ISC, approved, clearlydefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
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.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;
Expand Down Expand Up @@ -199,6 +200,7 @@ private void setupCustomerRole() throws JsonProcessingException {
5,
MeasurementUnit.piece,
"BPNS4444444444XX",
LocationIdTypeEnum.B_P_N_S,
new Date()
);
materialStockEntity = materialStockService.create(materialStockEntity);
Expand All @@ -212,6 +214,7 @@ private void setupCustomerRole() throws JsonProcessingException {
10,
MeasurementUnit.piece,
supplierPartner.getSites().stream().findFirst().get().getBpns(),
LocationIdTypeEnum.B_P_N_S,
new Date(),
supplierPartner
);
Expand Down Expand Up @@ -255,6 +258,7 @@ private void setupSupplierRole() {
20,
MeasurementUnit.piece,
"BPNS1234567890ZZ",
LocationIdTypeEnum.B_P_N_S,
new Date(),
customerPartner
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public ProductStockDto updateProductStocks(@RequestBody ProductStockDto productS
existingProductStock.setQuantity(productStockDto.getQuantity());
existingProductStock.setLastUpdatedOn(new Date());

existingProductStock = productStockService.create(existingProductStock);
existingProductStock = productStockService.update(existingProductStock);
log.info("Updated product-stock: " + existingProductStock);

ProductStockDto productStockToReturn = convertToDto(existingProductStock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
import org.eclipse.tractusx.puris.backend.stock.domain.model.datatype.DT_StockTypeEnum;
import org.eclipse.tractusx.puris.backend.stock.domain.model.measurement.MeasurementUnit;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.LocationIdTypeEnum;

import java.util.Date;

Expand All @@ -46,9 +47,10 @@
@NoArgsConstructor
public class MaterialStock extends Stock {

public MaterialStock(Material material, double quantity, MeasurementUnit measurementUnit, String atSiteBpns,
public MaterialStock(Material material, double quantity, MeasurementUnit measurementUnit, String locationId,
LocationIdTypeEnum locationIdType,
Date lastUpdatedOn) {
super(material, quantity, measurementUnit, atSiteBpns, lastUpdatedOn);
super(material, quantity, measurementUnit, locationId, locationIdType, lastUpdatedOn);
super.setType(DT_StockTypeEnum.MATERIAL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.eclipse.tractusx.puris.backend.stock.domain.model.datatype.DT_StockTypeEnum;
import org.eclipse.tractusx.puris.backend.stock.domain.model.measurement.MeasurementUnit;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.LocationIdTypeEnum;

import java.util.Date;

Expand All @@ -53,16 +54,11 @@ public class PartnerProductStock extends Stock {
@NotNull
private Partner supplierPartner;

public PartnerProductStock(Material material, double quantity, MeasurementUnit measurementUnit, String atSiteBpns,
Date lastUpdatedOn, Partner supplierPartner) {
super(material, quantity, measurementUnit, atSiteBpns, lastUpdatedOn);
public PartnerProductStock(Material material, double quantity, MeasurementUnit measurementUnit, String locationId,
LocationIdTypeEnum locationIdType, Date lastUpdatedOn, Partner supplierPartner) {
super(material, quantity, measurementUnit, locationId, locationIdType, lastUpdatedOn);
super.setType(DT_StockTypeEnum.PRODUCT);
this.setSupplierPartner(supplierPartner);
}

public PartnerProductStock(Material material, double quantity, MeasurementUnit measurementUnit, String atSiteBpns, Date lastUpdatedOn) {
super(material, quantity, measurementUnit, atSiteBpns, lastUpdatedOn);
super.setType(DT_StockTypeEnum.PRODUCT);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Partner;
import org.eclipse.tractusx.puris.backend.stock.domain.model.datatype.DT_StockTypeEnum;
import org.eclipse.tractusx.puris.backend.stock.domain.model.measurement.MeasurementUnit;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.LocationIdTypeEnum;

import java.util.Date;

Expand All @@ -51,14 +52,16 @@ public class ProductStock extends Stock {
@NotNull
private Partner allocatedToCustomerPartner;

public ProductStock(Material material, double quantity, MeasurementUnit measurementUnit, String atSiteBpns, Date lastUpdatedOn, Partner allocatedToCustomerPartner) {
super(material, quantity, measurementUnit, atSiteBpns, lastUpdatedOn);
public ProductStock(Material material, double quantity, MeasurementUnit measurementUnit, String locationId,
LocationIdTypeEnum locationIdType, Date lastUpdatedOn, Partner allocatedToCustomerPartner) {
super(material, quantity, measurementUnit, locationId, locationIdType, lastUpdatedOn);
super.setType(DT_StockTypeEnum.PRODUCT);
this.setAllocatedToCustomerPartner(allocatedToCustomerPartner);
}

public ProductStock(Material material, double quantity, MeasurementUnit measurementUnit, String atSiteBpns, Date lastUpdatedOn) {
super(material, quantity, measurementUnit, atSiteBpns, lastUpdatedOn);
public ProductStock(Material material, double quantity, MeasurementUnit measurementUnit, String atSiteBpns,
LocationIdTypeEnum locationIdType, Date lastUpdatedOn) {
super(material, quantity, measurementUnit, atSiteBpns, locationIdType, lastUpdatedOn);
super.setType(DT_StockTypeEnum.PRODUCT);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.Material;
import org.eclipse.tractusx.puris.backend.stock.domain.model.datatype.DT_StockTypeEnum;
import org.eclipse.tractusx.puris.backend.stock.domain.model.measurement.MeasurementUnit;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.LocationIdTypeEnum;

import java.util.Date;
import java.util.UUID;
Expand Down Expand Up @@ -64,7 +65,10 @@ public class Stock {
private MeasurementUnit measurementUnit;

@NotNull
private String atSiteBpns;
private String locationId;

@NotNull
private LocationIdTypeEnum locationIdType;

@Enumerated(EnumType.STRING)
@NotNull
Expand All @@ -74,11 +78,12 @@ public class Stock {
@NotNull
private Date lastUpdatedOn;

public Stock(Material material, double quantity, MeasurementUnit measurementUnit, String atSiteBpns, Date lastUpdatedOn) {
public Stock(Material material, double quantity, MeasurementUnit measurementUnit, String locationId, LocationIdTypeEnum locationIdType, Date lastUpdatedOn) {
this.material = material;
this.quantity = quantity;
this.measurementUnit = measurementUnit;
this.atSiteBpns = atSiteBpns;
this.locationId = locationId;
this.locationIdType = locationIdType;
this.lastUpdatedOn = lastUpdatedOn;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
package org.eclipse.tractusx.puris.backend.stock.domain.model.measurement;

import com.fasterxml.jackson.annotation.JsonValue;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.ProductStockSammDto;

public enum MeasurementUnit {

gram,
Expand Down Expand Up @@ -50,6 +53,17 @@ public enum MeasurementUnit {
set,
pair,
page,
kilowattHour
kilowattHour;

/**
* Returns a json representation needed for de-/serialization of the {@link ProductStockSammDto}.
* For example: "unit:piece"
*
* @return the json representation as String
*/
@JsonValue
public String jsonRepresentation() {
return "unit:" + this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
*/
package org.eclipse.tractusx.puris.backend.stock.domain.repository;

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.stock.domain.model.PartnerProductStock;
import org.eclipse.tractusx.puris.backend.stock.domain.model.Stock;
import org.eclipse.tractusx.puris.backend.stock.domain.model.datatype.DT_StockTypeEnum;
import org.eclipse.tractusx.puris.backend.stock.domain.model.measurement.MeasurementUnit;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.samm.LocationIdTypeEnum;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

Expand All @@ -44,13 +48,16 @@ public interface PartnerProductStockRepository extends JpaRepository<PartnerProd

List<PartnerProductStock> findAllByType(DT_StockTypeEnum stockType);

// List<PartnerProductStock> findAllByMaterial_UuidAndType(UUID materialUuid, DT_StockTypeEnum stockType);

List<PartnerProductStock> findAllByMaterial_OwnMaterialNumberAndType(String ownMaterialNumber, DT_StockTypeEnum stockType);

// List<PartnerProductStock> findAllByMaterial_UuidAndTypeAndSupplierPartner_Uuid(UUID materialUuid, DT_StockTypeEnum stockType, UUID supplierUuid);

List<PartnerProductStock> findAllByMaterial_OwnMaterialNumberAndTypeAndSupplierPartner_Uuid(String ownMaterialNumber, DT_StockTypeEnum stockType, UUID supplierUuid);

List<PartnerProductStock> findAllBySupplierPartner_Uuid(UUID uuid);

List<PartnerProductStock> findAllBySupplierPartnerAndMaterialAndLocationIdAndLocationIdTypeAndMeasurementUnit(
Partner supplierPartner,
Material material,
String locationId,
LocationIdTypeEnum locationIdType,
MeasurementUnit measurementUnit);
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,4 @@ public interface ProductStockRepository extends JpaRepository<ProductStock, UUID

List<ProductStock> findAllByType(DT_StockTypeEnum stockType);

// List<ProductStock> findAllByMaterial_MaterialNumberCustomerAndType(String materialNumberCustomer, DT_StockTypeEnum stockType);

// List<ProductStock> findAllByMaterial_MaterialNumberCustomerAndTypeAndAllocatedToCustomerPartner_Bpnl(String materialNumberCustomer, DT_StockTypeEnum stockType, String allocatedToPartnerBpnl);
}
Loading
Loading