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

Refactor/frontend backend interface #14

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
cf57abe
fix: frontend now sending materialNumberCustomer to update-partner-pr…
eschrewe Jul 31, 2023
03cd94e
fix: request/response endpoint now use requestId as key
eschrewe Aug 1, 2023
e8f01c8
feat: added MaterialPartnerRelation and accompanying services
eschrewe Aug 1, 2023
a035464
refactor: adjustments in existing classes
eschrewe Aug 1, 2023
10a2784
fix: some cleaning up, added flag consitency test for materialpartner…
eschrewe Aug 2, 2023
3f4395d
feat: added supplier dashboard and changed responsiveness in app.vue
PaMarzec Aug 2, 2023
13151e9
fix(product stock response): product stock quantity was not updated
tom-rm-meyer-ISST Aug 2, 2023
8ddaef1
refactor: moved productstockrequestservice to stock package
eschrewe Aug 3, 2023
739c17d
refactor: removed apimarshalling service
eschrewe Aug 3, 2023
539a189
fix: improved logic to identify requested material
eschrewe Aug 4, 2023
92bbcc2
Merge remote-tracking branch 'origin/fix/apply-catenax-standards' int…
eschrewe Aug 4, 2023
b1560dc
Merge remote-tracking branch 'origin/feat/supplierDashboard' into ref…
eschrewe Aug 7, 2023
ee61653
fix: added license headers
eschrewe Aug 7, 2023
0bc5eeb
refactor: edited materials and products endpoints, added materialnumb…
eschrewe Aug 7, 2023
22afcf0
refactor: added frontendMaterialDto
eschrewe Aug 7, 2023
bffa9b9
refactor: refactoring complete
eschrewe Aug 7, 2023
6c0c4eb
fix: some cleaning up
eschrewe Aug 7, 2023
2a57f10
refactor: edited partner-product-stock endpoint, expects ownMaterialN…
eschrewe Aug 7, 2023
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockResponse;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import lombok.Setter;
import lombok.ToString;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype.DT_UseCaseEnum;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockResponse;

import java.util.Date;
import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
*/
package org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype;

import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockResponse;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockResponse;

/**
* Enum to track the status of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockResponse;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockResponse;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockResponse;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockRequest;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockResponse;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.datatype.DT_RequestStateEnum;
import org.eclipse.tractusx.puris.backend.stock.logic.dto.ProductStockRequestForMaterialDto;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.eclipse.tractusx.puris.backend.common.api.domain.model.ProductStockResponse;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStockResponse;

/**
* Dto for {@link ProductStockResponse}
Expand Down
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 @@ -19,9 +19,16 @@ public class VariablesService {

@Value("${request.apiassetid}")
private String requestApiAssetId;

@Value("${response.apiassetid}")
private String responseApiAssetId;

@Value("${own.bpnl}")
private String ownBpnl;

@Value("${edc.idsUrl}")
private String ownEdcIdsUrl;

/**
* Returns the asset-id as defined in the properties file for the given api method
* under request.apiassetid or response.apiassetid respectively.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
*/
package org.eclipse.tractusx.puris.backend.masterdata.domain.model;

import jakarta.persistence.*;
import lombok.*;
import org.eclipse.tractusx.puris.backend.stock.domain.model.Stock;

import java.util.*;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.Objects;
import java.util.Set;

@Entity
@Table(name = "material")
Expand All @@ -35,36 +41,6 @@
@NoArgsConstructor
public class Material {

@Id
@GeneratedValue
private UUID uuid;

@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(
name = "partner_supplies_product",
joinColumns = @JoinColumn(name = "material_uuid", referencedColumnName = "uuid"),
inverseJoinColumns = @JoinColumn(name = "partner_uuid", referencedColumnName = "uuid")
)
@ToString.Exclude
@Setter(AccessLevel.NONE)
private Set<Partner> suppliedByPartners = new HashSet<>();
;;

@ManyToMany(targetEntity = Partner.class, fetch = FetchType.EAGER)
@JoinTable(
name = "partner_orders_product",
joinColumns = @JoinColumn(name = "material_uuid", referencedColumnName = "uuid"),
inverseJoinColumns = @JoinColumn(name = "partner_uuid", referencedColumnName = "uuid")
)
@ToString.Exclude
@Setter(AccessLevel.NONE)
private Set<Partner> orderedByPartners = new HashSet<>();

@OneToMany(mappedBy = "uuid")
@ToString.Exclude
@Setter(AccessLevel.NONE)
private List<Stock> materialOnStocks = new ArrayList<>();

/**
* If true, then the Material is a material (input for production / something I buy).
* <p>
Expand All @@ -79,30 +55,27 @@ public class Material {
*/
private boolean productFlag;

private String materialNumberCustomer;

private String materialNumberSupplier;
@Id
private String ownMaterialNumber;

private String materialNumberCx;

private String name;

public Material(boolean materialFlag, boolean productFlag, String materialNumberCustomer, String materialNumberSupplier, String materialNumberCx, String name) {
this.materialFlag = materialFlag;
this.productFlag = productFlag;
this.materialNumberCustomer = materialNumberCustomer;
this.materialNumberSupplier = materialNumberSupplier;
this.materialNumberCx = materialNumberCx;
this.name = name;
}
@OneToMany(mappedBy = "material")
Set<MaterialPartnerRelation> materialPartnerRelations;

public void addPartnerToSuppliedByPartners(Partner supplierPartner) {
this.suppliedByPartners.add(supplierPartner);
supplierPartner.getSuppliesMaterials().add(this);
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Material)) return false;
Material material = (Material) o;
return Objects.equals(ownMaterialNumber, material.ownMaterialNumber);
}

