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

Fix: product stock exchange message uses dash instead of camel case #15

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class SuccessfullRequestDto {
public class SuccessfulRequestDto {

@JsonProperty("request-id")
@JsonProperty("requestId")
private UUID requestId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.tractusx.puris.backend.common.api.controller.exception.RequestIdAlreadyUsedException;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.MessageHeader;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype.DT_RequestStateEnum;
import org.eclipse.tractusx.puris.backend.common.api.logic.dto.MessageHeaderDto;
import org.eclipse.tractusx.puris.backend.common.api.logic.dto.RequestDto;
import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfullRequestDto;
import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfulRequestDto;
import org.eclipse.tractusx.puris.backend.common.api.logic.service.RequestApiService;
import org.eclipse.tractusx.puris.backend.common.api.logic.service.RequestService;
import org.eclipse.tractusx.puris.backend.common.edc.logic.service.EdcAdapterService;
Expand Down Expand Up @@ -129,7 +128,7 @@ public ResponseEntity<Object> postRequest(@RequestBody String requestBody) {
respondAsyncThread.start();

// if the request has been correctly taken over, return 202
return ResponseEntity.status(HttpStatusCode.valueOf(202)).body(new SuccessfullRequestDto(requestId));
return ResponseEntity.status(HttpStatusCode.valueOf(202)).body(new SuccessfulRequestDto(requestId));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype.DT_RequestStateEnum;
import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfullRequestDto;
import org.eclipse.tractusx.puris.backend.common.api.logic.dto.SuccessfulRequestDto;
import org.eclipse.tractusx.puris.backend.common.api.logic.service.RequestService;
import org.eclipse.tractusx.puris.backend.common.api.logic.service.ResponseApiService;
import org.eclipse.tractusx.puris.backend.stock.logic.adapter.ApiMarshallingService;
Expand All @@ -39,7 +39,6 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -98,7 +97,7 @@ public ResponseEntity<Object> postResponse(@RequestBody String body) {
responseApiService.consumeResponse(productStockResponseDto);

// if the request has been correctly taken over, return 202
return ResponseEntity.status(HttpStatusCode.valueOf(202)).body(new SuccessfullRequestDto(requestId));
return ResponseEntity.status(HttpStatusCode.valueOf(202)).body(new SuccessfulRequestDto(requestId));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public interface PartnerProductStockService {

PartnerProductStock update(PartnerProductStock partnerProductStock);

List<PartnerProductStock> findAllByMaterialUuidAndPartnerUuid(UUID partnerUuid,
UUID materialUuid);
List<PartnerProductStock> findAllByMaterialUuidAndPartnerUuid(UUID materialUuid,
UUID partnerUuid);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public PartnerProductStock update(PartnerProductStock partnerProductStock) {
}

@Override
public List<PartnerProductStock> findAllByMaterialUuidAndPartnerUuid(UUID partnerUuid, UUID materialUuid) {
public List<PartnerProductStock> findAllByMaterialUuidAndPartnerUuid(UUID materialUuid, UUID partnerUuid) {
return partnerProductStockRepository.findAllByMaterial_UuidAndTypeAndSupplierPartner_Uuid(materialUuid, DT_StockTypeEnum.PRODUCT, partnerUuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public void consumeResponse(ResponseDto responseDto) {
// or whether an update is sufficient.
List<PartnerProductStock> existingPartnerProductStocks =
partnerProductStockService.findAllByMaterialUuidAndPartnerUuid(
partnerProductStockDto.getSupplierPartner().getUuid(),
partnerProductStockDto.getMaterial().getUuid()
);
partnerProductStockDto.getMaterial().getUuid(),
partnerProductStockDto.getSupplierPartner().getUuid()
);

// currently we only accept a one to one mapping of partner - material - stock -site
// therefore the can only be one PartnerProductStock
Expand All @@ -104,8 +104,12 @@ public void consumeResponse(ResponseDto responseDto) {
log.info(String.format("Created Partner ProductStock from SAMM: %s",
createdPartnerProductStock));
} else {
// update quantity only
PartnerProductStock existingPartnerProductStock = existingPartnerProductStocks.get(0);
existingPartnerProductStock.setQuantity(partnerProductStockDto.getQuantity());

PartnerProductStock updatedPartnerProductStock =
partnerProductStockService.update(existingPartnerProductStocks.get(0));
partnerProductStockService.update(existingPartnerProductStock);
log.info(String.format("Updated Partner ProductStock from SAMM: %s",
updatedPartnerProductStock));
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ VITE_ENDPOINT_MATERIAL_STOCKS=stockView/material-stocks
VITE_ENDPOINT_PRODUCT_STOCKS=stockView/product-stocks
VITE_ENDPOINT_CUSTOMER=stockView/customer?materialUuid=
VITE_ENDPOINT_PARTNER_PRODUCT_STOCKS=stockView/partner-product-stocks
VITE_ENDPOINT_UPDATE_PARTNER_PRODUCT_STOCK=stockView/update-partner-product-stock?materialUuid=
VITE_ENDPOINT_UPDATE_PARTNER_PRODUCT_STOCK=stockView/update-partner-product-stock?ownMaterialNumber=
6 changes: 3 additions & 3 deletions frontend/src/views/StockView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ export default {
methods: {
addOrUpdateStock(changedStock) {
if (changedStock.type === "Material") {
var existingMaterialStock = this.bdMaterialStocks.filter(
var existingMaterialStocks = this.bdMaterialStocks.filter(
(stock) => (stock.material.uuid === changedStock.materialId)
);

if (existingMaterialStock.length === 1) { // Update existing material stock
var existingMaterialStock = existingMaterialStock[0];
if (existingMaterialStocks.length === 1) { // Update existing material stock
var existingMaterialStock = existingMaterialStocks[0];
existingMaterialStock.quantity = changedStock.quantity;

this.putData(this.backendURL + this.endpointMaterialStocks, existingMaterialStock);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/stock/PartnerStockSFC.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
.catch(err => console.log(err));
},
updateMaterialOrProduct() {
fetch(this.backendURL + this.endpointUpdatePartnerProductStock + this.materialUuid)
fetch(this.backendURL + this.endpointUpdatePartnerProductStock + this.selectedMaterialOrProductId)
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.log(err));
Expand Down
1 change: 1 addition & 0 deletions frontend/src/views/stock/StockTableSFC.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default {
return {
selectedStockId: "",
selectedStockUuid: "",
materialNumberCustomer : ""
};
},
methods: {
Expand Down
Loading