Skip to content

Commit

Permalink
A1SDS-2452 Code updated for response new version
Browse files Browse the repository at this point in the history
  • Loading branch information
ChetanT-System committed Jun 22, 2023
1 parent 3956951 commit 9e38331
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.eclipse.tractusx.sde.submodels.apr.entity.AspectRelationshipEntity;
import org.eclipse.tractusx.sde.submodels.apr.model.AspectRelationship;
import org.eclipse.tractusx.sde.submodels.apr.model.AspectRelationshipResponse;
import org.eclipse.tractusx.sde.submodels.apr.model.ChildPart;
import org.eclipse.tractusx.sde.submodels.apr.model.ChildItems;
import org.eclipse.tractusx.sde.submodels.apr.model.Quantity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
Expand Down Expand Up @@ -70,26 +70,31 @@ public JsonObject mapToResponse(String parentCatenaXUuid, List<AspectRelationshi
return null;
}

Set<ChildPart> childParts = aspectRelationships.stream().map(this::toChildPart).collect(Collectors.toSet());
Set<ChildItems> childItems = aspectRelationships.stream().map(this::toChildItems).collect(Collectors.toSet());
return new Gson().toJsonTree(
AspectRelationshipResponse.builder().catenaXId(parentCatenaXUuid).childItems(childParts).build())
.getAsJsonObject();
AspectRelationshipResponse.builder()
.catenaXId(parentCatenaXUuid)
.childItems(childItems)
.build()).getAsJsonObject();

}

public AspectRelationshipResponse mapforResponse(JsonObject entity) {
return new Gson().fromJson(entity, AspectRelationshipResponse.class);
}

private ChildPart toChildPart(AspectRelationshipEntity entity) {
Quantity quantity = Quantity.builder().quantityNumber(entity.getQuantityNumber())
private ChildItems toChildItems(AspectRelationshipEntity entity) {
Quantity quantity = Quantity.builder()
.quantityNumber(entity.getQuantityNumber())
.measurementUnit(entity.getMeasurementUnit())
.build();

return ChildPart.builder()
return ChildItems.builder()
.createdOn(entity.getCreatedOn())
.businessPartner(entity.getChildManufacturerId())
.catenaXId(entity.getChildCatenaXId()).quantity(quantity).build();
.catenaXId(entity.getChildCatenaXId())
.quantity(quantity)
.build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
@AllArgsConstructor
public class AspectRelationshipResponse {
private String catenaXId;
private Set<ChildPart> childItems;
private Set<ChildItems> childItems;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@Data
@AllArgsConstructor
@Builder
public class ChildPart {
public class ChildItems {

private Quantity quantity;
private String createdOn;
Expand Down

0 comments on commit 9e38331

Please sign in to comment.