public void addPartnerToOrderedByPartners(Partner customerPartner) {
this.orderedByPartners.add(customerPartner);
customerPartner.getOrdersProducts().add(this);
@Override
public int hashCode() {
return Objects.hash(ownMaterialNumber);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright (c) 2023 Volkswagen AG
* Copyright (c) 2023 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V.
* (represented by Fraunhofer ISST)
* 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.masterdata.domain.model;

import jakarta.persistence.*;
import lombok.*;

import java.io.Serializable;
import java.util.Objects;
import java.util.UUID;

@Entity
@Getter
@Setter
@AllArgsConstructor
public class MaterialPartnerRelation {

@EmbeddedId
Key key;

private String partnerMaterialNumber;
private boolean partnerSuppliesMaterial;
private boolean partnerBuysMaterial;

@ManyToOne
@MapsId("ownMaterialNumber")
@JoinColumn(name = "material_ownMaterialNumber")
Material material;

@ManyToOne
@MapsId("uuid")
@JoinColumn(name = "partner_uuid")
Partner partner;

public MaterialPartnerRelation() {
this.key = new Key();
}

public MaterialPartnerRelation(Material material, Partner partner, String partnerMaterialNumber, boolean partnerSupplies, boolean partnerBuys) {
this.material = material;
this.partner = partner;
this.key = new Key(material.getOwnMaterialNumber(), partner.getUuid());
this.partnerMaterialNumber = partnerMaterialNumber;
this.partnerSuppliesMaterial = partnerSupplies;
this.partnerBuysMaterial = partnerBuys;
}

@Override
public String toString() {
return "MaterialPartnerRelation{" +
"key=" + key +
", partnerMaterialNumber='" + partnerMaterialNumber + '\'' +
", partnerSuppliesMaterial=" + partnerSuppliesMaterial +
", partnerBuysMaterial=" + partnerBuysMaterial +
", material=" + material.getOwnMaterialNumber() +
", partner=" + partner.getBpnl() +
'}';
}

@Embeddable
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public static class Key implements Serializable {

@Column(name = "material_ownMaterialNumber")
private String ownMaterialNumber;

@Column(name = "partner_uuid")
private UUID partnerUuid;

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Key)) return false;
Key key = (Key) o;
return Objects.equals(ownMaterialNumber, key.ownMaterialNumber) && Objects.equals(partnerUuid, key.partnerUuid);
}

@Override
public int hashCode() {
return Objects.hash(ownMaterialNumber, partnerUuid);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package org.eclipse.tractusx.puris.backend.masterdata.domain.model;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.*;
import org.eclipse.tractusx.puris.backend.stock.domain.model.PartnerProductStock;
import org.eclipse.tractusx.puris.backend.stock.domain.model.ProductStock;
Expand All @@ -41,38 +40,40 @@ public class Partner {
@GeneratedValue
private UUID uuid;
private String name;
@NotNull
private boolean actsAsCustomerFlag;
@NotNull
private boolean actsAsSupplierFlag;
private String edcUrl;
private String bpnl;
private String siteBpns;

@ManyToMany(mappedBy = "suppliedByPartners", fetch = FetchType.EAGER)
@Setter(AccessLevel.NONE)
private Set<Material> suppliesMaterials = new HashSet<>();

@ManyToMany(mappedBy = "orderedByPartners", fetch = FetchType.EAGER)
@Setter(AccessLevel.NONE)
private Set<Material> ordersProducts = new HashSet<>();
@OneToMany(mappedBy = "partner")
private Set<MaterialPartnerRelation> materialPartnerRelations;

@OneToMany(mappedBy = "uuid", fetch = FetchType.LAZY)
@OneToMany
@ToString.Exclude
@Setter(AccessLevel.NONE)
private List<ProductStock> allocatedProductStocksForCustomer = new ArrayList<>();

@OneToMany(mappedBy = "uuid")
@OneToMany
@ToString.Exclude
@Setter(AccessLevel.NONE)
private List<PartnerProductStock> partnerProductStocks = new ArrayList<>();

public Partner(String name, boolean actsAsCustomerFlag, boolean actsAsSupplierFlag, String edcUrl, String bpnl, String siteBpns) {
public Partner(String name, String edcUrl, String bpnl, String siteBpns) {
this.name = name;
this.actsAsCustomerFlag = actsAsCustomerFlag;
this.actsAsSupplierFlag = actsAsSupplierFlag;
this.edcUrl = edcUrl;
this.bpnl = bpnl;
this.siteBpns = siteBpns;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Partner)) return false;
Partner partner = (Partner) o;
return Objects.equals(uuid, partner.uuid);
}

@Override
public int hashCode() {
return Objects.hash(uuid);
}
}
Loading
Loading