-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from FraunhoferISST/refactor/material
feat: added MaterialPartnerRelation and accompanying services
- Loading branch information
Showing
28 changed files
with
699 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
...a/org/eclipse/tractusx/puris/backend/masterdata/domain/model/MaterialPartnerRelation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...ractusx/puris/backend/masterdata/domain/repository/MaterialPartnerRelationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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.repository; | ||
|
||
import org.eclipse.tractusx.puris.backend.masterdata.domain.model.MaterialPartnerRelation; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
@Repository | ||
public interface MaterialPartnerRelationRepository extends JpaRepository<MaterialPartnerRelation, MaterialPartnerRelation.Key> { | ||
|
||
List<MaterialPartnerRelation> findAllByPartner_Uuid(UUID partnerUuid); | ||
|
||
List<MaterialPartnerRelation> findAllByPartner_UuidAndPartnerSuppliesMaterialIsTrue(UUID partnerUuid); | ||
|
||
List<MaterialPartnerRelation> findAllByPartner_UuidAndPartnerBuysMaterialIsTrue(UUID partnerUuid); | ||
|
||
List<MaterialPartnerRelation> findAllByMaterial_OwnMaterialNumber(String ownMaterialNumber); | ||
|
||
List<MaterialPartnerRelation> findAllByMaterial_OwnMaterialNumberAndPartnerSuppliesMaterialIsTrue(String ownMaterialNumber); | ||
|
||
List<MaterialPartnerRelation> findAllByMaterial_OwnMaterialNumberAndPartnerBuysMaterialIsTrue(String ownMaterialNumber); | ||
|
||
List<MaterialPartnerRelation> findAllByPartnerMaterialNumber(String partnerMaterialNumber); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.